aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'teensy/teensy_context.c')
-rw-r--r--teensy/teensy_context.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/teensy/teensy_context.c b/teensy/teensy_context.c
index 91b9b90..ad7c79e 100644
--- a/teensy/teensy_context.c
+++ b/teensy/teensy_context.c
@@ -1,6 +1,7 @@
#include "teensy_context.h"
#include <math.h>
+#include <stdarg.h>
#include <time.h>
#include "teensy_platform.h"
@@ -99,3 +100,27 @@ void ty_sleep(uint64_t ms)
ts.tv_nsec = (ms % 1000) * 1000000;
nanosleep(&ts, NULL);
}
+
+char *ty_format_args(const char *fmt, va_list list)
+{
+ va_list args;
+ va_copy(args, list);
+ int len = vsnprintf(NULL, 0, fmt, args);
+ char *text = ty_talloc(sizeof(char) * (len + 1));
+ va_end(args);
+
+ va_copy(args, list);
+ vsnprintf(text, len + 1, fmt, args);
+ va_end(args);
+
+ return text;
+}
+
+char *ty_format(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ char *text = ty_format_args(fmt, args);
+ va_end(args);
+ return text;
+}