summaryrefslogtreecommitdiffstats
path: root/xmalloc.c
diff options
context:
space:
mode:
authornicm <nicm>2019-11-28 09:51:58 +0000
committernicm <nicm>2019-11-28 09:51:58 +0000
commitc416fe0da43f9caffd8b5f6c1a627c8f7a16f881 (patch)
treea8dada3909f6f8d21ddc1f1aa187e20cb897063a /xmalloc.c
parent9ea05b2fb32395d717ead5d7904acdfaa852b068 (diff)
Add xrecallocarray.
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/xmalloc.c b/xmalloc.c
index f249e397..d11d8dc7 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -71,6 +71,20 @@ xreallocarray(void *ptr, size_t nmemb, size_t size)
return new_ptr;
}
+void *
+xrecallocarray(void *ptr, size_t oldnmemb, size_t nmemb, size_t size)
+{
+ void *new_ptr;
+
+ if (nmemb == 0 || size == 0)
+ fatalx("xrecallocarray: zero size");
+ new_ptr = recallocarray(ptr, oldnmemb, nmemb, size);
+ if (new_ptr == NULL)
+ fatalx("xrecallocarray: allocating %zu * %zu bytes: %s",
+ nmemb, size, strerror(errno));
+ return new_ptr;
+}
+
char *
xstrdup(const char *str)
{