builtin/rev-list: migrate missing_objects cleanup to oidmap_clear_with_free()

As part of the conversion away from oidmap_clear(), switch the missing_objects map to use oidmap_clear_with_free(). missing_objects stores struct missing_objects_map_entry instances, which own an xstrdup()'d path string in addition to the container struct itself. Previously, rev-list manually freed entry->path before calling oidmap_clear(&missing_objects, true). Introduce a dedicated free callback and pass it to oidmap_clear_with_free(), consolidating entry teardown into a single place and making cleanup semantics explicit. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Seyi Kufoiji committed Mar 5, 2026 at 11:05 UTC a98ea50288c9fd39b501710635977478fb1f0a05
1 file changed +12 -3
builtin/rev-list.c
+12 -3
@@ -88,9 +88,19 @@ static int arg_print_omitted; /* print objects omitted by filter */
88
89 struct missing_objects_map_entry {
90 struct oidmap_entry entry;
91 - const char *path;
91 + char *path;
92 unsigned type;
93 };
94 +
95 +static void missing_objects_map_entry_free(void *e)
96 +{
97 + struct missing_objects_map_entry *entry =
98 + container_of(e, struct missing_objects_map_entry, entry);
99 +
100 + free(entry->path);
101 + free(entry);
102 +}
103 +
104 static struct oidmap missing_objects;
105 enum missing_action {
106 MA_ERROR = 0, /* fail if any missing objects are encountered */
@@ -935,10 +945,9 @@ int cmd_rev_list(int argc,
945 while ((entry = oidmap_iter_next(&iter))) {
946 print_missing_object(entry, arg_missing_action ==
947 MA_PRINT_INFO);
938 - free((void *)entry->path);
948 }
949
941 - oidmap_clear(&missing_objects, true);
950 + oidmap_clear_with_free(&missing_objects, missing_objects_map_entry_free);
951 }
952
953 stop_progress(&progress);