diff options
author | Karel Kočí <karel.koci@nic.cz> | 2018-08-27 16:46:12 +0200 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2018-08-27 16:54:40 +0200 |
commit | 5a7d5fa43536484508aad9d9553f64a33212311b (patch) | |
tree | e4ca1be7213a1460df47b63a2fbd9229d61d86d4 /utils.c | |
download | uroot-5a7d5fa43536484508aad9d9553f64a33212311b.tar.gz uroot-5a7d5fa43536484508aad9d9553f64a33212311b.tar.bz2 uroot-5a7d5fa43536484508aad9d9553f64a33212311b.zip |
Initial commit
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -0,0 +1,19 @@ +#include "utils.h" + +// Compute the size needed (including \0) to format given message +size_t printf_len(const char *msg, ...) { + va_list args; + va_start(args, msg); + size_t result = vsnprintf(NULL, 0, msg, args); + va_end(args); + return result + 1; +} + +// Like sprintf, but returs the string. Expects there's enough space. +char *printf_into(char *dst, const char *msg, ...) { + va_list args; + va_start(args, msg); + vsprintf(dst, msg, args); + va_end(args); + return dst; +} |