hashmap_remove takes "const struct hashmap_entry *"
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>
Eric Wong committed
Oct 6, 2019 at 23:30 UTC
28ee7941280828f9e528bd8c5d0f6515a57e0c44
9 files changed
+11
-10
blame.c
+1
-1
@@ -473,7 +473,7 @@ static void fingerprint_subtract(struct fingerprint *a, struct fingerprint *b)
473
while ((entry_b = hashmap_iter_next(&iter))) {
474
if ((entry_a = hashmap_get(&a->map, &entry_b->entry, NULL))) {
475
if (entry_a->count <= entry_b->count)
476
- hashmap_remove(&a->map, entry_b, NULL);
476
+ hashmap_remove(&a->map, &entry_b->entry, NULL);
477
else
478
entry_a->count -= entry_b->count;
479
}
hashmap.c
+2
-1
@@ -218,7 +218,8 @@ void hashmap_add(struct hashmap *map, struct hashmap_entry *entry)
218
}
219
}
220
221
-void *hashmap_remove(struct hashmap *map, const void *key, const void *keydata)
221
+void *hashmap_remove(struct hashmap *map, const struct hashmap_entry *key,
222
+ const void *keydata)
223
{
224
struct hashmap_entry *old;
225
struct hashmap_entry **e = find_entry_ptr(map, key, keydata);
hashmap.h
+1
-1
@@ -349,7 +349,7 @@ void *hashmap_put(struct hashmap *map, void *entry);
349
*
350
* Argument explanation is the same as in `hashmap_get`.
351
*/
352
-void *hashmap_remove(struct hashmap *map, const void *key,
352
+void *hashmap_remove(struct hashmap *map, const struct hashmap_entry *key,
353
const void *keydata);
354
355
/*
merge-recursive.c
+1
-1
@@ -2001,7 +2001,7 @@ static void remove_hashmap_entries(struct hashmap *dir_renames,
2001
2002
for (i = 0; i < items_to_remove->nr; i++) {
2003
entry = items_to_remove->items[i].util;
2004
- hashmap_remove(dir_renames, entry, NULL);
2004
+ hashmap_remove(dir_renames, &entry->ent, NULL);
2005
}
2006
string_list_clear(items_to_remove, 0);
2007
}
name-hash.c
+2
-2
@@ -95,7 +95,7 @@ static void remove_dir_entry(struct index_state *istate, struct cache_entry *ce)
95
struct dir_entry *dir = hash_dir_entry(istate, ce, ce_namelen(ce));
96
while (dir && !(--dir->nr)) {
97
struct dir_entry *parent = dir->parent;
98
- hashmap_remove(&istate->dir_hash, dir, NULL);
98
+ hashmap_remove(&istate->dir_hash, &dir->ent, NULL);
99
free(dir);
100
dir = parent;
101
}
@@ -625,7 +625,7 @@ void remove_name_hash(struct index_state *istate, struct cache_entry *ce)
625
if (!istate->name_hash_initialized || !(ce->ce_flags & CE_HASHED))
626
return;
627
ce->ce_flags &= ~CE_HASHED;
628
- hashmap_remove(&istate->name_hash, ce, ce);
628
+ hashmap_remove(&istate->name_hash, &ce->ent, ce);
629
630
if (ignore_case)
631
remove_dir_entry(istate, ce);
packfile.c
+1
-1
@@ -1423,7 +1423,7 @@ static int in_delta_base_cache(struct packed_git *p, off_t base_offset)
1423
*/
1424
static void detach_delta_base_cache_entry(struct delta_base_cache_entry *ent)
1425
{
1426
- hashmap_remove(&delta_base_cache, ent, &ent->key);
1426
+ hashmap_remove(&delta_base_cache, &ent->ent, &ent->key);
1427
list_del(&ent->lru);
1428
delta_base_cached -= ent->size;
1429
free(ent);
range-diff.c
+1
-1
@@ -229,7 +229,7 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)
229
util->patch = b->items[i].string;
230
util->diff = util->patch + util->diff_offset;
231
hashmap_entry_init(&util->e, strhash(util->diff));
232
- other = hashmap_remove(&map, util, NULL);
232
+ other = hashmap_remove(&map, &util->e, NULL);
233
if (other) {
234
if (other->matching >= 0)
235
BUG("already assigned!");
sub-process.c
+1
-1
@@ -58,7 +58,7 @@ void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry)
58
kill(entry->process.pid, SIGTERM);
59
finish_command(&entry->process);
60
61
- hashmap_remove(hashmap, entry, NULL);
61
+ hashmap_remove(hashmap, &entry->ent, NULL);
62
}
63
64
static void subprocess_exit_handler(struct child_process *process)
submodule-config.c
+1
-1
@@ -137,7 +137,7 @@ static void cache_remove_path(struct submodule_cache *cache,
137
struct submodule_entry *removed;
138
hashmap_entry_init(&e.ent, hash);
139
e.config = submodule;
140
- removed = hashmap_remove(&cache->for_path, &e, NULL);
140
+ removed = hashmap_remove(&cache->for_path, &e.ent, NULL);
141
free(removed);
142
}
143