summaryrefslogtreecommitdiff
path: root/xmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/xmalloc.c b/xmalloc.c
index 9cd0127dd..b48d33bbf 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: xmalloc.c,v 1.35 2019/06/06 05:13:13 otto Exp $ */ 1/* $OpenBSD: xmalloc.c,v 1.36 2019/11/12 22:32:48 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -96,17 +96,24 @@ xstrdup(const char *str)
96} 96}
97 97
98int 98int
99xvasprintf(char **ret, const char *fmt, va_list ap)
100{
101 int i;
102
103 i = vasprintf(ret, fmt, ap);
104 if (i < 0 || *ret == NULL)
105 fatal("xvasprintf: could not allocate memory");
106 return i;
107}
108
109int
99xasprintf(char **ret, const char *fmt, ...) 110xasprintf(char **ret, const char *fmt, ...)
100{ 111{
101 va_list ap; 112 va_list ap;
102 int i; 113 int i;
103 114
104 va_start(ap, fmt); 115 va_start(ap, fmt);
105 i = vasprintf(ret, fmt, ap); 116 i = xvasprintf(ret, fmt, ap);
106 va_end(ap); 117 va_end(ap);
107 118 return i;
108 if (i < 0 || *ret == NULL)
109 fatal("xasprintf: could not allocate memory");
110
111 return (i);
112} 119}