summary refs log tree commit diff
path: root/hashmap.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-10-06 23:30:30 +0000
committerJunio C Hamano <gitster@pobox.com>2019-10-07 10:20:10 +0900
commitb6c5241606e67b57470e86ccf547d4ab90008a1d (patch)
tree1c038790abd92afde1f8a256c2f0ac37ec19f69c /hashmap.c
parentb94e5c1df674eb4ec8fdeaaae1ad8df552cb5d70 (diff)
hashmap_get takes "const struct hashmap_entry *"
This is less error-prone than "const void *" as the compiler
now detects invalid types being passed.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'hashmap.c')
-rw-r--r--hashmap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/hashmap.c b/hashmap.c
index 9c2db3e0c8..092236c09a 100644
--- a/hashmap.c
+++ b/hashmap.c
@@ -186,7 +186,8 @@ void hashmap_free(struct hashmap *map, int free_entries)
 	memset(map, 0, sizeof(*map));
 }
 
-void *hashmap_get(const struct hashmap *map, const void *key, const void *keydata)
+void *hashmap_get(const struct hashmap *map, const struct hashmap_entry *key,
+		const void *keydata)
 {
 	return *find_entry_ptr(map, key, keydata);
 }
@@ -296,7 +297,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, data);
+	e = hashmap_get(&map, &key.ent, data);
 	if (!e) {
 		/* not found: create it */
 		FLEX_ALLOC_MEM(e, data, data, len);