aboutsummaryrefslogtreecommitdiff
path: root/src/hashmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hashmap.c')
-rw-r--r--src/hashmap.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/hashmap.c b/src/hashmap.c
index fa9a295..2522907 100644
--- a/src/hashmap.c
+++ b/src/hashmap.c
@@ -117,10 +117,6 @@ hashmap_new_with_cap(size_t cap)
return hm;
}
-/*
- * Inserts a key-value pair into the map. Returns NULL if map did not have key,
- * old value if it did.
- */
void *
hashmap_insert(struct hashmap *hm, const char *key, void *value)
{
@@ -148,7 +144,6 @@ hashmap_insert(struct hashmap *hm, const char *key, void *value)
return NULL;
}
-/* Returns a pointer to the value corresponding to the key. */
void *
hashmap_get(struct hashmap *hm, const char *key)
{
@@ -165,7 +160,6 @@ hashmap_get(struct hashmap *hm, const char *key)
return NULL;
}
-/* Retrieve pointer to value by key, handles dot notation for nested hashmaps */
void *
hashmap_resolve(struct hashmap *hm, const char *key)
{
@@ -192,10 +186,6 @@ hashmap_resolve(struct hashmap *hm, const char *key)
return hm;
}
-/*
- * Removes a key from the map, returning the value at the key if the key was
- * previously in the map.
- */
void *
hashmap_remove(struct hashmap *hm, const char *key)
{
@@ -226,7 +216,7 @@ hashmap_remove(struct hashmap *hm, const char *key)
}
void
-hashmap_walk(struct hashmap *hm, void (*fn)(void *value))
+hashmap_walk(struct hashmap *hm, void (*fn)(const void *key, void *value))
{
struct node *node;
struct node *next;
@@ -235,13 +225,12 @@ hashmap_walk(struct hashmap *hm, void (*fn)(void *value))
node = hm->buckets[i];
while (node) {
next = node->next;
- fn(node->value);
+ fn(node->key, node->value);
node = next;
}
}
}
-/* free hashmap related memory */
void
hashmap_free(struct hashmap *hm)
{