Re: [PATCH v2 2/9] reftable: introduce macros to allocate arrays
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Feb 5, 2024, 15:48 UTC
- Message-ID
- <CAOLa=ZSDz4PMqFGp3MHr7Ls2xOUs+NEnG-y09J9knNd_eGpZUQ@mail.gmail.com>
- In-Reply-To
- <2dde581a0256e4634ca4a64f313a98204763906a.1706772591.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 10 quoted lines
> 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.