mirror of
https://github.com/esphome/esphome.git
synced 2025-11-15 22:35:46 +00:00
Update esphome/components/web_server_idf/web_server_idf.cpp
Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com>
This commit is contained in:
@@ -353,9 +353,8 @@ void AsyncWebServerResponse::addHeader(const char *name, const char *value) {
|
|||||||
void AsyncResponseStream::print(float value) {
|
void AsyncResponseStream::print(float value) {
|
||||||
// Use stack buffer to avoid temporary string allocation
|
// Use stack buffer to avoid temporary string allocation
|
||||||
// Size: sign (1) + digits (10) + decimal (1) + precision (6) + exponent (5) + null (1) = 24, use 32 for safety
|
// Size: sign (1) + digits (10) + decimal (1) + precision (6) + exponent (5) + null (1) = 24, use 32 for safety
|
||||||
constexpr size_t float_buf_size = 32;
|
char buf[32];
|
||||||
char buf[float_buf_size];
|
int len = snprintf(buf, sizeof(buf), "%f", value);
|
||||||
int len = snprintf(buf, float_buf_size, "%f", value);
|
|
||||||
this->content_.append(buf, len);
|
this->content_.append(buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user