diff options
author | Mattias Andrée <maandree@kth.se> | 2024-08-18 09:43:16 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-08-18 09:43:16 +0200 |
commit | 715b59e5002b971a987c3c8a2e1b3e61d80388f7 (patch) | |
tree | aa64aa9fed94388056432f0f4a2180d5c03523fd /allocn.c | |
parent | Add @since for definitions added in version 1.0 and 1.1 (diff) | |
parent | Fix tests and libsimple_arraycpy and libsimple_arraymove (diff) | |
download | libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.gz libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.bz2 libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.xz |
Merge tag '1.2' into since
Version 1.2
Diffstat (limited to '')
-rw-r--r-- | allocn.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -15,11 +15,10 @@ alloc_size_product(int *errp, size_t n, va_list ap) n = va_arg(ap, size_t); if (!n) break; - if (n >= SIZE_MAX / prod) { + if (LIBSIMPLE_UMUL_OVERFLOW_NONZERO(n, prod, &prod, SIZE_MAX)) { *errp = ENOMEM; return 0; } - prod *= n; } return prod; } @@ -62,6 +61,15 @@ libsimple_vposix_memalignzn(void **memptr, int clear, size_t alignment, size_t n return ret; } +#ifdef LIBSIMPLE_HAVE_ALIGNED_REALLOC +void * +libsimple_valigned_reallocn(void *ptr, size_t alignment, size_t n, va_list ap) /* TODO test (aligned_reallocn) */ +{ + n = alloc_size_product(&errno, n, ap); + return !n ? NULL : aligned_realloc(ptr, alignment, n); +} +#endif + #else #include "test.h" |