aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-02-01 01:55:04 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-02-01 01:55:04 -0800
commit17fabd540aeb5019909a024243c6d26610cab307 (patch)
treef69edc766d9602dcfa3e56d6822de01789673989
parentaa5948f9f394c9357fce8ee3e7ad7b7f10fa63b1 (diff)
downloadklibc-17fabd540aeb5019909a024243c6d26610cab307.tar.gz
[klibc] Make asprintf() a simple wrapper around vasprintf()
Since we have vasprintf() anyway, save about a hundred bytes (on x86-64) by making asprintf() a typical stdarg wrapper function. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--usr/klibc/asprintf.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/usr/klibc/asprintf.c b/usr/klibc/asprintf.c
index a3f5f003d18a7..ce3aa76928e4c 100644
--- a/usr/klibc/asprintf.c
+++ b/usr/klibc/asprintf.c
@@ -8,22 +8,13 @@
int asprintf(char **bufp, const char *format, ...)
{
- va_list ap, ap1;
+ va_list ap;
int rv;
int bytes;
char *p;
va_start(ap, format);
- va_copy(ap1, ap);
-
- bytes = vsnprintf(NULL, 0, format, ap1) + 1;
- va_end(ap1);
-
- *bufp = p = malloc(bytes);
- if (!p)
- return -1;
-
- rv = vsnprintf(p, bytes, format, ap);
+ rv = vasprintf(bufp, format, ap);
va_end(ap);
return rv;