diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-02-06 07:35:27 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-02-06 12:10:08 -0800 |
| commit | b4ff12c8eefff9cba73ba3cb7492111adfa31d87 (patch) | |
| tree | cf75adb950d3c8bc7fd2743513ead645a5dbe453 /reftable/block_test.c | |
| parent | reftable: introduce macros to grow arrays (diff) | |
| download | git-b4ff12c8eefff9cba73ba3cb7492111adfa31d87.tar.gz git-b4ff12c8eefff9cba73ba3cb7492111adfa31d87.zip | |
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>
Diffstat (limited to 'reftable/block_test.c')
| -rw-r--r-- | reftable/block_test.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/reftable/block_test.c b/reftable/block_test.c index dedb05c7d8..e162c6e33f 100644 --- a/reftable/block_test.c +++ b/reftable/block_test.c @@ -36,7 +36,7 @@ static void test_block_read_write(void) int j = 0; struct strbuf want = STRBUF_INIT; - block.data = reftable_calloc(block_size); + REFTABLE_CALLOC_ARRAY(block.data, block_size); block.len = block_size; block.source = malloc_block_source(); block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size, |
