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
@ -2651,7 +2651,7 @@ static struct string_list *get_renames(struct merge_options *opt,
|
||||
free(e->target_file);
|
||||
string_list_clear(&e->source_files, 0);
|
||||
}
|
||||
hashmap_free_entries(&collisions, struct collision_entry, ent);
|
||||
hashmap_clear_and_free(&collisions, struct collision_entry, ent);
|
||||
return renames;
|
||||
}
|
||||
|
||||
@ -2870,7 +2870,7 @@ static void initial_cleanup_rename(struct diff_queue_struct *pairs,
|
||||
strbuf_release(&e->new_dir);
|
||||
/* possible_new_dirs already cleared in get_directory_renames */
|
||||
}
|
||||
hashmap_free_entries(dir_renames, struct dir_rename_entry, ent);
|
||||
hashmap_clear_and_free(dir_renames, struct dir_rename_entry, ent);
|
||||
free(dir_renames);
|
||||
|
||||
free(pairs->queue);
|
||||
@ -3497,7 +3497,7 @@ static int merge_trees_internal(struct merge_options *opt,
|
||||
string_list_clear(entries, 1);
|
||||
free(entries);
|
||||
|
||||
hashmap_free_entries(&opt->priv->current_file_dir_set,
|
||||
hashmap_clear_and_free(&opt->priv->current_file_dir_set,
|
||||
struct path_hashmap_entry, e);
|
||||
|
||||
if (clean < 0) {
|
||||
|
||||
Reference in New Issue
Block a user