24 #include "esp_heap_caps.h"
34 void osi_mem_dbg_init(
void);
35 void osi_mem_dbg_record(
void *p,
int size,
const char *func,
int line);
36 void osi_mem_dbg_clean(
void *p,
const char *func,
int line);
37 void osi_mem_dbg_show(
void);
38 uint32_t osi_mem_dbg_get_max_size(
void);
39 uint32_t osi_mem_dbg_get_current_size(
void);
40 void osi_men_dbg_set_section_start(uint8_t index);
41 void osi_men_dbg_set_section_end(uint8_t index);
42 uint32_t osi_mem_dbg_get_max_size_section(uint8_t index);
44 #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
45 #define osi_malloc(size) \
48 p = heap_caps_malloc_prefer(size, 2, \
49 MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \
50 MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
51 osi_mem_dbg_record(p, size, __func__, __LINE__); \
55 #define osi_calloc(size) \
58 p = heap_caps_calloc_prefer(1, size, 2, \
59 MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \
60 MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
61 osi_mem_dbg_record(p, size, __func__, __LINE__); \
67 #define osi_malloc(size) \
71 osi_mem_dbg_record(p, size, __func__, __LINE__); \
75 #define osi_calloc(size) \
78 p = calloc(1, (size)); \
79 osi_mem_dbg_record(p, size, __func__, __LINE__); \
87 #define osi_malloc(size) \
91 #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST \
92 p = heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
96 osi_mem_dbg_record(p, size, __func__, __LINE__); \
100 #define osi_calloc(size) \
104 #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST \
105 p = heap_caps_calloc_prefer(1, size, 2, \
106 MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \
107 MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \
109 p = calloc(1, (size)); \
111 osi_mem_dbg_record(p, size, __func__, __LINE__); \
116 #define osi_free(ptr) \
118 void *tmp_point = (void *)(ptr); \
119 osi_mem_dbg_clean(tmp_point, __func__, __LINE__); \
125 #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
126 #define osi_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
127 #define osi_calloc(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
129 #define osi_malloc(size) malloc((size))
130 #define osi_calloc(size) calloc(1, (size))
132 #define osi_free(p) free((p))
136 #define FREE_AND_RESET(a) \