[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v2 2/5] lib/nolibc: use a single file for both asprintf and vasprintf
From: Costin Lupu <costin.lupu@xxxxxxxxx> Move vasprintf function in asprintf.c and drop vasprintf.c . Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> Reviewed-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx> --- lib/nolibc/asprintf.c | 12 ++++++++++++ lib/nolibc/vasprintf.c | 15 --------------- 2 files changed, 12 insertions(+), 15 deletions(-) delete mode 100644 lib/nolibc/vasprintf.c diff --git a/lib/nolibc/asprintf.c b/lib/nolibc/asprintf.c index 4ec8353..edb491d 100644 --- a/lib/nolibc/asprintf.c +++ b/lib/nolibc/asprintf.c @@ -1,6 +1,18 @@ #define _GNU_SOURCE #include <stdio.h> #include <stdarg.h> +#include <stdlib.h> + +int vasprintf(char **s, const char *fmt, va_list ap) +{ + va_list ap2; + va_copy(ap2, ap); + int l = vsnprintf(0, 0, fmt, ap2); + va_end(ap2); + + if (l<0 || !(*s=malloc(l+1U))) return -1; + return vsnprintf(*s, l+1U, fmt, ap); +} int asprintf(char **s, const char *fmt, ...) { diff --git a/lib/nolibc/vasprintf.c b/lib/nolibc/vasprintf.c deleted file mode 100644 index 08251bc..0000000 --- a/lib/nolibc/vasprintf.c +++ /dev/null @@ -1,15 +0,0 @@ -#define _GNU_SOURCE -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> - -int vasprintf(char **s, const char *fmt, va_list ap) -{ - va_list ap2; - va_copy(ap2, ap); - int l = vsnprintf(0, 0, fmt, ap2); - va_end(ap2); - - if (l<0 || !(*s=malloc(l+1U))) return -1; - return vsnprintf(*s, l+1U, fmt, ap); -} -- 2.17.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |