reftable: introduce macros to allocate arrays
commitb4ff12c8eefff9cba73ba3cb7492111adfa31d87
authorPatrick Steinhardt <ps@pks.im>
Tue, 6 Feb 2024 06:35:27 +0000 (6 07:35 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Feb 2024 20:10:08 +0000 (6 12:10 -0800)
treecf75adb950d3c8bc7fd2743513ead645a5dbe453
parentf6b58c1be40ba4bd6e7f2364acfe5fa34ce04120
reftable: introduce macros to allocate arrays

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 and start
using the new macros where possible.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
16 files changed:
reftable/basics.h
reftable/block.c
reftable/block_test.c
reftable/blocksource.c
reftable/iter.c
reftable/merged.c
reftable/merged_test.c
reftable/publicbasics.c
reftable/reader.c
reftable/readwrite_test.c
reftable/record.c
reftable/record_test.c
reftable/refname.c
reftable/stack.c
reftable/tree.c
reftable/writer.c