Re: [PATCH 1/3] fsck: free tree buffers after walking unreachable objects
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 22, 2022, 19:27 UTC
- Message-ID
- <xmqq5yhfyztm.fsf@gitster.g>
- In-Reply-To
- <YyywSdrWO61Kza0e@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I do think it is true that this is the final time we'd look at these > objects. But I don't think it would be a disaster if somebody did. The > free_tree_buffer() function clears the "parsed" flag on the struct.
Ah, that is perfectly fine, then. Thanks.
> As a side note, IMHO having tree->buffer at all is a mistake, because it > leads to exactly this kind of confusion about when the buffer should be > discarded. We'd be better off having all callers parse directly into a > local buffer, and then clean up when they're done.
Yeah, tree-walk.c users woud use tree_desc structure anyway, and instead of having a moving pointer that points into a separate thing (i.e. tree->buffer), it could have its own copy of the "whole buffer" that can be used to free when it is done iterating over entries.
> .... But that's obviously a much bigger change.
Yup.
Thanks.