add d_malloc_only() for AsyncJSON

major stability improvement, especially on classic esp32.
This commit is contained in:
Frank
2026-02-20 01:09:52 +01:00
parent 8680d13df4
commit e519b4190b
3 changed files with 22 additions and 2 deletions

View File

@@ -17,6 +17,8 @@
// global WLED memory functions (util.cpp)
extern "C" {
// only allocate from internal DRAM, never uses PSRAM
void *d_malloc_only(size_t);
// prefer DRAM in d_xalloc functions, PSRAM as fallback
void *d_malloc(size_t);
void *d_calloc(size_t, size_t);
@@ -168,8 +170,9 @@ public:
if (_onRequest) {
_contentLength = total;
if (total > 0 && request->_tempObject == NULL && (int)total < _maxContentLength) {
//request->_tempObject = malloc(total);
//request->_tempObject = d_malloc(total); // seems to cause instabilities on classic esp32 with PSRAM
request->_tempObject = malloc(total);
request->_tempObject = d_malloc_only(total);
}
if (request->_tempObject != NULL) {
memcpy((uint8_t*)(request->_tempObject) + index, data, len);