diff options
Diffstat (limited to 'backend/String.cpp')
-rw-r--r-- | backend/String.cpp | 11 |
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; } |