aboutsummaryrefslogtreecommitdiff
path: root/xmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/xmalloc.c b/xmalloc.c
index ded7f4e3..ccfb5c48 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -32,8 +32,17 @@ xcalloc(size_t nmemb, size_t size)
void *
xrealloc(void *ptr, size_t size)
{
+ xassert(size != 0);
void *alloc = realloc(ptr, size);
- return unlikely(size == 0) ? alloc : check_alloc(alloc);
+ return check_alloc(alloc);
+}
+
+void *
+xreallocarray(void *ptr, size_t n, size_t size)
+{
+ xassert(n != 0 && size != 0);
+ void *alloc = reallocarray(ptr, n, size);
+ return check_alloc(alloc);
}
char *