diff options
author | 2006-10-19 09:01:48 +1000 | |
---|---|---|
committer | 2006-10-19 09:01:48 +1000 | |
commit | c7bc31fe505bcc762afccf16ca77653161d0ed3b (patch) | |
tree | 5c606f294512b27f07903afa26358de870784681 /util.c | |
parent | bab168f1d1c0db1b1a9aba208a87380616ac0850 (diff) |
Fix exceptaionally rare crash bug in hash tables (happens once in every 2^32 hash lookups
darcs-hash:20061018230148-ac50b-4e67ecf1f9aeae8239c40101ae2ad6aa164c31bb.gz
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -207,7 +207,7 @@ static int hash_search( hash_table_t *h, int pos; hv = h->hash_func( key ); - pos = abs(hv) % h->size; + pos = (hv & 0x7fffffff) % h->size; while(1) { if( (h->arr[pos].key == 0 ) || @@ -370,7 +370,7 @@ void hash_remove( hash_table_t *h, { int hv = h->hash_func( h->arr[next_pos].key ); - int ideal_pos = abs( hv ) % h->size; + int ideal_pos = ( hv & 0x7fffffff) % h->size; int dist_old = (next_pos - ideal_pos + h->size)%h->size; int dist_new = (pos - ideal_pos + h->size)%h->size; if ( dist_new < dist_old ) |