From: hniksic Date: Sat, 8 Nov 2003 00:52:23 +0000 (-0800) Subject: [svn] Mark entries as deleted with the correct marker. X-Git-Tag: v1.13~1451 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=fef88bd179baadb4e6e55bfc0569320b476955e3 [svn] Mark entries as deleted with the correct marker. --- diff --git a/src/ChangeLog b/src/ChangeLog index 8c422f9b..85b6c5cb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -4,6 +4,8 @@ (grow_hash_table): Extract ht->hash_function outside the loop. (hash_table_remove): Ditto. (hash_table_clear): Fill entries with 0xff to clear them. + (hash_table_remove): Mark entries as deleted with the correct + marker. 2003-11-08 Hrvoje Niksic diff --git a/src/hash.c b/src/hash.c index b7b73fdc..2c8d1351 100644 --- a/src/hash.c +++ b/src/hash.c @@ -161,7 +161,9 @@ struct hash_table { /* We use all-bit-set marker to mean that a mapping is empty. It is (hopefully) illegal as a pointer, and it allows the users to use NULL (as well as any non-negative integer) as key. */ + #define NON_EMPTY(mp) (mp->key != (void *)~(unsigned long)0) +#define MARK_AS_EMPTY(mp) (mp->key = (void *)~(unsigned long)0) /* "Next" mapping is the mapping after MP, but wrapping back to MAPPINGS when MP would reach MAPPINGS+SIZE. */ @@ -438,7 +440,7 @@ hash_table_remove (struct hash_table *ht, const void *key) struct mapping *mappings = ht->mappings; hashfun_t hasher = ht->hash_function; - mp->key = NULL; + MARK_AS_EMPTY (mp); --ht->count; /* Rehash all the entries following MP. The alternative @@ -461,7 +463,7 @@ hash_table_remove (struct hash_table *ht, const void *key) goto next_rehash; *mp_new = *mp; - mp->key = NULL; + MARK_AS_EMPTY (mp); next_rehash: ;