Compare commits

...

3 Commits

Author SHA1 Message Date
J. Nick Koston
c37f372885 Merge branch 'dev' into str_sprintf 2026-01-21 19:51:45 -10:00
J. Nick Koston
06c619b2e0 [ci] Soft-deprecate str_sprintf/str_snprintf to prevent hidden heap allocations 2026-01-14 15:48:22 -10:00
J. Nick Koston
71c922bb60 [ci] Soft-deprecate str_sprintf/str_snprintf to prevent hidden heap allocations 2026-01-14 15:46:09 -10:00
2 changed files with 7 additions and 1 deletions

View File

@@ -655,9 +655,11 @@ inline uint32_t fnv1_hash_object_id(const char *str, size_t len) {
}
/// snprintf-like function returning std::string of maximum length \p len (excluding null terminator).
/// @warning Allocates heap memory. Use snprintf() with a stack buffer instead.
std::string __attribute__((format(printf, 1, 3))) str_snprintf(const char *fmt, size_t len, ...);
/// sprintf-like function returning std::string.
/// @warning Allocates heap memory. Use snprintf() with a stack buffer instead.
std::string __attribute__((format(printf, 1, 2))) str_sprintf(const char *fmt, ...);
#ifdef USE_ESP8266

View File

@@ -692,6 +692,8 @@ HEAP_ALLOCATING_HELPERS = {
"str_truncate": "removal (function is unused)",
"str_upper_case": "removal (function is unused)",
"str_snake_case": "removal (function is unused)",
"str_sprintf": "snprintf() with a stack buffer",
"str_snprintf": "snprintf() with a stack buffer",
}
@@ -710,7 +712,9 @@ HEAP_ALLOCATING_HELPERS = {
r"str_sanitize(?!_)|"
r"str_truncate|"
r"str_upper_case|"
r"str_snake_case"
r"str_snake_case|"
r"str_sprintf|"
r"str_snprintf"
r")\s*\(" + CPP_RE_EOL,
include=cpp_include,
exclude=[