Re: [PATCH 04/15] ref-filter: add ref_filter_clear()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 8, 2023, 22:29 UTC
- Message-ID
- <xmqqr0rq4ful.fsf@gitster.g>
- In-Reply-To
- <c804ba3620476713bd0535a315876378149ad7dd.1683581621.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 10 quoted lines
> From: Jeff King <peff@peff.net> > > We did not bother to clean up at all in branch/tag, and for-each-ref > only hit a few elements. So this is probably cleaning up leaks, but I > didn't check yet. > > Note that the reachable_from and unreachable_from lists should be > cleaned as they are used. So this is just covering any case where we > might bail before running the reachability check. > ---
Not signed-off?
Show 9 quoted lines
> +void ref_filter_clear(struct ref_filter *filter)
> +{
> + oid_array_clear(&filter->points_at);
> + free_commit_list(filter->with_commit);
> + free_commit_list(filter->no_commit);
> + free_commit_list(filter->reachable_from);
> + free_commit_list(filter->unreachable_from);
> + ref_filter_init(filter);
> +}And the previous step matters here---otherwise we will end up walking two commit lists whose elements have all been popped in reach_filter().
Makes sense.
Show 5 quoted lines
> +void ref_filter_init(struct ref_filter *filter)
> +{
> + struct ref_filter blank = REF_FILTER_INIT;
> + memcpy(filter, &blank, sizeof(blank));
> +}I wonder if structure assignment "*filter = blank" is easier to see but I think we've seen this "_INIT; memcpy()" dance before.