aboutsummaryrefslogtreecommitdiff
path: root/backend/String.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 20:31:18 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 20:31:18 +0100
commitd8daa3e045ca2f41edcbed533bc5a9fef1363a17 (patch)
tree6a4c0883d05607476b609e68bcac7d854e281aea /backend/String.cpp
parent6e1d62955c7a7f39bc9126d709a42a70e02a1d30 (diff)
print to backend
Diffstat (limited to 'backend/String.cpp')
-rw-r--r--backend/String.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/backend/String.cpp b/backend/String.cpp
index 2b40c88..e387589 100644
--- a/backend/String.cpp
+++ b/backend/String.cpp
@@ -20,17 +20,22 @@ String::String(const char * c_str) {
}
String String::fmt(const char * fmt, ...) {
- String out;
- va_list args, args_copy;
+ va_list args;
va_start(args, fmt);
+ String out = String::va_fmt(args, fmt);
+ va_end(args);
+ return out;
+}
+String String::va_fmt(va_list args, const char * fmt) {
+ String out;
+ va_list args_copy;
va_copy(args_copy, args);
out._data_len = vsnprintf(NULL, 0, fmt, args_copy);
va_end(args_copy);
out._data = static_cast<char *>(malloc(out._data_len + 1));
vsnprintf(out._data, out._data_len + 1, fmt, args);
- va_end(args);
return out;
}