Re: [RFC PATCH 2/5] Add delta-islands.{c,h}
- From
Jeff King <peff@peff.net>
- Date
- Jul 27, 2018, 09:40 UTC
- Message-ID
- <20180727094026.GA17155@sigill.intra.peff.net>
- In-Reply-To
- <20180722054836.28935-3-chriscool@tuxfamily.org>
On Sun, Jul 22, 2018 at 07:48:33AM +0200, Christian Couder wrote:
Show 8 quoted lines
> + /* > + * We process only trees, as commits and tags have already been handled > + * (and passed their marks on to root trees, as well. We must make sure > + * to process them in descending tree-depth order so that marks > + * propagate down the tree properly, even if a sub-tree is found in > + * multiple parent trees. > + */ > + todo = xmalloc(to_pack->nr_objects * sizeof(*todo));
I was fiddling with "make coccicheck", and it looks like this code could stand some modernization. This could use ALLOC_ARRAY().
Show 5 quoted lines
> + for (i = 0; i < to_pack->nr_objects; i++) {
> + if (oe_type(&to_pack->objects[i]) == OBJ_TREE)
> + todo[nr++] = &to_pack->objects[i];
> + }
> + qsort(todo, nr, sizeof(*todo), cmp_tree_depth);And this QSORT().
There are a few others, I won't list them all. The only tricky one I see is:
> + free(tree->buffer); > + tree->buffer = NULL; > + tree->object.parsed = 0;
This suggests FREE_AND_NULL(), but I think it actually the whole block should become a call to free_tree_buffer().
-Peff