소스 검색

[Brl.LinkedList] Change assignment order in TLink.remove (#247)

When removing a link, change neighbour links before setting the link
value to null which is the intuitive order of modifications.
Even though LinkedList is not thread-safe and this change does not
prevent segmentation faults, it may reduce the chance of null access
problems when concurrently modifying and iterating over the list.
Alexander Nittka 6 달 전
부모
커밋
49115591fc
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      linkedlist.mod/linkedlist.bmx

+ 2 - 2
linkedlist.mod/linkedlist.bmx

@@ -66,9 +66,9 @@ Type TLink
 	bbdoc: Removes the link from the List.
 	bbdoc: Removes the link from the List.
 	End Rem
 	End Rem
 	Method Remove()
 	Method Remove()
-		_value=Null
-		_succ._pred=_pred
 		_pred._succ=_succ
 		_pred._succ=_succ
+		_succ._pred=_pred
+		_value=Null
 	End Method
 	End Method
 
 
 End Type
 End Type