7
7
#include " umm_malloc/umm_malloc.h"
8
8
#include < c_types.h>
9
9
#include < sys/reent.h>
10
-
10
+ # include < user_interface.h >
11
11
12
12
extern " C" {
13
13
14
- #if defined( UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE)
14
+ #if defined(UMM_POISON_CHECK) || defined(UMM_POISON_CHECK_LITE)
15
15
#define __umm_malloc (s ) umm_poison_malloc(s)
16
16
#define __umm_calloc (n,s ) umm_poison_calloc(n,s)
17
17
#define __umm_realloc_fl (p,s,f,l ) umm_poison_realloc_fl(p,s,f,l)
18
18
#define __umm_free_fl (p,f,l ) umm_poison_free_fl(p,f,l)
19
19
20
- #ifdef UMM_POISON_CHECK_LITE
21
- #define POISON_CHECK__ABORT () do {} while (0 )
22
- #define POISON_CHECK__PANIC_FL (file, line ) do { (void )file; (void )line; } while (0 )
23
-
24
- #else // Full heap poison check at every malloc libary call.
25
- #define POISON_CHECK__ABORT () \
26
- do { \
27
- if ( ! POISON_CHECK () ) \
28
- abort (); \
29
- } while (0 )
20
+ #undef realloc
21
+ #undef free
30
22
31
- #define POISON_CHECK__PANIC_FL (file, line ) \
32
- do { \
33
- if ( ! POISON_CHECK () ) \
34
- __panic_func (file, line, " " ); \
35
- } while (0 )
36
- #endif
23
+ #elif defined(DEBUG_ESP_OOM)
24
+ #define __umm_malloc (s ) umm_malloc(s)
25
+ #define __umm_calloc (n,s ) umm_calloc(n,s)
26
+ #define __umm_realloc_fl (p,s,f,l ) umm_realloc(p,s)
27
+ #define __umm_free_fl (p,f,l ) umm_free(p)
37
28
38
29
#undef realloc
39
30
#undef free
40
31
41
- #else // ! UMM_POISON_CHECK
32
+ #else // ! UMM_POISON_CHECK && ! DEBUG_ESP_OOM
42
33
#define __umm_malloc (s ) malloc(s)
43
34
#define __umm_calloc (n,s ) calloc(n,s)
44
35
#define __umm_realloc_fl (p,s,f,l ) realloc(p,s)
45
36
#define __umm_free_fl (p,f,l ) free(p)
37
+ #endif
46
38
47
- #define POISON_CHECK__ABORT () do {} while (0 )
48
- #define POISON_CHECK__PANIC_FL (file, line ) do { (void )file; (void )line; } while (0 )
49
- #endif // UMM_POISON_CHECK
39
+
40
+ #if defined(UMM_POISON_CHECK)
41
+ #define POISON_CHECK__ABORT () \
42
+ do { \
43
+ if ( ! POISON_CHECK () ) \
44
+ abort (); \
45
+ } while (0 )
46
+
47
+ #define POISON_CHECK__PANIC_FL (file, line ) \
48
+ do { \
49
+ if ( ! POISON_CHECK () ) \
50
+ __panic_func (file, line, " " ); \
51
+ } while (0 )
52
+
53
+ #else // No full heap poison checking.
54
+ #define POISON_CHECK__ABORT () do {} while (0 )
55
+ #define POISON_CHECK__PANIC_FL (file, line ) do { (void )file; (void )line; } while (0 )
56
+ #endif
50
57
51
58
// Debugging helper, last allocation which returned NULL
52
59
void *umm_last_fail_alloc_addr = NULL ;
@@ -109,14 +116,6 @@ void* _calloc_r(struct _reent* unused, size_t count, size_t size)
109
116
return ret;
110
117
}
111
118
112
-
113
- #define PTR_CHECK__LOG_LAST_FAIL (p, s, a ) \
114
- if (0 != (s) && 0 == p)\
115
- {\
116
- umm_last_fail_alloc_addr = a;\
117
- umm_last_fail_alloc_size = s;\
118
- }
119
-
120
119
#ifdef DEBUG_ESP_OOM
121
120
#undef malloc
122
121
#undef calloc
@@ -128,6 +127,8 @@ static const char oom_fmt_2[] PROGMEM STORE_ATTR = ":%d\n";
128
127
129
128
void ICACHE_RAM_ATTR print_loc (size_t size, const char * file, int line)
130
129
{
130
+ (void )size;
131
+ (void )line;
131
132
if (system_get_os_print ()) {
132
133
DBGLOG_FUNCTION_P (oom_fmt_1, (int )size);
133
134
DBGLOG_FUNCTION_P (file);
0 commit comments