diff options
Diffstat (limited to 'xmalloc.c')
-rw-r--r-- | xmalloc.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -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 | ||
98 | int | 98 | int |
99 | xvasprintf(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 | |||
109 | int | ||
99 | xasprintf(char **ret, const char *fmt, ...) | 110 | xasprintf(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 | } |