hash_element *hash_lookup(hash_table *table, char *key);
hash_element *hash_insert(hash_table *table, char *value, char *key);
void hash_remove(hash_table *table, hash_element *hash_elem);
-void hash_clear(hash_table *table);
+BOOL hash_clear(hash_table *table);
/*The following definitions come from lib/interface.c */
table->size = 2;
table->comp_func = compare_func;
while (table->size < num_buckets)
- table->size <<= 1;
+ table->size <<= 1;
for (i = 0; i < NUM_PRIMES; i++) {
if (primes[i] > table->size) {
table->size = primes[i];
*************************************************************************
*/
-void hash_clear(hash_table *table)
+BOOL hash_clear(hash_table *table)
{
int i;
ubi_dlList *bucket = table->buckets;
free((char *)hash_elem);
}
}
+ table->size = 0;
if(table->buckets)
free((char *) table->buckets);
+ table->buckets = NULL;
+
+ /* Reinitialize the hash table. */
+ if(!hash_table_init(table, 0, table->comp_func))
+ return False;
+
+ return True;
}