diff options
Diffstat (limited to 'allocn.c')
-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" |