summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-11-28 09:51:58 +0000
committernicm <nicm@openbsd.org>2019-11-28 09:51:58 +0000
commit18b1287e91faeee1e1b773686284365f28cb56d3 (patch)
treed19547ab639a6fa3d85a30753959a011a2ad176a
parentBump the escape sequence timeout to five seconds to allow for longer (diff)
downloadwireguard-openbsd-18b1287e91faeee1e1b773686284365f28cb56d3.tar.xz
wireguard-openbsd-18b1287e91faeee1e1b773686284365f28cb56d3.zip
Add xrecallocarray.
-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 *, ...)