diff options
author | Stefan Beller <sbeller@google.com> | 2017-06-30 17:28:29 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-05 13:53:12 -0700 |
commit | 201c14e375bfc0b81c6d7e12d1bae3ba22ce8038 (patch) | |
tree | 73c591c7f1435838255b5018538d8da0ce9d91ed /attr.c | |
parent | 1ecbf31d0298a1ed952623108e23234d5cf37086 (diff) | |
download | git-201c14e375bfc0b81c6d7e12d1bae3ba22ce8038.tar.gz |
attr.c: drop hashmap_cmp_fn cast
MAke the code more readable and less error prone by avoiding the cast
of the compare function pointer in hashmap_init, but instead have the
correctly named void pointers to casted to the specific data structure.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'attr.c')
-rw-r--r-- | attr.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -76,18 +76,20 @@ struct attr_hash_entry { }; /* attr_hashmap comparison function */ -static int attr_hash_entry_cmp(void *unused_cmp_data, - const struct attr_hash_entry *a, - const struct attr_hash_entry *b, - void *unused_keydata) +static int attr_hash_entry_cmp(const void *unused_cmp_data, + const void *entry, + const void *entry_or_key, + const void *unused_keydata) { + const struct attr_hash_entry *a = entry; + const struct attr_hash_entry *b = entry_or_key; return (a->keylen != b->keylen) || strncmp(a->key, b->key, a->keylen); } /* Initialize an 'attr_hashmap' object */ static void attr_hashmap_init(struct attr_hashmap *map) { - hashmap_init(&map->map, (hashmap_cmp_fn) attr_hash_entry_cmp, NULL, 0); + hashmap_init(&map->map, attr_hash_entry_cmp, NULL, 0); } /* |