summary refs log tree commit diff
path: root/xmalloc.c
diff options
context:
space:
mode:
authorokan <okan>2015-03-28 23:12:47 +0000
committerokan <okan>2015-03-28 23:12:47 +0000
commita4a414b68bf8a59255ee68959863f4c5fdee85d9 (patch)
treec612ebec85e5022479b6888b1ada2c5ad17c8eac /xmalloc.c
parent0bbe0ad98c7b8ed5d081747ee3bdb2dbf7a1b848 (diff)
downloadcwm-a4a414b68bf8a59255ee68959863f4c5fdee85d9.tar.gz
cwm-a4a414b68bf8a59255ee68959863f4c5fdee85d9.tar.xz
cwm-a4a414b68bf8a59255ee68959863f4c5fdee85d9.zip
Introduce a xreallocarray and convert a few xcalloc instances that do
not require zero'ing.
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/xmalloc.c b/xmalloc.c
index 2db79ab..9cf824a 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -61,6 +61,18 @@ xcalloc(size_t no, size_t siz)
 	return(p);
 }
 
+void *
+xreallocarray(void *ptr, size_t nmemb, size_t size)
+{
+	void	*p;
+
+	p = reallocarray(ptr, nmemb, size);
+	if (p == NULL)
+		errx(1, "xreallocarray: out of memory (new_size %zu bytes)",
+		    nmemb * size);
+	return(p);
+}
+
 char *
 xstrdup(const char *str)
 {