summaryrefslogtreecommitdiff
path: root/hashmap.h
diff options
context:
space:
mode:
authorLibravatar Eric Wong <e@80x24.org>2019-10-06 23:30:30 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-10-07 10:20:10 +0900
commitb6c5241606e67b57470e86ccf547d4ab90008a1d (patch)
tree1c038790abd92afde1f8a256c2f0ac37ec19f69c /hashmap.h
parenthashmap_add takes "struct hashmap_entry *" (diff)
downloadtgif-b6c5241606e67b57470e86ccf547d4ab90008a1d.tar.xz
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.h')
-rw-r--r--hashmap.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/hashmap.h b/hashmap.h
index 47ee5c00d7..ef83f9431d 100644
--- a/hashmap.h
+++ b/hashmap.h
@@ -74,7 +74,8 @@
* e->key = key;
*
* flags |= COMPARE_VALUE;
- * printf("%sfound\n", hashmap_get(&map, e, NULL) ? "" : "not ");
+ * printf("%sfound\n",
+ * hashmap_get(&map, &e->ent, NULL) ? "" : "not ");
* free(e);
* }
*
@@ -84,7 +85,8 @@
* k.key = key;
*
* flags |= COMPARE_VALUE;
- * printf("%sfound\n", hashmap_get(&map, &k, value) ? "" : "not ");
+ * printf("%sfound\n",
+ * hashmap_get(&map, &k->ent, value) ? "" : "not ");
* }
*
* if (!strcmp("end", action)) {
@@ -286,7 +288,7 @@ static inline unsigned int hashmap_get_size(struct hashmap *map)
* If an entry with matching hash code is found, `key` and `keydata` are passed
* to `hashmap_cmp_fn` to decide whether the entry matches the key.
*/
-void *hashmap_get(const struct hashmap *map, const void *key,
+void *hashmap_get(const struct hashmap *map, const struct hashmap_entry *key,
const void *keydata);
/*