aboutsummaryrefslogtreecommitdiffstats
path: root/allocn.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-08-18 09:43:16 +0200
committerMattias Andrée <maandree@kth.se>2024-08-18 09:43:16 +0200
commit715b59e5002b971a987c3c8a2e1b3e61d80388f7 (patch)
treeaa64aa9fed94388056432f0f4a2180d5c03523fd /allocn.c
parentAdd @since for definitions added in version 1.0 and 1.1 (diff)
parentFix tests and libsimple_arraycpy and libsimple_arraymove (diff)
downloadlibsimple-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.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"