aboutsummaryrefslogtreecommitdiffstats
path: root/memory/reallocarray.c
diff options
context:
space:
mode:
Diffstat (limited to 'memory/reallocarray.c')
-rw-r--r--memory/reallocarray.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/memory/reallocarray.c b/memory/reallocarray.c
new file mode 100644
index 0000000..8148b20
--- /dev/null
+++ b/memory/reallocarray.c
@@ -0,0 +1,12 @@
+#include "memory.h"
+#include <errno.h>
+#include <stdint.h>
+
+void *reallocarray(void *buffer, size_t count, size_t size)
+{
+ if (count > 0 && SIZE_MAX / count < size) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return _realloc_wrap(buffer, count * size);
+}