aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmalloc.c7
-rw-r--r--xmalloc.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/xmalloc.c b/xmalloc.c
index ded7f4e3..0a67cdb2 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -36,6 +36,13 @@ xrealloc(void *ptr, size_t size)
return unlikely(size == 0) ? alloc : check_alloc(alloc);
}
+void *
+xreallocarray(void *ptr, size_t n, size_t size)
+{
+ void *alloc = reallocarray(ptr, n, size);
+ return unlikely(size == 0) ? alloc : check_alloc(alloc);
+}
+
char *
xstrdup(const char *str)
{
diff --git a/xmalloc.h b/xmalloc.h
index 8a2c208f..03e6eb0d 100644
--- a/xmalloc.h
+++ b/xmalloc.h
@@ -12,6 +12,7 @@
void *xmalloc(size_t size) XMALLOC;
void *xcalloc(size_t nmemb, size_t size) XMALLOC;
void *xrealloc(void *ptr, size_t size);
+void *xreallocarray(void *ptr, size_t n, size_t size);
char *xstrdup(const char *str) XSTRDUP;
char *xstrndup(const char *str, size_t n) XSTRDUP;
char *xasprintf(const char *format, ...) PRINTF(1) XMALLOC;