summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-11-02 18:55:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-02 20:15:50 (GMT)
commit6da1a258142ac2422c8c57c54b92eaed3c86226e (patch)
tree480a35cb1c8754d02f21233d2efd8e5d28ff24d0 /builtin
parent33f20d82177871225e17d9dd44169a52a36c9f1d (diff)
downloadgit-6da1a258142ac2422c8c57c54b92eaed3c86226e.zip
git-6da1a258142ac2422c8c57c54b92eaed3c86226e.tar.gz
git-6da1a258142ac2422c8c57c54b92eaed3c86226e.tar.bz2
hashmap: provide deallocation function names
hashmap_free(), hashmap_free_entries(), and hashmap_free_() have existed for a while, but aren't necessarily the clearest names, especially with hashmap_partial_clear() being added to the mix and lazy-initialization now being supported. Peff suggested we adopt the following names[1]: - hashmap_clear() - remove all entries and de-allocate any hashmap-specific data, but be ready for reuse - hashmap_clear_and_free() - ditto, but free the entries themselves - hashmap_partial_clear() - remove all entries but don't deallocate table - hashmap_partial_clear_and_free() - ditto, but free the entries This patch provides the new names and converts all existing callers over to the new naming scheme. [1] https://lore.kernel.org/git/20201030125059.GA3277724@coredump.intra.peff.net/ Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fetch.c6
-rw-r--r--builtin/shortlog.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f9c3c49..ecf8537 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -393,7 +393,7 @@ static void find_non_local_tags(const struct ref *refs,
item = refname_hash_add(&remote_refs, ref->name, &ref->old_oid);
string_list_insert(&remote_refs_list, ref->name);
}
- hashmap_free_entries(&existing_refs, struct refname_hash_entry, ent);
+ hashmap_clear_and_free(&existing_refs, struct refname_hash_entry, ent);
/*
* We may have a final lightweight tag that needs to be
@@ -428,7 +428,7 @@ static void find_non_local_tags(const struct ref *refs,
**tail = rm;
*tail = &rm->next;
}
- hashmap_free_entries(&remote_refs, struct refname_hash_entry, ent);
+ hashmap_clear_and_free(&remote_refs, struct refname_hash_entry, ent);
string_list_clear(&remote_refs_list, 0);
oidset_clear(&fetch_oids);
}
@@ -573,7 +573,7 @@ static struct ref *get_ref_map(struct remote *remote,
}
}
if (existing_refs_populated)
- hashmap_free_entries(&existing_refs, struct refname_hash_entry, ent);
+ hashmap_clear_and_free(&existing_refs, struct refname_hash_entry, ent);
return ref_map;
}
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 0a5c496..83f0a73 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -220,7 +220,7 @@ static void strset_clear(struct strset *ss)
{
if (!ss->map.table)
return;
- hashmap_free_entries(&ss->map, struct strset_item, ent);
+ hashmap_clear_and_free(&ss->map, struct strset_item, ent);
}
static void insert_records_from_trailers(struct shortlog *log,