Files
lucky-cat/components/platform/third_party/lodepng/lodepng_esp_alloc.cpp
T

33 lines
635 B
C++

#include <stddef.h>
#include <stdlib.h>
#include "esp_heap_caps.h"
#include "soc/soc_caps.h"
void *lodepng_malloc(size_t size)
{
#if SOC_SPIRAM_SUPPORTED
void *ptr = heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
if (ptr != NULL) {
return ptr;
}
#endif
return malloc(size);
}
void *lodepng_realloc(void *ptr, size_t new_size)
{
#if SOC_SPIRAM_SUPPORTED
void *new_ptr = heap_caps_realloc(ptr, new_size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
if (new_ptr != NULL) {
return new_ptr;
}
#endif
return realloc(ptr, new_size);
}
void lodepng_free(void *ptr)
{
free(ptr);
}