Re: [PATCH v2 3/5] list-objects-filter: use oidmap_clear_with_free() for cleanup
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 2, 2026, 22:30 UTC
- Message-ID
- <xmqq7brtyids.fsf@gitster.g>
- In-Reply-To
- <20260302200018.75731-4-kuforiji98@gmail.com>
Seyi Kuforiji <kuforiji98@gmail.com> writes:
Show 14 quoted lines
> 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].
Show 8 quoted lines
> @@ -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);
> }