diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-08-03 15:31:39 -0300 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-08-03 15:31:39 -0300 |
commit | 1c59139687546db411fe6957cbdb2122666a0515 (patch) | |
tree | 484b53c2de440e90ce890b05134a2a6059ccc342 /misc.c | |
parent | 7fb60e31ab104a05dcf3840c7580c630ff4636ee (diff) |
misc: Add `vformat_len_copy()`
This works the same as `vformat_len()`, except that it copies `args`
into a temporary `va_list`.
This can be useful when you're already using a `va_list`, and thus need
to copy the list already.
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -201,6 +201,15 @@ char *skip_whitespace(const char *str) { } } +int vformat_len_copy(const char *fmt, va_list args) { + int len; + va_list tmp_args; + va_copy(tmp_args, args); + len = vformat_len(fmt, tmp_args); + va_end(tmp_args); + return len; +} + int vformat_len(const char *fmt, va_list args) { return vsnprintf(NULL, 0, fmt, args); } |