Permit hashtable_foreach iterator to remove the current entry

This commit is contained in:
Tony Garnock-Jones 2011-01-02 18:13:51 -05:00
parent 97b610452f
commit 0cab9ca4f5
1 changed files with 4 additions and 2 deletions

View File

@ -132,9 +132,11 @@ void hashtable_foreach(hashtable_t *table,
{
int i;
for (i = 0; i < table->bucket_count; i++) {
hashtable_entry_t *chain;
for (chain = table->buckets[i]; chain != NULL; chain = chain->next) {
hashtable_entry_t *chain = table->buckets[i];
while (chain != NULL) {
hashtable_entry_t *next = chain->next;
iterator(context, chain->key, chain->value);
chain = next;
}
}
}