Skip to content

Commit 6ff1507

Browse files
Seyi007gitster
authored andcommitted
list-objects-filter: use oidmap_clear_with_free() for cleanup
Replace the use of oidmap_clear(&seen_at_depth, 1) in filter_trees_free() with oidmap_clear_with_free(). The seen_at_depth map stores heap-allocated struct seen_map_entry objects. Previously, passing 1 relied on oidmap_clear() internally calling free() on each entry. Convert this to the explicit oidmap_clear_with_free() API and provide a typed free_seen_map_entry() helper to free each container entry. This makes the ownership and cleanup policy explicit and removes reliance on the legacy boolean free_entries parameter. Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent bbf93f9 commit 6ff1507

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

list-objects-filter.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ struct seen_map_entry {
143143
size_t depth;
144144
};
145145

146+
static void free_seen_map_entry(void *e)
147+
{
148+
struct seen_map_entry *entry =
149+
container_of(e, struct seen_map_entry, base);
150+
free(entry);
151+
}
152+
146153
/* Returns 1 if the oid was in the omits set before it was invoked. */
147154
static int filter_trees_update_omits(
148155
struct object *obj,
@@ -244,7 +251,7 @@ static void filter_trees_free(void *filter_data) {
244251
struct filter_trees_depth_data *d = filter_data;
245252
if (!d)
246253
return;
247-
oidmap_clear(&d->seen_at_depth, 1);
254+
oidmap_clear_with_free(&d->seen_at_depth, free_seen_map_entry);
248255
free(d);
249256
}
250257

0 commit comments

Comments
 (0)