oidmap: rename oidmap_free() to oidmap_clear()

This function does not free the oidmap struct itself; it just drops all items from the map (using hashmap_clear_() internally). It should be called oidmap_clear(), per CodingGuidelines. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 12, 2025 at 14:50 UTC 274464683462d04363d2107822b0f9d2d5a27623
7 files changed +10 -9
builtin/rev-list.c
+1 -1
@@ -924,7 +924,7 @@ int cmd_rev_list(int argc,
924 free((void *)entry->path);
925 }
926
927 - oidmap_free(&missing_objects, true);
927 + oidmap_clear(&missing_objects, true);
928 }
929
930 stop_progress(&progress);
list-objects-filter.c
+1 -1
@@ -244,7 +244,7 @@ static void filter_trees_free(void *filter_data) {
244 struct filter_trees_depth_data *d = filter_data;
245 if (!d)
246 return;
247 - oidmap_free(&d->seen_at_depth, 1);
247 + oidmap_clear(&d->seen_at_depth, 1);
248 free(d);
249 }
250
object-store.c
+1 -1
@@ -1017,7 +1017,7 @@ void raw_object_store_clear(struct raw_object_store *o)
1017 {
1018 FREE_AND_NULL(o->alternate_db);
1019
1020 - oidmap_free(o->replace_map, 1);
1020 + oidmap_clear(o->replace_map, 1);
1021 FREE_AND_NULL(o->replace_map);
1022 pthread_mutex_destroy(&o->replace_mutex);
1023
oidmap.c
+1 -1
@@ -22,7 +22,7 @@ void oidmap_init(struct oidmap *map, size_t initial_size)
22 hashmap_init(&map->map, oidmap_neq, NULL, initial_size);
23 }
24
25 -void oidmap_free(struct oidmap *map, int free_entries)
25 +void oidmap_clear(struct oidmap *map, int free_entries)
26 {
27 if (!map)
28 return;
oidmap.h
+3 -2
@@ -36,12 +36,13 @@ struct oidmap {
36 void oidmap_init(struct oidmap *map, size_t initial_size);
37
38 /*
39 - * Frees an oidmap structure and allocated memory.
39 + * Clear an oidmap, freeing any allocated memory. The map is empty and
40 + * can be reused without another explicit init.
41 *
42 * If `free_entries` is true, each oidmap_entry in the map is freed as well
43 * using stdlibs free().
44 */
44 -void oidmap_free(struct oidmap *map, int free_entries);
45 +void oidmap_clear(struct oidmap *map, int free_entries);
46
47 /*
48 * Returns the oidmap entry for the specified oid, or NULL if not found.
sequencer.c
+2 -2
@@ -6053,8 +6053,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
6053 oidset_clear(&interesting);
6054 oidset_clear(&child_seen);
6055 oidset_clear(&shown);
6056 - oidmap_free(&commit2todo, 1);
6057 - oidmap_free(&state.commit2label, 1);
6056 + oidmap_clear(&commit2todo, 1);
6057 + oidmap_clear(&state.commit2label, 1);
6058 hashmap_clear_and_free(&state.labels, struct labels_entry, entry);
6059 strbuf_release(&state.buf);
6060
t/unit-tests/u-oidmap.c
+1 -1
@@ -35,7 +35,7 @@ void test_oidmap__initialize(void)
35
36 void test_oidmap__cleanup(void)
37 {
38 - oidmap_free(&map, 1);
38 + oidmap_clear(&map, 1);
39 }
40
41 void test_oidmap__replace(void)