(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 <hniksic@xemacs.org>
/* 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. */
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
goto next_rehash;
*mp_new = *mp;
- mp->key = NULL;
+ MARK_AS_EMPTY (mp);
next_rehash:
;