OSDN Git Service

Merge branch 'sb/hashmap-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Fri, 11 Aug 2017 20:27:01 +0000 (13:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 11 Aug 2017 20:27:01 +0000 (13:27 -0700)
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

1  2 
builtin/describe.c
config.c
convert.c
remote.c
submodule-config.c

Simple merge
diff --cc config.c
Simple merge
diff --cc convert.c
Simple merge
diff --cc remote.c
Simple merge
@@@ -34,11 -31,17 +34,14 @@@ enum lookup_type 
        lookup_path
  };
  
 -static struct submodule_cache the_submodule_cache;
 -static int is_cache_init;
 -
  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);
  }
@@@ -52,16 -58,10 +58,16 @@@ static int config_name_cmp(const void *
               hashcmp(a->config->gitmodules_sha1, b->config->gitmodules_sha1);
  }
  
 -static void cache_init(struct submodule_cache *cache)
 +static struct submodule_cache *submodule_cache_alloc(void)
 +{
 +      return xcalloc(1, sizeof(struct submodule_cache));
 +}
 +
 +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;
  }
  
  static void free_one_config(struct submodule_entry *entry)