When navigating over the nodes in the same bucket of a hash
table, one only needs the next pointer of the current node
in order to move to the next node (in the same bucket).  The
delete operation was using the container-wide iterator to get
the pointer to the next node, but this was incorrect, as
that iterator operation will navigate across buckets.  The
(incorrect) use of the iterator was replaced with the (correct)
use of the Next selector operation, which returns the value of the
Next component of the current node.

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

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

        * a-chtgbo.adb (Delete_Node_Sans_Free): Replace iterator with selector.

Index: a-chtgbo.adb
===================================================================
--- a-chtgbo.adb        (revision 176998)
+++ a-chtgbo.adb        (working copy)
@@ -78,7 +78,7 @@
       end if;
 
       if Prev = X then
-         HT.Buckets (Indx) := Next (HT, Prev);
+         HT.Buckets (Indx) := Next (HT.Nodes (Prev));
          HT.Length := HT.Length - 1;
          return;
       end if;
@@ -89,7 +89,7 @@
       end if;
 
       loop
-         Curr := Next (HT, Prev);
+         Curr := Next (HT.Nodes (Prev));
 
          if Curr = 0 then
             raise Program_Error with
@@ -97,7 +97,7 @@
          end if;
 
          if Curr = X then
-            Set_Next (HT.Nodes (Prev), Next => Next (HT, Curr));
+            Set_Next (HT.Nodes (Prev), Next => Next (HT.Nodes (Curr)));
             HT.Length := HT.Length - 1;
             return;
          end if;

Reply via email to