summaryrefslogtreecommitdiff
path: root/libihash
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-04-28 23:59:26 +0200
committerJustus Winter <justus@gnupg.org>2016-04-29 22:39:06 +0200
commit74d373342f799a45e9193c2f56189843b7b42c04 (patch)
tree5f90392df013caebd86b93f7f8ad562508ef3cba /libihash
parentd18ea50ec00210680b80359cb182a0175374d5e1 (diff)
libihash: fix index computation
Previously, find_index would return a suboptimal slot if a tombstone was in the optimal slot. * libihash/ihash.c (find_index): Fix index computation.
Diffstat (limited to 'libihash')
-rw-r--r--libihash/ihash.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/libihash/ihash.c b/libihash/ihash.c
index 4bc54fdb..01ba23bd 100644
--- a/libihash/ihash.c
+++ b/libihash/ihash.c
@@ -81,15 +81,9 @@ find_index (hurd_ihash_t ht, hurd_ihash_key_t key)
idx = hash (ht, key) & mask;
- if (ht->items[idx].value == _HURD_IHASH_EMPTY
- || compare (ht, ht->items[idx].key, key))
- return idx;
-
up_idx = idx;
-
do
{
- up_idx = (up_idx + 1) & mask;
if (ht->items[up_idx].value == _HURD_IHASH_EMPTY)
return first_deleted_set ? first_deleted : up_idx;
if (compare (ht, ht->items[up_idx].key, key))
@@ -97,6 +91,7 @@ find_index (hurd_ihash_t ht, hurd_ihash_key_t key)
if (! first_deleted_set
&& ht->items[up_idx].value == _HURD_IHASH_DELETED)
first_deleted = up_idx, first_deleted_set = 1;
+ up_idx = (up_idx + 1) & mask;
}
while (up_idx != idx);