From bb1f0f3368f3ee2065b0e5ee74e3c45b0116e8a9 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Mon, 20 Oct 2014 07:50:42 +0000 Subject: get rid of gu/str.(c|h) --- src/runtime/c/gu/out.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/runtime/c/gu/out.c') diff --git a/src/runtime/c/gu/out.c b/src/runtime/c/gu/out.c index 6bde9cc58..d08b192dc 100644 --- a/src/runtime/c/gu/out.c +++ b/src/runtime/c/gu/out.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include static bool gu_out_is_buffering(GuOut* out) @@ -261,7 +261,15 @@ void gu_vprintf(const char* fmt, va_list args, GuOut* out, GuExn* err) { GuPool* tmp_pool = gu_local_pool(); - char* str = gu_vasprintf(fmt, args, tmp_pool); + + va_list args2; + va_copy(args2, args); + int len = vsnprintf(NULL, 0, fmt, args2); + gu_assert_msg(len >= 0, "Invalid format string: \"%s\"", fmt); + va_end(args2); + char* str = gu_new_n(char, len + 1, tmp_pool); + vsnprintf(str, len + 1, fmt, args); + gu_out_bytes(out, (const uint8_t*) str, strlen(str), err); gu_pool_free(tmp_pool); } -- cgit v1.2.3