]> git.ipfire.org Git - thirdparty/git.git/blobdiff - hashmap.c
hashmap_get_next takes "const struct hashmap_entry *"
[thirdparty/git.git] / hashmap.c
index d42f01ff5ae6f3494d5b427c64bc64406c35d576..c1de40eea0aa1e1f5b99d7626c0f6988b6ba2ffc 100644 (file)
--- a/hashmap.c
+++ b/hashmap.c
@@ -191,9 +191,10 @@ void *hashmap_get(const struct hashmap *map, const void *key, const void *keydat
        return *find_entry_ptr(map, key, keydata);
 }
 
-void *hashmap_get_next(const struct hashmap *map, const void *entry)
+void *hashmap_get_next(const struct hashmap *map,
+                       const struct hashmap_entry *entry)
 {
-       struct hashmap_entry *e = ((struct hashmap_entry *) entry)->next;
+       struct hashmap_entry *e = entry->next;
        for (; e; e = e->next)
                if (entry_equals(map, entry, e, NULL))
                        return e;
@@ -293,13 +294,13 @@ const void *memintern(const void *data, size_t len)
                hashmap_init(&map, (hashmap_cmp_fn) pool_entry_cmp, NULL, 0);
 
        /* lookup interned string in pool */
-       hashmap_entry_init(&key, memhash(data, len));
+       hashmap_entry_init(&key.ent, memhash(data, len));
        key.len = len;
        e = hashmap_get(&map, &key, data);
        if (!e) {
                /* not found: create it */
                FLEX_ALLOC_MEM(e, data, data, len);
-               hashmap_entry_init(e, key.ent.hash);
+               hashmap_entry_init(&e->ent, key.ent.hash);
                e->len = len;
                hashmap_add(&map, e);
        }