diff options
author | Hans Goudey <h.goudey@me.com> | 2022-11-11 04:14:48 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-11-11 04:41:13 +0300 |
commit | 9465b109af0b70244a36f9e68493e316d9f8b56f (patch) | |
tree | c4d933bf09f8313071556063156538ec3356b24c /source/blender/blenlib/intern/string.c | |
parent | 026d21a225521670c6b5083da9da61227da69e65 (diff) | |
parent | ca1642cd0c5cdf634fe2022c955d93983de95934 (diff) |
Merge branch 'master' into refactor-mesh-position-genericrefactor-mesh-position-generic
Diffstat (limited to 'source/blender/blenlib/intern/string.c')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 755d2dbd55d..3c3dcaf90f4 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -241,6 +241,17 @@ char *BLI_sprintfN(const char *__restrict format, ...) return n; } +int BLI_sprintf(char *__restrict str, const char *__restrict format, ...) +{ + va_list arg; + + va_start(arg, format); + const int result = vsprintf(str, format, arg); + va_end(arg); + + return result; +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -1114,7 +1125,7 @@ static size_t BLI_str_format_int_grouped_ex(char src[16], char dst[16], int num_ size_t BLI_str_format_int_grouped(char dst[16], int num) { char src[16]; - int num_len = sprintf(src, "%d", num); + const int num_len = BLI_snprintf(src, sizeof(src), "%d", num); return BLI_str_format_int_grouped_ex(src, dst, num_len); } @@ -1124,7 +1135,7 @@ size_t BLI_str_format_uint64_grouped(char dst[16], uint64_t num) /* NOTE: Buffer to hold maximum `uint64`, which is 1.8e+19. but * we also need space for commas and null-terminator. */ char src[27]; - int num_len = sprintf(src, "%" PRIu64 "", num); + const int num_len = BLI_snprintf(src, sizeof(src), "%" PRIu64 "", num); return BLI_str_format_int_grouped_ex(src, dst, num_len); } |