hashmap: Fix removing last entry in l_hashmap_foreach_remove
PATCH 1/1 hashmap: Fix removing last entry in l_hashmap_foreach_remove
When the last entry in a bucket with 2 or more entries was removed the loop would roll over and iterate over the remaining entries for a second time (then stop), add missing check.
--- ell/hashmap.c | 2 ++ 1 file changed, 2 insertions(+)
ell/hashmap.c +2 -0
@@ -607,6 +607,8 @@ LIB_EXPORT unsigned int l_hashmap_foreach_remove(struct l_hashmap *hashmap,free_key (hashmap, entry->key);l_free (entry); entry = prev->next; +if (entry == head) +break ;continue ; }
Signature · 1 line
2.19.1
Hi Andrew,
Quoted 7 lines · Andrew Zaborowski
When the last entry in a bucket with 2 or more entries was removed the loop would roll over and iterate over the remaining entries for a second time (then stop), add missing check.
--- ell/hashmap.c | 2 ++ 1 file changed, 2 insertions(+)
Hah, good catch. Applied, thanks.
Regards,
-Denis