1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
From f318ac5b55327ba8787d675b3f2470644b7a81e8 Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@gnupg.org>
Date: Thu, 28 Apr 2016 23:59:26 +0200
Subject: [PATCH hurd 1/3] 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.
---
libihash/ihash.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/libihash/ihash.c b/libihash/ihash.c
index 4bc54fd..01ba23b 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);
--
2.1.4
|