hashmap: hashmap_{put,remove} return hashmap_entry *

And add *_entry variants to perform container_of as necessary
to simplify most callers.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Eric Wong
2019-10-06 23:30:39 +00:00
committed by Junio C Hamano
parent 87571c3f71
commit 8a973d0bb3
6 changed files with 32 additions and 11 deletions

View File

@ -229,7 +229,9 @@ 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->e, NULL);
other = hashmap_remove_entry(&map, util, NULL,
struct patch_util,
e /* member name */);
if (other) {
if (other->matching >= 0)
BUG("already assigned!");