summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-11-28 09:51:59 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-11-28 09:51:59 +0000
commit699ccf7099cc83b40b031690ef3734d9e22d41c5 (patch)
treef8d4b1e225f4407ed4d3a7fb28eb8615ccfde5a6 /usr.bin/tmux
parent1a27458ca1e1939312c1ea8a49a714452d3a146e (diff)
Add xrecallocarray.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/xmalloc.c16
-rw-r--r--usr.bin/tmux/xmalloc.h3
2 files changed, 17 insertions, 2 deletions
diff --git a/usr.bin/tmux/xmalloc.c b/usr.bin/tmux/xmalloc.c
index 0871b7c7e19..7bb3b526132 100644
--- a/usr.bin/tmux/xmalloc.c
+++ b/usr.bin/tmux/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.12 2019/06/28 05:44:09 deraadt Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.13 2019/11/28 09:51:58 nicm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -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)
{
diff --git a/usr.bin/tmux/xmalloc.h b/usr.bin/tmux/xmalloc.h
index 76d93a26fc3..570c2e33e4a 100644
--- a/usr.bin/tmux/xmalloc.h
+++ b/usr.bin/tmux/xmalloc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.h,v 1.2 2016/11/17 10:06:08 nicm Exp $ */
+/* $OpenBSD: xmalloc.h,v 1.3 2019/11/28 09:51:58 nicm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -23,6 +23,7 @@ void *xmalloc(size_t);
void *xcalloc(size_t, size_t);
void *xrealloc(void *, size_t);
void *xreallocarray(void *, size_t, size_t);
+void *xrecallocarray(void *, size_t, size_t, size_t);
char *xstrdup(const char *);
char *xstrndup(const char *, size_t);
int xasprintf(char **, const char *, ...)