serveLiveLeds: Use variable buffer size

Allocate the serialization buffer size at the required length, rather
than always allocating the maximum size.
pull/3828/head
Will Miles 2024-03-19 23:50:32 -04:00
rodzic 2640203c88
commit 8b6bf08a23
1 zmienionych plików z 1 dodań i 1 usunięć

Wyświetl plik

@ -1152,7 +1152,7 @@ bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient)
}
#endif
DynamicBuffer buffer(9 + (9*MAX_LIVE_LEDS) + 7 + 5 + 6 + 5 + 6 + 5 + 2);
DynamicBuffer buffer(9 + (9*(1+(used/n))) + 7 + 5 + 6 + 5 + 6 + 5 + 2);
char* buf = buffer.data(); // assign buffer for oappnd() functions
strncpy_P(buffer.data(), PSTR("{\"leds\":["), buffer.size());
buf += 9; // sizeof(PSTR()) from last line