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>
This commit is contained in:

committed by
Junio C Hamano

parent
33f20d8217
commit
6da1a25814
@ -5058,7 +5058,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
|
||||
|
||||
oidmap_free(&commit2todo, 1);
|
||||
oidmap_free(&state.commit2label, 1);
|
||||
hashmap_free_entries(&state.labels, struct labels_entry, entry);
|
||||
hashmap_clear_and_free(&state.labels, struct labels_entry, entry);
|
||||
strbuf_release(&state.buf);
|
||||
|
||||
return 0;
|
||||
@ -5577,7 +5577,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
|
||||
for (i = 0; i < todo_list->nr; i++)
|
||||
free(subjects[i]);
|
||||
free(subjects);
|
||||
hashmap_free_entries(&subject2item, struct subject2item_entry, entry);
|
||||
hashmap_clear_and_free(&subject2item, struct subject2item_entry, entry);
|
||||
|
||||
clear_commit_todo_item(&commit_todo);
|
||||
|
||||
|
Reference in New Issue
Block a user