From 8b6bf08a2361aba3ec61cea88d1bd7bb741c937a Mon Sep 17 00:00:00 2001 From: Will Miles Date: Tue, 19 Mar 2024 23:50:32 -0400 Subject: [PATCH] serveLiveLeds: Use variable buffer size Allocate the serialization buffer size at the required length, rather than always allocating the maximum size. --- wled00/json.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index f6cb645c0..c493ae2f2 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -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