Patchwork [Ada] Incorrect assignment when deleting node

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 1, 2011, 9:16 a.m.
Message ID <20110801091602.GA1953@adacore.com>
Download mbox | patch
Permalink /patch/107697/
State New
Headers show

Comments

Arnaud Charlet - Aug. 1, 2011, 9:16 a.m.
When a node was being removed from the tree, the node itself was
being assigned to the child of its parent, which was incorrect.
The correct assignment value is the left child of the deleted node.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-01  Matthew Heaney  <heaney@adacore.com>

	* a-rbtgbo.adb (Delete_Node_Sans_Free): Fixed assignment to left child
	of node.

Patch

Index: a-rbtgbo.adb
===================================================================
--- a-rbtgbo.adb	(revision 176998)
+++ a-rbtgbo.adb	(working copy)
@@ -330,7 +330,7 @@ 
                   Set_Right (N (Parent (N (Z))), Y);
                end if;
 
-               Set_Left (N (Y), Z);
+               Set_Left (N (Y), Left (N (Z)));
                Set_Parent (N (Left (N (Y))), Y);
                Set_Right (N (Y), Z);
                Set_Parent (N (Z), Y);