@@ -72,11 +72,13 @@ long atol(const char *s);
72
72
unsigned long os_random (void );
73
73
int os_get_random (unsigned char * buf , size_t len );
74
74
75
+ #ifndef os_printf
75
76
/* NOTE: don't use printf_opt in irq handler, for test */
76
77
#define os_printf (fmt , ...) do { \
77
78
static const char flash_str[] ICACHE_RODATA_ATTR STORE_ATTR = fmt; \
78
79
printf(flash_str, ##__VA_ARGS__); \
79
80
} while(0)
81
+ #endif
80
82
81
83
/* Note: check_memleak_debug_enable is a weak function inside SDK.
82
84
* please copy following codes to user_main.c.
@@ -90,43 +92,67 @@ bool ICACHE_FLASH_ATTR check_memleak_debug_enable(void)
90
92
91
93
#ifndef MEMLEAK_DEBUG
92
94
#define MEMLEAK_DEBUG_ENABLE 0
95
+ #ifndef os_free
93
96
#define os_free (s ) free(s)
97
+ #endif
98
+
99
+ #ifndef os_malloc
94
100
#define os_malloc (s ) malloc(s)
95
- #define os_calloc (p , s ) calloc(p, s);
101
+ #endif
102
+
103
+ #ifndef os_calloc
104
+ #define os_calloc (p , s ) calloc(p, s)
105
+ #endif
106
+
107
+ #ifndef os_realloc
96
108
#define os_realloc (p , s ) realloc(p, s)
109
+ #endif
110
+
111
+ #ifndef os_zalloc
97
112
#define os_zalloc (s ) zalloc(s)
113
+ #endif
98
114
#else
99
115
#define MEMLEAK_DEBUG_ENABLE 1
100
116
117
+ #ifndef os_free
101
118
#define os_free (s ) \
102
119
do{\
103
120
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
104
121
vPortFree(s, mem_debug_file, __LINE__);\
105
122
}while(0)
123
+ #endif
106
124
125
+ #ifndef os_malloc
107
126
#define os_malloc (s ) \
108
127
({ \
109
128
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
110
129
pvPortMalloc(s, mem_debug_file, __LINE__); \
111
130
})
131
+ #endif
112
132
133
+ #ifndef os_calloc
113
134
#define os_calloc (p , s ) \
114
135
({ \
115
136
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
116
137
pvPortCalloc(p, s, mem_debug_file, __LINE__); \
117
138
})
139
+ #endif
118
140
141
+ #ifndef os_realloc
119
142
#define os_realloc (p , s ) \
120
143
({ \
121
144
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
122
145
pvPortRealloc(p, s, mem_debug_file, __LINE__); \
123
146
})
147
+ #endif
124
148
149
+ #ifndef os_zalloc
125
150
#define os_zalloc (s ) \
126
151
({ \
127
152
static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__; \
128
153
pvPortZalloc(s, mem_debug_file, __LINE__); \
129
154
})
155
+ #endif
130
156
131
157
#endif
132
158
0 commit comments