Browse Source

[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 tháng trước cách đây
mục cha
commit
49115591fc
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  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.
 	End Rem
 	Method Remove()
-		_value=Null
-		_succ._pred=_pred
 		_pred._succ=_succ
+		_succ._pred=_pred
+		_value=Null
 	End Method
 
 End Type