path: root/hashmap.c
diff options
authorEric Wong <>2019-10-06 23:30:36 (GMT)
committerJunio C Hamano <>2019-10-07 01:20:11 (GMT)
commitf23a465132a22860684ac66052cf9a954a18e27d (patch)
tree0af87116e641be6cc7f7dc75e1a337e917abc610 /hashmap.c
parentf0e63c41139f8982add435536d39aff6f3d4ca98 (diff)
hashmap_get{,_from_hash} return "struct hashmap_entry *"
Update callers to use hashmap_get_entry, hashmap_get_entry_from_hash or container_of as appropriate. This is another step towards eliminating the requirement of hashmap_entry being the first field in a struct. Signed-off-by: Eric Wong <> Reviewed-by: Derrick Stolee <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'hashmap.c')
1 files changed, 4 insertions, 3 deletions
diff --git a/hashmap.c b/hashmap.c
index 22bc7c5..5662bee 100644
--- a/hashmap.c
+++ b/hashmap.c
@@ -186,8 +186,9 @@ void hashmap_free(struct hashmap *map, int free_entries)
memset(map, 0, sizeof(*map));
-void *hashmap_get(const struct hashmap *map, const struct hashmap_entry *key,
- const void *keydata)
+struct hashmap_entry *hashmap_get(const struct hashmap *map,
+ const struct hashmap_entry *key,
+ const void *keydata)
return *find_entry_ptr(map, key, keydata);
@@ -298,7 +299,7 @@ const void *memintern(const void *data, size_t len)
/* lookup interned string in pool */
hashmap_entry_init(&key.ent, memhash(data, len));
key.len = len;
- e = hashmap_get(&map, &key.ent, data);
+ e = hashmap_get_entry(&map, &key, data, struct pool_entry, ent);
if (!e) {
/* not found: create it */
FLEX_ALLOC_MEM(e, data, data, len);