diff options
| author | Eric Wong <e@80x24.org> | 2019-10-06 23:30:39 +0000 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2019-10-07 10:20:11 +0900 |
| commit | 8a973d0bb398d6d83d6c048acecc750d01bd7234 (patch) | |
| tree | c4987af10c66582df750927a060b13995dafd84a /t | |
| parent | 87571c3f71ba41d89eef5202f8589daa26f984ca (diff) | |
| download | git-8a973d0bb398d6d83d6c048acecc750d01bd7234.tar.gz | |
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>
Diffstat (limited to 't')
| -rw-r--r-- | t/helper/test-hashmap.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c index 4ec5e11556..07a93a2aec 100644 --- a/t/helper/test-hashmap.c +++ b/t/helper/test-hashmap.c @@ -189,7 +189,9 @@ int cmd__hashmap(int argc, const char **argv) entry = alloc_test_entry(hash, p1, p2); /* add / replace entry */ - entry = hashmap_put(&map, &entry->ent); + entry = hashmap_put_entry(&map, entry, + struct test_entry, + ent /* member name */); /* print and free replaced entry, if any */ puts(entry ? get_value(entry) : "NULL"); @@ -212,10 +214,13 @@ int cmd__hashmap(int argc, const char **argv) /* setup static key */ struct hashmap_entry key; + struct hashmap_entry *rm; hashmap_entry_init(&key, hash); /* remove entry from hashmap */ - entry = hashmap_remove(&map, &key, p1); + rm = hashmap_remove(&map, &key, p1); + entry = rm ? container_of(rm, struct test_entry, ent) + : NULL; /* print result and free entry*/ puts(entry ? get_value(entry) : "NULL"); |
