summaryrefslogtreecommitdiff
path: root/compiler/hashmap.c
diff options
context:
space:
mode:
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++) {