summaryrefslogtreecommitdiff
path: root/usr.bin/sort/mem.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-03-30 19:57:37 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-03-30 19:57:37 +0000
commit372431faaf47acdffd7f206b484d73aba84bcafb (patch)
tree68b74d12b4b8d3920bb82a2fdb692c54c71e983b /usr.bin/sort/mem.c
parentccc1ec1680f7855ed0e79c0fd20f15be416fe16e (diff)
Add sort_asprintf()
Diffstat (limited to 'usr.bin/sort/mem.c')
-rw-r--r--usr.bin/sort/mem.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/usr.bin/sort/mem.c b/usr.bin/sort/mem.c
index c223292a1ff..a38bf13bb9a 100644
--- a/usr.bin/sort/mem.c
+++ b/usr.bin/sort/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.2 2015/03/17 17:49:27 millert Exp $ */
+/* $OpenBSD: mem.c,v 1.3 2015/03/30 19:57:36 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -29,7 +29,7 @@
#include <err.h>
#include <stdint.h>
-#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include "mem.h"
@@ -103,3 +103,18 @@ sort_strdup(const char *str)
err(2, NULL);
return dup;
}
+
+int
+sort_asprintf(char **ret, const char *fmt, ...)
+{
+ int len;
+ va_list ap;
+
+ va_start(ap, fmt);
+ len = vasprintf(ret, fmt, ap);
+ va_end(ap);
+
+ if (len == -1)
+ err(2, NULL);
+ return len;
+}