summaryrefslogtreecommitdiff
path: root/compiler/hashmap.c
diff options
context:
space:
mode:
authorQuinn Stephens <quinn@osmora.org>2024-11-03 16:53:16 -0500
committerQuinn Stephens <quinn@osmora.org>2024-11-03 16:53:16 -0500
commit71b10c1c765196a771ce05216395d6b78892a735 (patch)
treeea88735919caebb6500d0b3ae78820c083048e25 /compiler/hashmap.c
parent388025e5a7d2d7997926c6a9af8767ca9ccb12bf (diff)
[compiler] More small refactoring
Signed-off-by: Quinn Stephens <quinn@osmora.org>
Diffstat (limited to 'compiler/hashmap.c')
-rw-r--r--compiler/hashmap.c16
1 files changed, 16 insertions, 0 deletions
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 <stddef.h>
+#include <stdlib.h>
#include "hashmap.h"
void
@@ -31,6 +32,21 @@ hashmap_find(struct hashmap *map, hash_t hash)
}
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)
{
for (size_t r = 0; r < map->n_rows; r++) {