summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2022-08-03 15:31:39 -0300
committermrb0nk500 <b0nk@b0nk.xyz>2022-08-03 15:31:39 -0300
commit1c59139687546db411fe6957cbdb2122666a0515 (patch)
tree484b53c2de440e90ce890b05134a2a6059ccc342 /misc.c
parent7fb60e31ab104a05dcf3840c7580c630ff4636ee (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.c9
1 files changed, 9 insertions, 0 deletions
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);
}