]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hashmap_remove takes "const struct hashmap_entry *"
authorEric Wong <e@80x24.org>
Sun, 6 Oct 2019 23:30:31 +0000 (23:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Oct 2019 01:20:10 +0000 (10:20 +0900)
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>
blame.c
hashmap.c
hashmap.h
merge-recursive.c
name-hash.c
packfile.c
range-diff.c
sub-process.c
submodule-config.c

diff --git a/blame.c b/blame.c
index 73ffb594030608317b999861f4d872e3ac887331..00f8f3fb0a1ca0f25315c5241e7361a91f45dba5 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -473,7 +473,7 @@ static void fingerprint_subtract(struct fingerprint *a, struct fingerprint *b)
        while ((entry_b = hashmap_iter_next(&iter))) {
                if ((entry_a = hashmap_get(&a->map, &entry_b->entry, NULL))) {
                        if (entry_a->count <= entry_b->count)
-                               hashmap_remove(&a->map, entry_b, NULL);
+                               hashmap_remove(&a->map, &entry_b->entry, NULL);
                        else
                                entry_a->count -= entry_b->count;
                }
index 092236c09aac0155b7b317afe4d2c47e9628cf37..bdf33e0381a91cbe7d720faadb8a9bb7abaf22fb 100644 (file)
--- a/hashmap.c
+++ b/hashmap.c
@@ -218,7 +218,8 @@ void hashmap_add(struct hashmap *map, struct hashmap_entry *entry)
        }
 }
 
-void *hashmap_remove(struct hashmap *map, const void *key, const void *keydata)
+void *hashmap_remove(struct hashmap *map, const struct hashmap_entry *key,
+               const void *keydata)
 {
        struct hashmap_entry *old;
        struct hashmap_entry **e = find_entry_ptr(map, key, keydata);
index ef83f9431d64fd249adc88b5d054a9ea2d9a0953..c4c31b462f95b893fb60bf76d285d37d2ffa80b6 100644 (file)
--- a/hashmap.h
+++ b/hashmap.h
@@ -349,7 +349,7 @@ void *hashmap_put(struct hashmap *map, void *entry);
  *
  * Argument explanation is the same as in `hashmap_get`.
  */
-void *hashmap_remove(struct hashmap *map, const void *key,
+void *hashmap_remove(struct hashmap *map, const struct hashmap_entry *key,
                const void *keydata);
 
 /*
index 2d31a3e279b789b225385c591658222d3521ce0a..f60451d396f203d506096d112b51ec66fd54a675 100644 (file)
@@ -2001,7 +2001,7 @@ static void remove_hashmap_entries(struct hashmap *dir_renames,
 
        for (i = 0; i < items_to_remove->nr; i++) {
                entry = items_to_remove->items[i].util;
-               hashmap_remove(dir_renames, entry, NULL);
+               hashmap_remove(dir_renames, &entry->ent, NULL);
        }
        string_list_clear(items_to_remove, 0);
 }
index 4eaeded7759a69932e64a555dea713773e47252b..44d788f1cedbb0119dc9c91fb942201d17fdc26e 100644 (file)
@@ -95,7 +95,7 @@ static void remove_dir_entry(struct index_state *istate, struct cache_entry *ce)
        struct dir_entry *dir = hash_dir_entry(istate, ce, ce_namelen(ce));
        while (dir && !(--dir->nr)) {
                struct dir_entry *parent = dir->parent;
-               hashmap_remove(&istate->dir_hash, dir, NULL);
+               hashmap_remove(&istate->dir_hash, &dir->ent, NULL);
                free(dir);
                dir = parent;
        }
@@ -625,7 +625,7 @@ void remove_name_hash(struct index_state *istate, struct cache_entry *ce)
        if (!istate->name_hash_initialized || !(ce->ce_flags & CE_HASHED))
                return;
        ce->ce_flags &= ~CE_HASHED;
-       hashmap_remove(&istate->name_hash, ce, ce);
+       hashmap_remove(&istate->name_hash, &ce->ent, ce);
 
        if (ignore_case)
                remove_dir_entry(istate, ce);
index f7402c470b6b8fb3abd1ca9d3fff0386802ec3e0..3edd648de0855927df0982ac43d32d3103d6584b 100644 (file)
@@ -1423,7 +1423,7 @@ static int in_delta_base_cache(struct packed_git *p, off_t base_offset)
  */
 static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)
 {
-       hashmap_remove(&delta_base_cache, ent, &ent->key);
+       hashmap_remove(&delta_base_cache, &ent->ent, &ent->key);
        list_del(&ent->lru);
        delta_base_cached -= ent->size;
        free(ent);
index 96f955d84d0c450dfc989a485f9fcf850d21f398..c51cfd5556999efc1a515f89d80b3575b03e3e7b 100644 (file)
@@ -229,7 +229,7 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)
                util->patch = b->items[i].string;
                util->diff = util->patch + util->diff_offset;
                hashmap_entry_init(&util->e, strhash(util->diff));
-               other = hashmap_remove(&map, util, NULL);
+               other = hashmap_remove(&map, &util->e, NULL);
                if (other) {
                        if (other->matching >= 0)
                                BUG("already assigned!");
index debd86bb689f4b68d86d9024dd27e8a315d0c09b..99fccef59291d8622f7d0d2bac28e8696b75015d 100644 (file)
@@ -58,7 +58,7 @@ void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry)
        kill(entry->process.pid, SIGTERM);
        finish_command(&entry->process);
 
-       hashmap_remove(hashmap, entry, NULL);
+       hashmap_remove(hashmap, &entry->ent, NULL);
 }
 
 static void subprocess_exit_handler(struct child_process *process)
index 58d585cd7d9cd5482f4134a08e0e146c4d4ec19b..7486745a6a091353d94b5f219648b7727395cbe3 100644 (file)
@@ -137,7 +137,7 @@ static void cache_remove_path(struct submodule_cache *cache,
        struct submodule_entry *removed;
        hashmap_entry_init(&e.ent, hash);
        e.config = submodule;
-       removed = hashmap_remove(&cache->for_path, &e, NULL);
+       removed = hashmap_remove(&cache->for_path, &e.ent, NULL);
        free(removed);
 }