Subject: Re: [PATCH v2 3/5] list-objects-filter: use oidmap_clear_with_free() for cleanup

From: Junio C Hamano <[email-masked]>
Date: Mon, 02 Mar 2026 14:30:07 -0800

Seyi Kuforiji <[email-masked]> writes:

> diff --git a/list-objects-filter.c b/list-objects-filter.c
> index 78316e7f90..0038bfaac5 100644
> --- a/list-objects-filter.c
> +++ b/list-objects-filter.c
> @@ -143,6 +143,13 @@ struct seen_map_entry {
>  	size_t depth;
>  };
>  
> +static void free_seen_map_entry(void *e)
> +{
> +	struct seen_map_entry *entry =
> +		container_of(e, struct seen_map_entry, base);
> +	free(entry);
> +}

As there is *no* extra resources held in seen_map_entry other than
the shell itself, this step alone does not make the code any clearer
to follow.  But if we are going to add new members to the structure
in the future, the story will change and we'll leap the same benefit
as we saw in [PATCH v2 2/5].

> @@ -244,7 +251,7 @@ static void filter_trees_free(void *filter_data) {
>  	struct filter_trees_depth_data *d = filter_data;
>  	if (!d)
>  		return;
> -	oidmap_clear(&d->seen_at_depth, 1);
> +	oidmap_clear_with_free(&d->seen_at_depth, free_seen_map_entry);
>  	free(d);
>  }