summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-12-24 04:14:03 +0100
committerThomas Voss <mail@thomasvoss.com> 2022-12-24 04:14:03 +0100
commit2c56adac9d0191c8d85f1c188365041ea5e1bbbf (patch)
treee6640f193d2df6ae4dd0e2a700f5f863f7e506b1
parentb635385784508eac26f1c5a820f70e2a71aa3958 (diff)
Use GEHASHMAP_FOREACH_SAFE() in n##_free()
-rw-r--r--src/gehashmap.h11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/gehashmap.h b/src/gehashmap.h
index 2fc9ffb..9415589 100644
--- a/src/gehashmap.h
+++ b/src/gehashmap.h
@@ -87,14 +87,9 @@
void \
n##_free(n##_t *map) \
{ \
- for (size_t i = 0; i < map->capacity; i++) { \
- struct n##_entry *entry = map->entries[i]; \
- while (entry != NULL) { \
- struct n##_entry *next = entry->next; \
- free(entry); \
- entry = next; \
- } \
- } \
+ struct n##_entry *entry, *tmp; \
+ GEHASHMAP_FOREACH_SAFE(entry, tmp, map) \
+ free(entry); \
free(map->entries); \
} \
\