From 2c56adac9d0191c8d85f1c188365041ea5e1bbbf Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 24 Dec 2022 04:14:03 +0100 Subject: Use GEHASHMAP_FOREACH_SAFE() in n##_free() --- src/gehashmap.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src') 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); \ } \ \ -- cgit v1.2.3