From 15121096d4adcfddf59141e8f1d10577320fd295 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 15 Mar 2011 16:19:47 +0100 Subject: [PATCH] Allow removal of hashtable entry in callback of hashtable_map --- src/core/wee-hashtable.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/wee-hashtable.c b/src/core/wee-hashtable.c index 99210cbc7..6fc09a00d 100644 --- a/src/core/wee-hashtable.c +++ b/src/core/wee-hashtable.c @@ -431,20 +431,24 @@ hashtable_map (struct t_hashtable *hashtable, void *callback_map_data) { int i; - struct t_hashtable_item *ptr_item; + struct t_hashtable_item *ptr_item, *ptr_next_item; if (!hashtable) return; for (i = 0; i < hashtable->size; i++) { - for (ptr_item = hashtable->htable[i]; ptr_item; - ptr_item = ptr_item->next_item) + ptr_item = hashtable->htable[i]; + while (ptr_item) { + ptr_next_item = ptr_item->next_item; + (void) (callback_map) (callback_map_data, hashtable, ptr_item->key, ptr_item->value); + + ptr_item = ptr_next_item; } } }