From 71b10c1c765196a771ce05216395d6b78892a735 Mon Sep 17 00:00:00 2001 From: Quinn Stephens Date: Sun, 3 Nov 2024 16:53:16 -0500 Subject: [compiler] More small refactoring Signed-off-by: Quinn Stephens --- compiler/hashmap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'compiler/hashmap.c') diff --git a/compiler/hashmap.c b/compiler/hashmap.c index 0fb2e14..e5aed7b 100644 --- a/compiler/hashmap.c +++ b/compiler/hashmap.c @@ -5,6 +5,7 @@ */ #include +#include #include "hashmap.h" void @@ -30,6 +31,21 @@ hashmap_find(struct hashmap *map, hash_t hash) return NULL; } +void +hashmap_free_entries(struct hashmap *map) +{ + struct hashmap_entry *ent, *next; + + for (size_t r = 0; r < map->n_rows; r++) { + ent = (struct hashmap_entry*)map->rows[r].head; + while (ent != (struct hashmap_entry*)&map->rows[r]) { + next = (struct hashmap_entry*)ent->list_entry.next; + free(ent); + ent = next; + } + } +} + void hashmap_init(struct hashmap *map) { -- cgit v1.2.3