Re: [PATCH 1/4] repack: convert "names" util bitfield to array
- From
Jeff King <peff@peff.net>
- Date
- Oct 21, 2022, 23:29 UTC
- Message-ID
- <Y1MrXoobkVKngYL1@coredump.intra.peff.net>
- In-Reply-To
- <Y1Mm9zTX3XwN3IWu@nand.local>
On Fri, Oct 21, 2022 at 07:10:47PM -0400, Taylor Blau wrote:
Show 11 quoted lines
> > + struct generated_pack_data *data = xcalloc(1, sizeof(*data)); > > I'm nitpicking, but we could replace this with; > > struct generated_pack_data *data; > > CALLOC_ARRAY(data, 1); > > so that we don't have to rely on calling sizeof(*data). But > sizeof(*data) will always give us the right answer anyway, even if the > name of data's type changed, so what you have is fine, too.
Yeah, I actually considered writing it that way, but it felt a bit silly to use _ARRAY for something which is clearly meant to be a single item. Grepping for "CALLOC_ARRAY([^)]*, 1)" does seem to turn up quite a few hits, though, so maybe it is just me.
We could also introduce:
#define CALLOC(x) CALLOC_ARRAY((x), 1)
but even if we think that is a good idea, it should not be in this series.
It looks I may re-roll for the fname_old stuff in the other part of the thread, so I'll take your suggestion.
-Peff