Package: staden-io-lib / 1.14.11-6

242cd6b.patch Patch series | download
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From: Rob Davies <rmd+git@sanger.ac.uk>
Date: Fri, 7 Dec 2018 11:11:12 +0000
Origin: https://github.com/jkbonfield/io_lib/commit/242cd6b
Bug-Debian: https://bugs.debian.org/915460
Subject: [PATCH] Fix hash table HASH_INT_KEYS on 32-bit platforms

The hash table has the option to declare the key pointer is the key
itself rather than the memory it points to.  It assumed however that
the key was 8 bytes long, rather than sizeof(char *).

Fixes Debian Bug#915460
---
 io_lib/hash_table.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/io_lib/hash_table.c b/io_lib/hash_table.c
index 6c37ff8..238cafa 100644
--- a/io_lib/hash_table.c
+++ b/io_lib/hash_table.c
@@ -478,7 +478,7 @@ int HashTableResize(HashTable *h, int newsize) {
 	for (hi = h->bucket[i]; hi; hi = next) {
 	    uint64_t hv = h2->options & HASH_INT_KEYS
 		? hash64(h2->options & HASH_FUNC_MASK,
-			 (uint8_t *)&hi->key, hi->key_len) & h2->mask
+			 (uint8_t *)&hi->key, sizeof(hi->key)) & h2->mask
 		: hash64(h2->options & HASH_FUNC_MASK,
 			 (uint8_t *)hi->key, hi->key_len) & h2->mask;
 	    next = hi->next;
@@ -535,7 +535,7 @@ HashItem *HashTableAdd(HashTable *h, char *key, int key_len, HashData data,
 	key_len = strlen(key);
 
     hv = h->options & HASH_INT_KEYS
-	? hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, key_len) & h->mask
+	? hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key)) & h->mask
 	: hash64(h->options & HASH_FUNC_MASK, (uint8_t *)key, key_len) & h->mask;
 
     /* Already exists? */
@@ -603,7 +603,7 @@ int HashTableDel(HashTable *h, HashItem *hi, int deallocate_data) {
 
     hv = h->options & HASH_INT_KEYS
 	? hash64(h->options & HASH_FUNC_MASK,
-		 (uint8_t *)&hi->key, hi->key_len) & h->mask
+		 (uint8_t *)&hi->key, sizeof(hi->key)) & h->mask
 	: hash64(h->options & HASH_FUNC_MASK,
 		 (uint8_t *)hi->key, hi->key_len) & h->mask;
 
@@ -651,7 +651,7 @@ int HashTableRemove(HashTable *h, char *key, int key_len,
 	key_len = strlen(key);
 
     hv = h->options & HASH_INT_KEYS
-	? hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, key_len) & h->mask
+	? hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key)) & h->mask
 	: hash64(h->options & HASH_FUNC_MASK, (uint8_t *)key, key_len) & h->mask;
 
     last = NULL;
@@ -702,7 +702,7 @@ HashItem *HashTableSearch(HashTable *h, char *key, int key_len) {
 	key_len = strlen(key);
 
     if (h->options & HASH_INT_KEYS) {
-	hv = hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, key_len)& h->mask;
+	hv = hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key))& h->mask;
 
 	for (hi = h->bucket[hv]; hi; hi = hi->next) {
 	    if ((int)(size_t)key == (int)(size_t)hi->key)