mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
[debug] Use stack buffers with buf_append helper instead of std::string
This commit is contained in:
@@ -28,7 +28,7 @@ static constexpr size_t RESET_REASON_BUFFER_SIZE = 128;
|
||||
#ifdef USE_ESP8266
|
||||
// ESP8266: Use vsnprintf_P to keep format strings in flash (PROGMEM)
|
||||
// Format strings must be wrapped with PSTR() macro
|
||||
inline size_t buf_append_P(char *buf, size_t size, size_t pos, PGM_P fmt, ...) {
|
||||
inline size_t buf_append_p(char *buf, size_t size, size_t pos, PGM_P fmt, ...) {
|
||||
if (pos >= size) {
|
||||
return size;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ inline size_t buf_append_P(char *buf, size_t size, size_t pos, PGM_P fmt, ...) {
|
||||
}
|
||||
return std::min(pos + static_cast<size_t>(written), size);
|
||||
}
|
||||
#define buf_append(buf, size, pos, fmt, ...) buf_append_P(buf, size, pos, PSTR(fmt), ##__VA_ARGS__)
|
||||
#define buf_append(buf, size, pos, fmt, ...) buf_append_p(buf, size, pos, PSTR(fmt), ##__VA_ARGS__)
|
||||
#else
|
||||
/// Safely append formatted string to buffer, returning new position (capped at size)
|
||||
__attribute__((format(printf, 4, 5))) inline size_t buf_append(char *buf, size_t size, size_t pos, const char *fmt,
|
||||
|
||||
Reference in New Issue
Block a user