Re: [PATCH 3/6] index-pack: remove redundant child field
- From
Jeff King <peff@peff.net>
- Date
- Oct 17, 2019, 06:26 UTC
- Message-ID
- <20191017062640.GD10862@sigill.intra.peff.net>
- In-Reply-To
- <39740c6e58bd6cb6ea33e5abb4ab8542ff6eb7b7.1570663470.git.jonathantanmy@google.com>
On Wed, Oct 09, 2019 at 04:44:19PM -0700, Jonathan Tan wrote:
Show 12 quoted lines
> -static void prune_base_data(struct base_data *retain)
> +static void prune_base_data(struct base_data *youngest_child)
> {
> struct base_data *b;
> struct thread_local *data = get_thread_data();
> - for (b = data->base_cache;
> - data->base_cache_used > delta_base_cache_limit && b;
> - b = b->child) {
> - if (b->data && b != retain)
> - free_base_data(b);
> + struct base_data **ancestry = NULL;
> + int nr = 0, alloc = 0;Minor, but please use size_t for allocation variables.
> + int i;
Technically this probably ought to be a size_t as well, but I'm much more concerned about the allocation ones, where we might accidentally overflow and underallocate a buffer. Overflowing "i" would probably just lead to an error or bad result.
I _think_ what the patch is actually doing makes sense (taking as an assumption that it's heading in a useful direction for the end of the series).
-Peff