improve robustness when heap is low
* customMappingTable: allocate using calloc instead of new (new will throw exception if nor enough heap) * fixing a few minor memory leaks * ws.cpp: catch out-of-memory in sendLiveLedsWs * ws.cpp: change interval to 80ms (120 ws very slow...)
This commit is contained in:
@@ -37,7 +37,8 @@
|
||||
void WS2812FX::setUpMatrix() {
|
||||
#ifndef WLED_DISABLE_2D
|
||||
// erase old ledmap, just in case.
|
||||
if (customMappingTable != nullptr) delete[] customMappingTable;
|
||||
//if (customMappingTable != nullptr) delete[] customMappingTable;
|
||||
if (customMappingTable != nullptr) free(customMappingTable);
|
||||
customMappingTable = nullptr;
|
||||
customMappingSize = 0;
|
||||
|
||||
@@ -68,7 +69,9 @@ void WS2812FX::setUpMatrix() {
|
||||
return;
|
||||
}
|
||||
|
||||
customMappingTable = new uint16_t[Segment::maxWidth * Segment::maxHeight];
|
||||
//customMappingTable = new uint16_t[Segment::maxWidth * Segment::maxHeight];
|
||||
if (nullptr != customMappingTable) free(customMappingTable);
|
||||
customMappingTable = (uint16_t *) calloc(Segment::maxWidth * Segment::maxHeight, sizeof(uint16_t));
|
||||
|
||||
if (customMappingTable != nullptr) {
|
||||
customMappingSize = Segment::maxWidth * Segment::maxHeight;
|
||||
|
||||
Reference in New Issue
Block a user