summaryrefslogtreecommitdiff
path: root/src/runtime/c/gu/out.c
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2014-10-20 07:50:42 +0000
committerkr.angelov <kr.angelov@gmail.com>2014-10-20 07:50:42 +0000
commitbb1f0f3368f3ee2065b0e5ee74e3c45b0116e8a9 (patch)
tree943c45eb896e0e99564ad84f27fed4d96cf09aaa /src/runtime/c/gu/out.c
parent84bce336fd2acc5b18e0e8792a82b682dacaab37 (diff)
get rid of gu/str.(c|h)
Diffstat (limited to 'src/runtime/c/gu/out.c')
-rw-r--r--src/runtime/c/gu/out.c12
1 files changed, 10 insertions, 2 deletions
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 <gu/seq.h>
#include <gu/out.h>
#include <gu/utf8.h>
-#include <gu/str.h>
+#include <stdio.h>
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);
}