When a node is allocated from the free store, its pointer components (the links
to other nodes in the tree) must also be initialized (to 0, the equivalent of
null). This simplifies the post-allocation handling of nodes inserted into
terminal positions.
Tested on x86_64-pc-linux-gnu, committed on trunk
2011-08-31 Matthew Heaney <[email protected]>
* a-rbtgbo.adb (Generic_Allocate): Initialize pointer components of
node to null value.
Index: a-rbtgbo.adb
===================================================================
--- a-rbtgbo.adb (revision 178358)
+++ a-rbtgbo.adb (working copy)
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2004-2010, Free Software Foundation, Inc. --
+-- Copyright (C) 2004-2011, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -586,6 +586,10 @@
Set_Element (N (Node));
Tree.Free := Tree.Free - 1;
end if;
+
+ Set_Parent (N (Node), Parent => 0);
+ Set_Left (N (Node), Left => 0);
+ Set_Right (N (Node), Right => 0);
end Generic_Allocate;
-------------------