From 1c59139687546db411fe6957cbdb2122666a0515 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Wed, 3 Aug 2022 15:31:39 -0300 Subject: 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. --- misc.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 3f82b64..36bbad4 100644 --- a/misc.c +++ b/misc.c @@ -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); } -- cgit v1.2.3-13-gbd6f