Websocket - Allow to choose which memory takes (internal, external) for buffer (IDFGH-12913)
filzek opened this issue · 3 comments
Is your feature request related to a problem?
Memory allocartion always internal, need to have an option to choose it to delegates internal or external.
Describe the solution you'd like.
No response
Describe alternatives you've considered.
No response
Additional context.
No response
could be setup in the esp_websocket_client_config_t or with a custom handler like in the CJSON to override:
memoryHook.malloc_fn = spiram_calloc;
memoryHook.free_fn = spiram_free;
cJSON_InitHooks(&memoryHook);
// Wrapper calloc SPI RAM.
void* spiram_calloc(size_t size) {
void* ptr = TRACEABLE_HEAP_CAPS_CALLOC(1, size * sizeof(unsigned char), MALLOC_CAP_SPIRAM);
if(ptr == NULL) {
printf("Fail alloc SPIRAM\n");
}
return ptr; // return NULL if TRACEABLE_HEAP_CAPS_CALLOC fail
}
void spiram_free(void* ptr) {
heap_caps_free(ptr);
}
so in the hooks the way to handle the memory could be lead to user to choose, or just like a flag in the esp_websocket_client_config_t as:
.memorytouse = 0 (0, internal, 1, external)
I have sent an pull request proposal to the maintainers.