Re: [PATCH v2 2/9] reftable: introduce macros to allocate arrays
On Mon, Feb 05, 2024 at 07:48:41AM -0800, Karthik Nayak wrote:
Show 16 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
>
> > Similar to the preceding commit, let's carry over macros to allocate
> > arrays with `REFTABLE_ALLOC_ARRAY()` and `REFTABLE_CALLOC_ARRAY()`. This
> > requires us to change the signature of `reftable_calloc()`, which only
> > takes a single argument right now and thus puts the burden on the caller
> > to calculate the final array's size. This is a net improvement though as
> > it means that we can now provide proper overflow checks when multiplying
> > the array size with the member size.
> >
> > Convert callsites of `reftable_calloc()` to the new signature, using the
> > new macros where possible.
>
> What about converting users of `reftable_malloc()` to use
> `REFTABLE_ALLOC_ARRAY()`. This means currently `REFTABLE_ALLOC_ARRAY()`
> is defined and never used in this patch series.
Good point, will do.
Patrick