]> git.ipfire.org Git - thirdparty/git.git/commitdiff
oidmap: rename oidmap_free() to oidmap_clear()
authorJeff King <peff@peff.net>
Mon, 12 May 2025 18:50:28 +0000 (14:50 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 May 2025 20:06:26 +0000 (13:06 -0700)
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>
builtin/rev-list.c
list-objects-filter.c
object-store.c
oidmap.c
oidmap.h
sequencer.c
t/unit-tests/u-oidmap.c

index c4cd4ed5c81570f3ae7ec543f7d35faf62e372c5..0984b607bf052d7d248083f358f2c56f53c16c55 100644 (file)
@@ -924,7 +924,7 @@ int cmd_rev_list(int argc,
                        free((void *)entry->path);
                }
 
-               oidmap_free(&missing_objects, true);
+               oidmap_clear(&missing_objects, true);
        }
 
        stop_progress(&progress);
index 7765761b3c6e2a82d42209e52fe4f398d0cb10ab..78b397bc194849b4c32ec48bc7af1aadb0a5cfb5 100644 (file)
@@ -244,7 +244,7 @@ static void filter_trees_free(void *filter_data) {
        struct filter_trees_depth_data *d = filter_data;
        if (!d)
                return;
-       oidmap_free(&d->seen_at_depth, 1);
+       oidmap_clear(&d->seen_at_depth, 1);
        free(d);
 }
 
index 6ab50d25d3eb4f45af597cfb3aa896bdc91455c6..bc24e8082904d520cd23489f7e3968d04c0bfec9 100644 (file)
@@ -1017,7 +1017,7 @@ void raw_object_store_clear(struct raw_object_store *o)
 {
        FREE_AND_NULL(o->alternate_db);
 
-       oidmap_free(o->replace_map, 1);
+       oidmap_clear(o->replace_map, 1);
        FREE_AND_NULL(o->replace_map);
        pthread_mutex_destroy(&o->replace_mutex);
 
index 8b1bc4dec9496e3b49ba064cc0936925625e5c79..508d6c7dec17a71e16afc63e7050babcdc7c03a6 100644 (file)
--- a/oidmap.c
+++ b/oidmap.c
@@ -22,7 +22,7 @@ void oidmap_init(struct oidmap *map, size_t initial_size)
        hashmap_init(&map->map, oidmap_neq, NULL, initial_size);
 }
 
-void oidmap_free(struct oidmap *map, int free_entries)
+void oidmap_clear(struct oidmap *map, int free_entries)
 {
        if (!map)
                return;
index fad412827af6884f6b3a95742f446949a36a7d1b..603ae1adbcc0587cbcddd654eb87ef143da10fdb 100644 (file)
--- a/oidmap.h
+++ b/oidmap.h
@@ -36,12 +36,13 @@ struct oidmap {
 void oidmap_init(struct oidmap *map, size_t initial_size);
 
 /*
- * Frees an oidmap structure and allocated memory.
+ * Clear an oidmap, freeing any allocated memory. The map is empty and
+ * can be reused without another explicit init.
  *
  * If `free_entries` is true, each oidmap_entry in the map is freed as well
  * using stdlibs free().
  */
-void oidmap_free(struct oidmap *map, int free_entries);
+void oidmap_clear(struct oidmap *map, int free_entries);
 
 /*
  * Returns the oidmap entry for the specified oid, or NULL if not found.
index b5c4043757e948aedaad0782dff947373e2f45ea..7fa24db14303b0c4e79b971c5732f073067a091f 100644 (file)
@@ -6053,8 +6053,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
        oidset_clear(&interesting);
        oidset_clear(&child_seen);
        oidset_clear(&shown);
-       oidmap_free(&commit2todo, 1);
-       oidmap_free(&state.commit2label, 1);
+       oidmap_clear(&commit2todo, 1);
+       oidmap_clear(&state.commit2label, 1);
        hashmap_clear_and_free(&state.labels, struct labels_entry, entry);
        strbuf_release(&state.buf);
 
index dc805b7e3cb424f962901da1f9a6fa5b572ace19..b23af449f6452e5733329c8d3a1274563f42ceea 100644 (file)
@@ -35,7 +35,7 @@ void test_oidmap__initialize(void)
 
 void test_oidmap__cleanup(void)
 {
-       oidmap_free(&map, 1);
+       oidmap_clear(&map, 1);
 }
 
 void test_oidmap__replace(void)