@@ -146,8 +146,8 @@ extern "C" {
146146 *
147147 * Support debug wrappers that need to include handling poison
148148 */
149- #define UMM_MALLOC_FL ( s,f,l,c ) umm_poison_malloc(s)
150- #define UMM_CALLOC_FL (n,s,f,l,c ) umm_poison_calloc(n,s)
149+ #define UMM_MALLOC ( s ) umm_poison_malloc(s)
150+ #define UMM_CALLOC (n,s ) umm_poison_calloc(n,s)
151151#define UMM_REALLOC_FL (p,s,f,l,c ) umm_poison_realloc_flc(p,s,f,l,c)
152152#define UMM_FREE_FL (p,f,l,c ) umm_poison_free_flc(p,f,l,c)
153153#define ENABLE_THICK_DEBUG_WRAPPERS
@@ -161,19 +161,19 @@ extern "C" {
161161 *
162162 * Support debug wrappers that need to include handling poison
163163 */
164- #define UMM_MALLOC_FL ( s,f,l,c ) umm_poison_malloc(s)
165- #define UMM_CALLOC_FL (n,s,f,l,c ) umm_poison_calloc(n,s)
164+ #define UMM_MALLOC ( s ) umm_poison_malloc(s)
165+ #define UMM_CALLOC (n,s ) umm_poison_calloc(n,s)
166166#define UMM_REALLOC_FL (p,s,f,l,c ) umm_poison_realloc(p,s)
167167#define UMM_FREE_FL (p,f,l,c ) umm_poison_free(p)
168168#define ENABLE_THICK_DEBUG_WRAPPERS
169169
170170#undef realloc
171171#undef free
172172
173- #elif defined(DEBUG_ESP_OOM) || defined(UMM_INTEGRITY_CHECK) || defined(DEBUG_ESP_WITHINISR) || defined(HEAP_DEBUG_PROBE_PSFLC_CB)
173+ #elif defined(DEBUG_ESP_OOM) || defined(UMM_INTEGRITY_CHECK) || defined(DEBUG_ESP_WITHINISR)
174174// All other debug wrappers that do not require handling poison
175- #define UMM_MALLOC_FL ( s,f,l,c ) umm_malloc(s)
176- #define UMM_CALLOC_FL (n,s,f,l,c ) umm_calloc(n,s)
175+ #define UMM_MALLOC ( s ) umm_malloc(s)
176+ #define UMM_CALLOC (n,s ) umm_calloc(n,s)
177177#define UMM_REALLOC_FL (p,s,f,l,c ) umm_realloc(p,s)
178178#define UMM_FREE_FL (p,f,l,c ) umm_free(p)
179179#define ENABLE_THICK_DEBUG_WRAPPERS
@@ -241,19 +241,19 @@ extern "C" {
241241// always track last failed caller and size requested
242242#if defined(DEBUG_ESP_OOM)
243243struct umm_last_fail_alloc {
244- const void *addr;
245- size_t size;
246- const char *file;
247- int line;
248- } _umm_last_fail_alloc = { NULL , 0 , NULL , 0 } ;
244+ const void *addr = { nullptr } ;
245+ size_t size = { 0 } ;
246+ const char *file = { nullptr } ;
247+ int line = { 0 } ;
248+ } _umm_last_fail_alloc;
249249
250250#else
251251// Note for the least used case "(defined(__cpp_exceptions) &&
252252// !defined(DEBUG_ESP_OOM))", we only capture details for LIBC calls.
253253struct umm_last_fail_alloc {
254- const void *addr;
255- size_t size;
256- } _umm_last_fail_alloc = { NULL , 0 } ;
254+ const void *addr = { nullptr } ;
255+ size_t size = { 0 } ;
256+ } _umm_last_fail_alloc;
257257#endif
258258
259259
@@ -314,7 +314,7 @@ static bool IRAM_ATTR oom_check__log_last_fail_atomic_psflc(void *ptr, size_t si
314314 return true ;
315315}
316316#define OOM_CHECK__LOG_LAST_FAIL_FL (p, s, f, l, c ) oom_check__log_last_fail_atomic_psflc(p, s, f, l, c)
317- #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, f, l, c ) ({ (void )p, ( void )s, ( void )f ; (void )l ; (void )c; true ; })
317+ #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, c ) ({ (void )p; (void )s ; (void )c; true ; })
318318
319319#elif defined(ENABLE_THICK_DEBUG_WRAPPERS)
320320static bool IRAM_ATTR oom_check__log_last_fail_atomic_psc (void *ptr, size_t size, const void * caller) {
@@ -329,7 +329,7 @@ static bool IRAM_ATTR oom_check__log_last_fail_atomic_psc(void *ptr, size_t size
329329 return true ;
330330}
331331#define OOM_CHECK__LOG_LAST_FAIL_FL (p, s, f, l, c ) oom_check__log_last_fail_atomic_psc(p, s, c)
332- #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, f, l, c ) ({ (void )p, ( void )s, ( void )f ; (void )l ; (void )c; true ; })
332+ #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, c ) ({ (void )p; (void )s ; (void )c; true ; })
333333
334334#else
335335// At this location, the macro is only used by Heap API families "new" and
@@ -344,8 +344,8 @@ static bool oom_check__log_last_fail_psc(void *ptr, size_t size, const void* cal
344344 return true ;
345345}
346346// Used to capture minumum OOM info for "new" and LIBC
347- #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, f, l, c ) oom_check__log_last_fail_psc(p, s, c)
348- #define OOM_CHECK__LOG_LAST_FAIL_FL (p, s, f, l, c ) ({ (void )p, ( void )s, ( void )f ; (void )l ; (void )c; true ; })
347+ #define OOM_CHECK__LOG_LAST_FAIL_LITE_FL (p, s, c ) oom_check__log_last_fail_psc(p, s, c)
348+ #define OOM_CHECK__LOG_LAST_FAIL_FL (p, s, c ) ({ (void )p; (void )s ; (void )c; true ; })
349349#endif
350350
351351
@@ -398,26 +398,26 @@ static void isr_check__flash_not_safe(const void *caller) {
398398// * "fancy macros" that call heap_pvPortMalloc, ...
399399// * Fallback for uncapture malloc API calls, malloc, ...
400400//
401- void * IRAM_ATTR _heap_pvPortMalloc (size_t size, const char * file, int line, const void * caller)
401+ void * IRAM_ATTR _heap_pvPortMalloc (size_t size, const char * file, int line, const void * caller)
402402{
403403 INTEGRITY_CHECK__PANIC_FL (file, line, caller);
404404 POISON_CHECK__PANIC_FL (file, line, caller);
405- void * ret = UMM_MALLOC_FL (size, file, line, caller );
405+ void * ret = UMM_MALLOC (size);
406406 OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, file, line, caller);
407407 return ret;
408408}
409409
410- void * IRAM_ATTR _heap_pvPortCalloc (size_t count, size_t size, const char * file, int line, const void * caller)
410+ void * IRAM_ATTR _heap_pvPortCalloc (size_t count, size_t size, const char * file, int line, const void * caller)
411411{
412412 INTEGRITY_CHECK__PANIC_FL (file, line, caller);
413413 POISON_CHECK__PANIC_FL (file, line, caller);
414414 size_t total_size = umm_umul_sat (count, size);
415- void * ret = UMM_CALLOC_FL (1 , total_size, file, line, caller );
415+ void * ret = UMM_CALLOC (1 , total_size);
416416 OOM_CHECK__LOG_LAST_FAIL_FL (ret, total_size, file, line, caller);
417417 return ret;
418418}
419419
420- void * IRAM_ATTR _heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line, const void * caller)
420+ void * IRAM_ATTR _heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line, const void * caller)
421421{
422422 INTEGRITY_CHECK__PANIC_FL (file, line, caller);
423423 POISON_CHECK__PANIC_FL (file, line, caller);
@@ -426,7 +426,7 @@ void* IRAM_ATTR _heap_pvPortRealloc(void *ptr, size_t size, const char* file, in
426426 return ret;
427427}
428428
429- void IRAM_ATTR _heap_vPortFree (void * ptr, const char * file, int line, [[maybe_unused]] const void * caller)
429+ void IRAM_ATTR _heap_vPortFree (void * ptr, const char * file, int line, [[maybe_unused]] const void * caller)
430430{
431431 INTEGRITY_CHECK__PANIC_FL (file, line, caller);
432432 POISON_CHECK__PANIC_FL (file, line, caller);
@@ -448,12 +448,12 @@ void* IRAM_ATTR heap_pvPortCalloc(size_t count, size_t size, const char* file, i
448448 return _heap_pvPortCalloc (count, size, file, line, __builtin_return_address (0 ));
449449}
450450
451- void * IRAM_ATTR heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line)
451+ void * IRAM_ATTR heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line)
452452{
453453 return _heap_pvPortRealloc (ptr, size, file, line, __builtin_return_address (0 ));
454454}
455455
456- void IRAM_ATTR heap_vPortFree (void * ptr, const char * file, int line)
456+ void IRAM_ATTR heap_vPortFree (void * ptr, const char * file, int line)
457457{
458458 return _heap_vPortFree (ptr, file, line, __builtin_return_address (0 ));
459459}
@@ -489,7 +489,7 @@ void IRAM_ATTR free(void* ptr)
489489#define STATIC_ALWAYS_INLINE static ALWAYS_INLINE
490490
491491STATIC_ALWAYS_INLINE
492- void * IRAM_ATTR _heap_pvPortMalloc (size_t size, const char * file, int line, const void * caller)
492+ void * IRAM_ATTR _heap_pvPortMalloc (size_t size, const char * file, int line, const void * caller)
493493{
494494 (void )file;
495495 (void )line;
@@ -498,7 +498,7 @@ void* IRAM_ATTR _heap_pvPortMalloc(size_t size, const char* file, int line, cons
498498}
499499
500500STATIC_ALWAYS_INLINE
501- void * IRAM_ATTR _heap_pvPortCalloc (size_t count, size_t size, const char * file, int line, const void * caller)
501+ void * IRAM_ATTR _heap_pvPortCalloc (size_t count, size_t size, const char * file, int line, const void * caller)
502502{
503503 (void )file;
504504 (void )line;
@@ -507,7 +507,7 @@ void* IRAM_ATTR _heap_pvPortCalloc(size_t count, size_t size, const char* file,
507507}
508508
509509STATIC_ALWAYS_INLINE
510- void * IRAM_ATTR _heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line, const void * caller)
510+ void * IRAM_ATTR _heap_pvPortRealloc (void * ptr, size_t size, const char * file, int line, const void * caller)
511511{
512512 (void )file;
513513 (void )line;
@@ -516,7 +516,7 @@ void* IRAM_ATTR _heap_pvPortRealloc(void *ptr, size_t size, const char* file, in
516516}
517517
518518STATIC_ALWAYS_INLINE
519- void IRAM_ATTR _heap_vPortFree (void * ptr, const char * file, int line, const void * caller)
519+ void IRAM_ATTR _heap_vPortFree (void * ptr, const char * file, int line, const void * caller)
520520{
521521 (void )file;
522522 (void )line;
@@ -532,37 +532,37 @@ void IRAM_ATTR _heap_vPortFree(void *ptr, const char* file, int line, const void
532532void * _malloc_r (struct _reent * unused, size_t size)
533533{
534534 (void ) unused;
535- void * caller = __builtin_return_address (0 );
535+ void * caller = __builtin_return_address (0 );
536536 ISR_CHECK__LOG_NOT_SAFE (caller);
537537 void * ret = _heap_pvPortMalloc (size, NULL , 0 , caller);
538- OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, NULL , 0 , caller);
538+ OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, caller);
539539 return ret;
540540}
541541
542542void * _calloc_r (struct _reent * unused, size_t count, size_t size)
543543{
544544 (void ) unused;
545- void * caller = __builtin_return_address (0 );
545+ void * caller = __builtin_return_address (0 );
546546 ISR_CHECK__LOG_NOT_SAFE (caller);
547547 void * ret = _heap_pvPortCalloc (count, size, NULL , 0 , caller);
548- OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, NULL , 0 , caller);
548+ OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, caller);
549549 return ret;
550550}
551551
552552void * _realloc_r (struct _reent * unused, void * ptr, size_t size)
553553{
554554 (void ) unused;
555- void * caller = __builtin_return_address (0 );
555+ void * caller = __builtin_return_address (0 );
556556 ISR_CHECK__LOG_NOT_SAFE (caller);
557557 void * ret = _heap_pvPortRealloc (ptr, size, NULL , 0 , caller);
558- OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, NULL , 0 , caller);
558+ OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, caller);
559559 return ret;
560560}
561561
562562void _free_r (struct _reent * unused, void * ptr)
563563{
564564 (void ) unused;
565- void * caller = __builtin_return_address (0 );
565+ void * caller = __builtin_return_address (0 );
566566 ISR_CHECK__LOG_NOT_SAFE (caller);
567567 _heap_vPortFree (ptr, NULL , 0 , caller);
568568}
@@ -590,7 +590,7 @@ void* IRAM_ATTR pvPortCalloc(size_t count, size_t size, const char* file, int li
590590 return _heap_pvPortCalloc (count, size, file, line, __builtin_return_address (0 ));
591591}
592592
593- void * IRAM_ATTR pvPortRealloc (void * ptr, size_t size, const char * file, int line)
593+ void * IRAM_ATTR pvPortRealloc (void * ptr, size_t size, const char * file, int line)
594594{
595595 HeapSelectDram ephemeral;
596596 return _heap_pvPortRealloc (ptr, size, file, line, __builtin_return_address (0 ));
@@ -602,7 +602,7 @@ void* IRAM_ATTR pvPortZalloc(size_t size, const char* file, int line)
602602 return _heap_pvPortCalloc (1 , size, file, line, __builtin_return_address (0 ));
603603}
604604
605- void IRAM_ATTR vPortFree (void * ptr, const char * file, int line)
605+ void IRAM_ATTR vPortFree (void * ptr, const char * file, int line)
606606{
607607#if defined(UMM_POISON_CHECK) || defined(UMM_INTEGRITY_CHECK)
608608 // While umm_free internally determines the correct heap, UMM_POISON_CHECK
@@ -639,19 +639,16 @@ void system_show_malloc(void)
639639// heap allocator for "new" (ABI) - To support collecting OOM info, always defined
640640void * _heap_abi_malloc (size_t size, bool unhandled, const void * caller)
641641{
642- [[maybe_unused]] const char *file = NULL ;
643- [[maybe_unused]] const int line = 0 ;
644-
645642 #ifdef ENABLE_THICK_DEBUG_WRAPPERS
646643 ISR_CHECK__LOG_NOT_SAFE (caller);
647- INTEGRITY_CHECK__PANIC_FL (file, line , caller);
648- POISON_CHECK__PANIC_FL (file, line , caller);
649- void * ret = UMM_MALLOC_FL (size, file, line, caller );
650- bool ok = OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, file, line , caller);
644+ INTEGRITY_CHECK__PANIC_FL (NULL , 0 , caller);
645+ POISON_CHECK__PANIC_FL (NULL , 0 , caller);
646+ void * ret = UMM_MALLOC (size);
647+ bool ok = OOM_CHECK__LOG_LAST_FAIL_FL (ret, size, NULL , 0 , caller);
651648 #else
652649 void * ret = UMM_MALLOC (size);
653650 // minimum OOM check
654- bool ok = OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, file, line, caller);
651+ bool ok = OOM_CHECK__LOG_LAST_FAIL_LITE_FL (ret, size, caller);
655652 #endif
656653 if (!ok && unhandled) {
657654 __unhandled_exception (PSTR (" OOM" ));
@@ -767,22 +764,22 @@ uint32 IRAM_ATTR user_iram_memory_is_enabled(void)
767764//
768765#include < bits/c++config.h>
769766#include < cstdlib>
770- #include " new"
767+ #include < new>
771768
772769// The sized deletes are defined in other files.
773770#pragma GCC diagnostic ignored "-Wsized-deallocation"
774771
775772// These function replace their weak counterparts tagged with _GLIBCXX_WEAK_DEFINITION
776773void operator delete (void * ptr) noexcept
777774{
778- void * caller = __builtin_return_address (0 );
775+ void * caller = __builtin_return_address (0 );
779776 ISR_CHECK__LOG_NOT_SAFE (caller);
780777 _heap_vPortFree (ptr, NULL , 0 , caller);
781778}
782779
783780void operator delete (void * ptr, std::size_t ) noexcept
784781{
785- void * caller = __builtin_return_address (0 );
782+ void * caller = __builtin_return_address (0 );
786783 ISR_CHECK__LOG_NOT_SAFE (caller);
787784 _heap_vPortFree (ptr, NULL , 0 , caller);
788785}
0 commit comments