Merge branch 'sb/hashmap-cleanup'
Many uses of comparision callback function the hashmap API uses cast the callback function type when registering it to hashmap_init(), which defeats the compile time type checking when the callback interface changes (e.g. gaining more parameters). The callback implementations have been updated to take "void *" pointers and cast them to the type they expect instead. * sb/hashmap-cleanup: t/helper/test-hashmap: use custom data instead of duplicate cmp functions name-hash.c: drop hashmap_cmp_fn cast submodule-config.c: drop hashmap_cmp_fn cast remote.c: drop hashmap_cmp_fn cast patch-ids.c: drop hashmap_cmp_fn cast convert/sub-process: drop cast to hashmap_cmp_fn config.c: drop hashmap_cmp_fn cast builtin/describe: drop hashmap_cmp_fn cast builtin/difftool.c: drop hashmap_cmp_fn cast attr.c: drop hashmap_cmp_fn cast
This commit is contained in:
@ -35,19 +35,25 @@ enum lookup_type {
|
||||
};
|
||||
|
||||
static int config_path_cmp(const void *unused_cmp_data,
|
||||
const struct submodule_entry *a,
|
||||
const struct submodule_entry *b,
|
||||
const void *entry,
|
||||
const void *entry_or_key,
|
||||
const void *unused_keydata)
|
||||
{
|
||||
const struct submodule_entry *a = entry;
|
||||
const struct submodule_entry *b = entry_or_key;
|
||||
|
||||
return strcmp(a->config->path, b->config->path) ||
|
||||
hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
|
||||
}
|
||||
|
||||
static int config_name_cmp(const void *unused_cmp_data,
|
||||
const struct submodule_entry *a,
|
||||
const struct submodule_entry *b,
|
||||
const void *entry,
|
||||
const void *entry_or_key,
|
||||
const void *unused_keydata)
|
||||
{
|
||||
const struct submodule_entry *a = entry;
|
||||
const struct submodule_entry *b = entry_or_key;
|
||||
|
||||
return strcmp(a->config->name, b->config->name) ||
|
||||
hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
|
||||
}
|
||||
@ -59,8 +65,8 @@ static struct submodule_cache *submodule_cache_alloc(void)
|
||||
|
||||
static void submodule_cache_init(struct submodule_cache *cache)
|
||||
{
|
||||
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);
|
||||
hashmap_init(&cache->for_path, config_path_cmp, NULL, 0);
|
||||
hashmap_init(&cache->for_name, config_name_cmp, NULL, 0);
|
||||
cache->initialized = 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user