aboutsummaryrefslogtreecommitdiffstats
path: root/allocn.c
diff options
context:
space:
mode:
Diffstat (limited to 'allocn.c')
-rw-r--r--allocn.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/allocn.c b/allocn.c
index d54542c..ce4fbad 100644
--- a/allocn.c
+++ b/allocn.c
@@ -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"