Am 27.12.24 um 11:33 schrieb Patrick Steinhardt: > On Wed, Dec 25, 2024 at 07:38:35PM +0100, René Scharfe wrote: > >> diff --git a/reftable/basics.h b/reftable/basics.h >> index 259f4c274c..fa5d75868b 100644 >> --- a/reftable/basics.h >> +++ b/reftable/basics.h >> @@ -120,22 +120,35 @@ char *reftable_strdup(const char *str); >> #define REFTABLE_ALLOC_ARRAY(x, alloc) (x) = reftable_malloc(st_mult(sizeof(*(x)), (alloc))) >> #define REFTABLE_CALLOC_ARRAY(x, alloc) (x) = reftable_calloc((alloc), sizeof(*(x))) >> #define REFTABLE_REALLOC_ARRAY(x, alloc) (x) = reftable_realloc((x), st_mult(sizeof(*(x)), (alloc))) >> +#define REFTABLE_ALLOC_GROW(x, nr, alloc) ( \ >> + (nr) > (alloc) && ( \ >> + (x) = reftable_alloc_grow((x), (nr), sizeof(*(x)), &(alloc)), \ >> + (nr) > (alloc) \ >> + ) \ >> +) > > Do we even need this macro? I don't really think it serves much of a > purpose anymore. It provides the same value as the *ALLOC_ARRAY macros above: automatic sizeof handling. Plus it returns whether the allocation succeeded, avoiding repetition of its arguments in callers. René