]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hashmap.h: compare function has access to a data field
authorStefan Beller <sbeller@google.com>
Fri, 30 Jun 2017 19:14:05 +0000 (12:14 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Jun 2017 19:49:28 +0000 (12:49 -0700)
When using the hashmap a common need is to have access to caller provided
data in the compare function. A couple of times we abuse the keydata field
to pass in the data needed. This happens for example in patch-ids.c.

This patch changes the function signature of the compare function
to have one more void pointer available. The pointer given for each
invocation of the compare function must be defined in the init function
of the hashmap and is just passed through.

Documentation of this new feature is deferred to a later patch.
This is a rather mechanical conversion, just adding the new pass-through
parameter.  However while at it improve the naming of the fields of all
compare functions used by hashmaps by ensuring unused parameters are
prefixed with 'unused_' and naming the parameters what they are (instead
of 'unused' make it 'unused_keydata').

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
19 files changed:
attr.c
builtin/describe.c
builtin/difftool.c
builtin/fast-export.c
config.c
convert.c
diffcore-rename.c
hashmap.c
hashmap.h
name-hash.c
oidset.c
patch-ids.c
refs.c
remote.c
sha1_file.c
sub-process.c
sub-process.h
submodule-config.c
t/helper/test-hashmap.c

diff --git a/attr.c b/attr.c
index 37454999d21e9dcea73e6717da608d80720235e8..56961f02361129b5cb49e6ffb7ab185655f09c41 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -76,9 +76,10 @@ struct attr_hash_entry {
 };
 
 /* attr_hashmap comparison function */
-static int attr_hash_entry_cmp(const struct attr_hash_entry *a,
+static int attr_hash_entry_cmp(void *unused_cmp_data,
+                              const struct attr_hash_entry *a,
                               const struct attr_hash_entry *b,
-                              void *unused)
+                              void *unused_keydata)
 {
        return (a->keylen != b->keylen) || strncmp(a->key, b->key, a->keylen);
 }
@@ -86,7 +87,7 @@ static int attr_hash_entry_cmp(const struct attr_hash_entry *a,
 /* 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, 0);
+       hashmap_init(&map->map, (hashmap_cmp_fn) attr_hash_entry_cmp, NULL, 0);
 }
 
 /*
index 70eb1446089583cd859ea1f05b260283cd78067f..8868f00ed0059595b5ce5c05d8905f72a637bcb7 100644 (file)
@@ -54,8 +54,10 @@ static const char *prio_names[] = {
        N_("head"), N_("lightweight"), N_("annotated"),
 };
 
-static int commit_name_cmp(const struct commit_name *cn1,
-               const struct commit_name *cn2, const void *peeled)
+static int commit_name_cmp(const void *unused_cmp_data,
+                          const struct commit_name *cn1,
+                          const struct commit_name *cn2,
+                          const void *peeled)
 {
        return oidcmp(&cn1->peeled, peeled ? peeled : &cn2->peeled);
 }
@@ -501,7 +503,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
                return cmd_name_rev(args.argc, args.argv, prefix);
        }
 
-       hashmap_init(&names, (hashmap_cmp_fn) commit_name_cmp, 0);
+       hashmap_init(&names, (hashmap_cmp_fn) commit_name_cmp, NULL, 0);
        for_each_rawref(get_name, NULL);
        if (!names.size && !always)
                die(_("No names found, cannot describe anything."));
index 9199227f6e9dc0b6d0c3e350f701aeaf9caaddd3..a1a26ba8912f4ee49527b287657826440fd92e9e 100644 (file)
@@ -130,8 +130,10 @@ struct working_tree_entry {
        char path[FLEX_ARRAY];
 };
 
-static int working_tree_entry_cmp(struct working_tree_entry *a,
-                                 struct working_tree_entry *b, void *keydata)
+static int working_tree_entry_cmp(const void *unused_cmp_data,
+                                 struct working_tree_entry *a,
+                                 struct working_tree_entry *b,
+                                 void *unused_keydata)
 {
        return strcmp(a->path, b->path);
 }
@@ -146,7 +148,9 @@ struct pair_entry {
        const char path[FLEX_ARRAY];
 };
 
-static int pair_cmp(struct pair_entry *a, struct pair_entry *b, void *keydata)
+static int pair_cmp(const void *unused_cmp_data,
+                   struct pair_entry *a, struct pair_entry *b,
+                   void *unused_keydata)
 {
        return strcmp(a->path, b->path);
 }
@@ -174,7 +178,9 @@ struct path_entry {
        char path[FLEX_ARRAY];
 };
 
-static int path_entry_cmp(struct path_entry *a, struct path_entry *b, void *key)
+static int path_entry_cmp(const void *unused_cmp_data,
+                         struct path_entry *a, struct path_entry *b,
+                         void *key)
 {
        return strcmp(a->path, key ? key : b->path);
 }
@@ -367,9 +373,9 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
        wtdir_len = wtdir.len;
 
        hashmap_init(&working_tree_dups,
-                    (hashmap_cmp_fn)working_tree_entry_cmp, 0);
-       hashmap_init(&submodules, (hashmap_cmp_fn)pair_cmp, 0);
-       hashmap_init(&symlinks2, (hashmap_cmp_fn)pair_cmp, 0);
+                    (hashmap_cmp_fn)working_tree_entry_cmp, NULL, 0);
+       hashmap_init(&submodules, (hashmap_cmp_fn)pair_cmp, NULL, 0);
+       hashmap_init(&symlinks2, (hashmap_cmp_fn)pair_cmp, NULL, 0);
 
        child.no_stdin = 1;
        child.git_cmd = 1;
@@ -580,9 +586,9 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
         * files through the symlink.
         */
        hashmap_init(&wt_modified, (hashmap_cmp_fn)path_entry_cmp,
-                    wtindex.cache_nr);
+                    NULL, wtindex.cache_nr);
        hashmap_init(&tmp_modified, (hashmap_cmp_fn)path_entry_cmp,
-                    wtindex.cache_nr);
+                    NULL, wtindex.cache_nr);
 
        for (i = 0; i < wtindex.cache_nr; i++) {
                struct hashmap_entry dummy;
index 12d501bfde3aac09c411169f99ff28ad35593a3b..d412c0a8f354659acade8ea6271f5c60826a0b3f 100644 (file)
@@ -93,8 +93,9 @@ struct anonymized_entry {
        size_t anon_len;
 };
 
-static int anonymized_entry_cmp(const void *va, const void *vb,
-                               const void *data)
+static int anonymized_entry_cmp(const void *unused_cmp_data,
+                               const void *va, const void *vb,
+                               const void *unused_keydata)
 {
        const struct anonymized_entry *a = va, *b = vb;
        return a->orig_len != b->orig_len ||
@@ -113,7 +114,7 @@ static const void *anonymize_mem(struct hashmap *map,
        struct anonymized_entry key, *ret;
 
        if (!map->cmpfn)
-               hashmap_init(map, anonymized_entry_cmp, 0);
+               hashmap_init(map, anonymized_entry_cmp, NULL, 0);
 
        hashmap_entry_init(&key, memhash(orig, *len));
        key.orig = orig;
index 1cd40a5fe6802db723de0d0c78b7d316735e80b3..4a31e31ac30f8552e5116f319fecb8cf76182938 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1753,15 +1753,18 @@ static int configset_add_value(struct config_set *cs, const char *key, const cha
        return 0;
 }
 
-static int config_set_element_cmp(const struct config_set_element *e1,
-                                const struct config_set_element *e2, const void *unused)
+static int config_set_element_cmp(const void *unused_cmp_data,
+                                 const struct config_set_element *e1,
+                                 const struct config_set_element *e2,
+                                 const void *unused_keydata)
 {
        return strcmp(e1->key, e2->key);
 }
 
 void git_configset_init(struct config_set *cs)
 {
-       hashmap_init(&cs->config_hash, (hashmap_cmp_fn)config_set_element_cmp, 0);
+       hashmap_init(&cs->config_hash, (hashmap_cmp_fn)config_set_element_cmp,
+                    NULL, 0);
        cs->hash_initialized = 1;
        cs->list.nr = 0;
        cs->list.alloc = 0;
index 7d2a519dafe5dcf892df10c51e1bfb83bc8a2091..deaf0ba7b30ffa4e0003649985ef1594ee2ac049 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -583,7 +583,8 @@ static int apply_multi_file_filter(const char *path, const char *src, size_t len
 
        if (!subprocess_map_initialized) {
                subprocess_map_initialized = 1;
-               hashmap_init(&subprocess_map, (hashmap_cmp_fn) cmd2process_cmp, 0);
+               hashmap_init(&subprocess_map, (hashmap_cmp_fn) cmd2process_cmp,
+                            NULL, 0);
                entry = NULL;
        } else {
                entry = (struct cmd2process *)subprocess_find_entry(&subprocess_map, cmd);
index 1e4678b7d7cb56ee52f160b55924ddeb863e2872..786f3894984b5652482f313aa489200dd7ff9355 100644 (file)
@@ -341,7 +341,7 @@ static int find_exact_renames(struct diff_options *options)
        /* Add all sources to the hash table in reverse order, because
         * later on they will be retrieved in LIFO order.
         */
-       hashmap_init(&file_table, NULL, rename_src_nr);
+       hashmap_init(&file_table, NULL, NULL, rename_src_nr);
        for (i = rename_src_nr-1; i >= 0; i--)
                insert_file_table(&file_table, i, rename_src[i].p->one);
 
index 7d1044eb5de0faf69a151ca16c1a21500d9d8a10..9b6a12859be67a09685f13310f9769df260d558d 100644 (file)
--- a/hashmap.c
+++ b/hashmap.c
@@ -95,7 +95,9 @@ static inline int entry_equals(const struct hashmap *map,
                const struct hashmap_entry *e1, const struct hashmap_entry *e2,
                const void *keydata)
 {
-       return (e1 == e2) || (e1->hash == e2->hash && !map->cmpfn(e1, e2, keydata));
+       return (e1 == e2) ||
+              (e1->hash == e2->hash &&
+               !map->cmpfn(map->cmpfn_data, e1, e2, keydata));
 }
 
 static inline unsigned int bucket(const struct hashmap *map,
@@ -140,19 +142,23 @@ static inline struct hashmap_entry **find_entry_ptr(const struct hashmap *map,
        return e;
 }
 
-static int always_equal(const void *unused1, const void *unused2, const void *unused3)
+static int always_equal(const void *unused_cmp_data,
+                       const void *unused1,
+                       const void *unused2,
+                       const void *unused_keydata)
 {
        return 0;
 }
 
 void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function,
-               size_t initial_size)
+               const void *cmpfn_data, size_t initial_size)
 {
        unsigned int size = HASHMAP_INITIAL_SIZE;
 
        memset(map, 0, sizeof(*map));
 
        map->cmpfn = equals_function ? equals_function : always_equal;
+       map->cmpfn_data = cmpfn_data;
 
        /* calculate initial table size and allocate the table */
        initial_size = (unsigned int) ((uint64_t) initial_size * 100
@@ -260,7 +266,8 @@ struct pool_entry {
        unsigned char data[FLEX_ARRAY];
 };
 
-static int pool_entry_cmp(const struct pool_entry *e1,
+static int pool_entry_cmp(const void *unused_cmp_data,
+                         const struct pool_entry *e1,
                          const struct pool_entry *e2,
                          const unsigned char *keydata)
 {
@@ -275,7 +282,7 @@ const void *memintern(const void *data, size_t len)
 
        /* initialize string pool hashmap */
        if (!map.tablesize)
-               hashmap_init(&map, (hashmap_cmp_fn) pool_entry_cmp, 0);
+               hashmap_init(&map, (hashmap_cmp_fn) pool_entry_cmp, NULL, 0);
 
        /* lookup interned string in pool */
        hashmap_entry_init(&key, memhash(data, len));
index de6022a3a916605d8e3330b23259110dd3522c7d..aaf09e047e3f7a6907718392ca4f303c04d9c74a 100644 (file)
--- a/hashmap.h
+++ b/hashmap.h
@@ -32,12 +32,14 @@ struct hashmap_entry {
        unsigned int hash;
 };
 
-typedef int (*hashmap_cmp_fn)(const void *entry, const void *entry_or_key,
-               const void *keydata);
+typedef int (*hashmap_cmp_fn)(const void *hashmap_cmp_fn_data,
+                             const void *entry, const void *entry_or_key,
+                             const void *keydata);
 
 struct hashmap {
        struct hashmap_entry **table;
        hashmap_cmp_fn cmpfn;
+       const void *cmpfn_data;
        unsigned int size, tablesize, grow_at, shrink_at;
        unsigned disallow_rehash : 1;
 };
@@ -50,8 +52,10 @@ struct hashmap_iter {
 
 /* hashmap functions */
 
-extern void hashmap_init(struct hashmap *map, hashmap_cmp_fn equals_function,
-               size_t initial_size);
+extern void hashmap_init(struct hashmap *map,
+                        hashmap_cmp_fn equals_function,
+                        const void *equals_function_data,
+                        size_t initial_size);
 extern void hashmap_free(struct hashmap *map, int free_entries);
 
 /* hashmap_entry functions */
index 39309efb7f9e21eb7a039b6b17cdb0d9f1859820..0e10f3eab804cdc08d3a2f97021e8b18edcb552a 100644 (file)
@@ -16,8 +16,10 @@ struct dir_entry {
        char name[FLEX_ARRAY];
 };
 
-static int dir_entry_cmp(const struct dir_entry *e1,
-               const struct dir_entry *e2, const char *name)
+static int dir_entry_cmp(const void *unused_cmp_data,
+                        const struct dir_entry *e1,
+                        const struct dir_entry *e2,
+                        const char *name)
 {
        return e1->namelen != e2->namelen || strncasecmp(e1->name,
                        name ? name : e2->name, e1->namelen);
@@ -107,8 +109,10 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
                add_dir_entry(istate, ce);
 }
 
-static int cache_entry_cmp(const struct cache_entry *ce1,
-               const struct cache_entry *ce2, const void *remove)
+static int cache_entry_cmp(const void *unused_cmp_data,
+                          const struct cache_entry *ce1,
+                          const struct cache_entry *ce2,
+                          const void *remove)
 {
        /*
         * For remove_name_hash, find the exact entry (pointer equality); for
@@ -571,9 +575,9 @@ static void lazy_init_name_hash(struct index_state *istate)
        if (istate->name_hash_initialized)
                return;
        hashmap_init(&istate->name_hash, (hashmap_cmp_fn) cache_entry_cmp,
-                       istate->cache_nr);
+                       NULL, istate->cache_nr);
        hashmap_init(&istate->dir_hash, (hashmap_cmp_fn) dir_entry_cmp,
-                       istate->cache_nr);
+                       NULL, istate->cache_nr);
 
        if (lookup_lazy_params(istate)) {
                hashmap_disallow_rehash(&istate->dir_hash, 1);
index ac169f05d3ab1bde7391f15ae58743d6ceafbad5..a6a08ba52abdcda75b0bd5cc28349cd3c4be871c 100644 (file)
--- a/oidset.c
+++ b/oidset.c
@@ -6,7 +6,8 @@ struct oidset_entry {
        struct object_id oid;
 };
 
-static int oidset_hashcmp(const void *va, const void *vb,
+static int oidset_hashcmp(const void *unused_cmp_data,
+                         const void *va, const void *vb,
                          const void *vkey)
 {
        const struct oidset_entry *a = va, *b = vb;
@@ -30,7 +31,7 @@ int oidset_insert(struct oidset *set, const struct object_id *oid)
        struct oidset_entry *entry;
 
        if (!set->map.cmpfn)
-               hashmap_init(&set->map, oidset_hashcmp, 0);
+               hashmap_init(&set->map, oidset_hashcmp, NULL, 0);
 
        if (oidset_contains(set, oid))
                return 1;
index 9c0ab9e67a80b54f87d9b9d52fa08de7167aec4a..815c1158118129f6b5332d6e67a05688d62490e3 100644 (file)
@@ -35,7 +35,8 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
  * the side of safety.  The actual value being negative does not have
  * any significance; only that it is non-zero matters.
  */
-static int patch_id_cmp(struct patch_id *a,
+static int patch_id_cmp(const void *unused_cmp_data,
+                       struct patch_id *a,
                        struct patch_id *b,
                        struct diff_options *opt)
 {
@@ -57,7 +58,8 @@ int init_patch_ids(struct patch_ids *ids)
        ids->diffopts.detect_rename = 0;
        DIFF_OPT_SET(&ids->diffopts, RECURSIVE);
        diff_setup_done(&ids->diffopts);
-       hashmap_init(&ids->patches, (hashmap_cmp_fn)patch_id_cmp, 256);
+       hashmap_init(&ids->patches, (hashmap_cmp_fn)patch_id_cmp,
+                    NULL, 256);
        return 0;
 }
 
diff --git a/refs.c b/refs.c
index 88658ba76960401e4ab246b597d1212f5b435de1..eef1a7b67de48d1c929921549889112fe1f5d934 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1525,7 +1525,8 @@ struct ref_store_hash_entry
        char name[FLEX_ARRAY];
 };
 
-static int ref_store_hash_cmp(const void *entry, const void *entry_or_key,
+static int ref_store_hash_cmp(const void *unused_cmp_data,
+                             const void *entry, const void *entry_or_key,
                              const void *keydata)
 {
        const struct ref_store_hash_entry *e1 = entry, *e2 = entry_or_key;
@@ -1608,7 +1609,7 @@ static void register_ref_store_map(struct hashmap *map,
                                   const char *name)
 {
        if (!map->tablesize)
-               hashmap_init(map, ref_store_hash_cmp, 0);
+               hashmap_init(map, ref_store_hash_cmp, NULL, 0);
 
        if (hashmap_put(map, alloc_ref_store_hash_entry(name, refs)))
                die("BUG: %s ref_store '%s' initialized twice", type, name);
index d87482573d38b057257c08024fbe6b4339661481..60d004392109f1e39f0bf34578e195cdf3af1639 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -133,7 +133,10 @@ struct remotes_hash_key {
        int len;
 };
 
-static int remotes_hash_cmp(const struct remote *a, const struct remote *b, const struct remotes_hash_key *key)
+static int remotes_hash_cmp(const void *unused_cmp_data,
+                           const struct remote *a,
+                           const struct remote *b,
+                           const struct remotes_hash_key *key)
 {
        if (key)
                return strncmp(a->name, key->str, key->len) || a->name[key->len];
@@ -144,7 +147,7 @@ static int remotes_hash_cmp(const struct remote *a, const struct remote *b, cons
 static inline void init_remotes_hash(void)
 {
        if (!remotes_hash.cmpfn)
-               hashmap_init(&remotes_hash, (hashmap_cmp_fn)remotes_hash_cmp, 0);
+               hashmap_init(&remotes_hash, (hashmap_cmp_fn)remotes_hash_cmp, NULL, 0);
 }
 
 static struct remote *make_remote(const char *name, int len)
index fb1fd809dcbda2ed91c7d9337584a709a248971b..8c523a5b74542b141154372ae07495c35d2abae1 100644 (file)
@@ -2389,7 +2389,8 @@ static int delta_base_cache_key_eq(const struct delta_base_cache_key *a,
        return a->p == b->p && a->base_offset == b->base_offset;
 }
 
-static int delta_base_cache_hash_cmp(const void *va, const void *vb,
+static int delta_base_cache_hash_cmp(const void *unused_cmp_data,
+                                    const void *va, const void *vb,
                                     const void *vkey)
 {
        const struct delta_base_cache_entry *a = va, *b = vb;
@@ -2472,7 +2473,7 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
        list_add_tail(&ent->lru, &delta_base_cache_lru);
 
        if (!delta_base_cache.cmpfn)
-               hashmap_init(&delta_base_cache, delta_base_cache_hash_cmp, 0);
+               hashmap_init(&delta_base_cache, delta_base_cache_hash_cmp, NULL, 0);
        hashmap_entry_init(ent, pack_entry_hash(p, base_offset));
        hashmap_add(&delta_base_cache, ent);
 }
index 92f8aea70aa0bc7654b89bebc3e72b197953e84a..a3cfab1a9d1feb1fea3fbc9bb9dbe04a89b9c874 100644 (file)
@@ -5,9 +5,10 @@
 #include "sigchain.h"
 #include "pkt-line.h"
 
-int cmd2process_cmp(const struct subprocess_entry *e1,
-                          const struct subprocess_entry *e2,
-                          const void *unused)
+int cmd2process_cmp(const void *unused_cmp_data,
+                   const struct subprocess_entry *e1,
+                   const struct subprocess_entry *e2,
+                   const void *unused_keydata)
 {
        return strcmp(e1->cmd, e2->cmd);
 }
index d9a45cd359a780d77d2dc01bd8a315d49a6a994f..96a2cca360c5660fb8e72c684dc4c25e96ba0546 100644 (file)
@@ -20,8 +20,10 @@ struct subprocess_entry {
 
 /* subprocess functions */
 
-int cmd2process_cmp(const struct subprocess_entry *e1,
-       const struct subprocess_entry *e2, const void *unused);
+extern int cmd2process_cmp(const void *unused_cmp_data,
+                          const struct subprocess_entry *e1,
+                          const struct subprocess_entry *e2,
+                          const void *unused_keydata);
 
 typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
 int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
index d8f8d5ea3277d4dcfc8119e726e2f78c9aa881c9..0e1126183dbb75d3ebbf391004b2fe9f5708bd76 100644 (file)
@@ -34,17 +34,19 @@ enum lookup_type {
 static struct submodule_cache the_submodule_cache;
 static int is_cache_init;
 
-static int config_path_cmp(const struct submodule_entry *a,
+static int config_path_cmp(const void *unused_cmp_data,
+                          const struct submodule_entry *a,
                           const struct submodule_entry *b,
-                          const void *unused)
+                          const void *unused_keydata)
 {
        return strcmp(a->config->path, b->config->path) ||
               hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
 }
 
-static int config_name_cmp(const struct submodule_entry *a,
+static int config_name_cmp(const void *unused_cmp_data,
+                          const struct submodule_entry *a,
                           const struct submodule_entry *b,
-                          const void *unused)
+                          const void *unused_keydata)
 {
        return strcmp(a->config->name, b->config->name) ||
               hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
@@ -52,8 +54,8 @@ static int config_name_cmp(const struct submodule_entry *a,
 
 static void cache_init(struct submodule_cache *cache)
 {
-       hashmap_init(&cache->for_path, (hashmap_cmp_fn) config_path_cmp, 0);
-       hashmap_init(&cache->for_name, (hashmap_cmp_fn) config_name_cmp, 0);
+       hashmap_init(&cache->for_path, (hashmap_cmp_fn) config_path_cmp, NULL, 0);
+       hashmap_init(&cache->for_name, (hashmap_cmp_fn) config_name_cmp, NULL, 0);
 }
 
 static void free_one_config(struct submodule_entry *entry)
index 7aa9440e274fb443a30b3f61a241f4fea1601f10..095d7395f3c25d042c60095e8c56d8a22a9a0ba6 100644 (file)
@@ -13,14 +13,18 @@ static const char *get_value(const struct test_entry *e)
        return e->key + strlen(e->key) + 1;
 }
 
-static int test_entry_cmp(const struct test_entry *e1,
-               const struct test_entry *e2, const char* key)
+static int test_entry_cmp(const void *unused_cmp_data,
+                         const struct test_entry *e1,
+                         const struct test_entry *e2,
+                         const char* key)
 {
        return strcmp(e1->key, key ? key : e2->key);
 }
 
-static int test_entry_cmp_icase(const struct test_entry *e1,
-               const struct test_entry *e2, const char* key)
+static int test_entry_cmp_icase(const void *unused_cmp_data,
+                               const struct test_entry *e1,
+                               const struct test_entry *e2,
+                               const char* key)
 {
        return strcasecmp(e1->key, key ? key : e2->key);
 }
@@ -92,7 +96,8 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
        if (method & TEST_ADD) {
                /* test adding to the map */
                for (j = 0; j < rounds; j++) {
-                       hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, 0);
+                       hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp,
+                                    NULL, 0);
 
                        /* add entries */
                        for (i = 0; i < TEST_SIZE; i++) {
@@ -104,7 +109,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
                }
        } else {
                /* test map lookups */
-               hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, 0);
+               hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, NULL, 0);
 
                /* fill the map (sparsely if specified) */
                j = (method & TEST_SPARSE) ? TEST_SIZE / 10 : TEST_SIZE;
@@ -147,7 +152,7 @@ int cmd_main(int argc, const char **argv)
        /* init hash map */
        icase = argc > 1 && !strcmp("ignorecase", argv[1]);
        hashmap_init(&map, (hashmap_cmp_fn) (icase ? test_entry_cmp_icase
-                       : test_entry_cmp), 0);
+                       : test_entry_cmp), NULL, 0);
 
        /* process commands from stdin */
        while (fgets(line, sizeof(line), stdin)) {