/* Default memory allocation implementation. Should return standard 8-bit memory. malloc() essentially resolves to this function.  */
IRAM_ATTR void* heap_caps_malloc_default(size_t size)
/* Default memory allocation implementation. Should return standard 8-bit memory. malloc() essentially resolves to this function.  */
IRAM_ATTR void* heap_caps_malloc_default(size_t size)
{
    if (malloc_alwaysinternal_limit==MALLOC_DISABLE_EXTERNAL_ALLOCS) {
        return heap_caps_malloc( size, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL);
    } else {
        void *r;
        if (size <= malloc_alwaysinternal_limit) {
            r=heap_caps_malloc( size, MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL );
        } else {
            r=heap_caps_malloc( size, MALLOC_CAP_DEFAULT | MALLOC_CAP_SPIRAM );
        }
        if (r==NULL) {
            r=heap_caps_malloc( size, MALLOC_CAP_DEFAULT );
        }
        return r;
    }
}