--- hash.c~ Fri Mar 3 11:10:08 2000 +++ hash.c Sat Oct 13 10:15:26 2001 @@ -121,7 +121,7 @@ void hash_delete_hash (HASH * table, int { *last = ptr->next; if (destroy) destroy (ptr->data); - FREE (&ptr); + free (ptr); return; } } @@ -136,15 +136,38 @@ void hash_destroy (HASH **ptr, void (*de HASH *pptr = *ptr; struct hash_elem *elem, *tmp; - for (i = 0 ; i < pptr->nelem; i++) + /* We want to keep the test for the optional destroy argument out + * of the loop to get a faster execution. The price we pay is that + * we then have to have two versions of the loop. + */ +#if 0 + /* Nobody use the destroy argument at the moment, so the destroy + * version of the loop is out-commented until somebody needs it. + */ + if (destroy) { - for (elem = pptr->table[i]; elem; ) + for (i = 0 ; i < pptr->nelem; i++) { - tmp = elem; - elem = elem->next; - if (destroy) + for (elem = pptr->table[i]; elem; ) + { + tmp = elem; + elem = elem->next; destroy (tmp->data); - safe_free ((void **) &tmp); + free (tmp); + } + } + } + else +#endif + { + for (i = 0 ; i < pptr->nelem; i++) + { + for (elem = pptr->table[i]; elem; ) + { + tmp = elem; + elem = elem->next; + free (tmp); + } } } safe_free ((void **) &pptr->table);