diff --git a/.github/lexicon.txt b/.github/lexicon.txt index 3263b0843..718b0b37e 100644 --- a/.github/lexicon.txt +++ b/.github/lexicon.txt @@ -2476,6 +2476,7 @@ vapplicationgetidletaskmemory vapplicationgettimertaskmemory vapplicationidlehook vapplicationirqhandler +vapplicationmallocfailedhook vapplicationsetuptickinterrupt vapplicationsetupticktimerinterrupt vapplicationsetuptimerinterrupt diff --git a/include/portable.h b/include/portable.h index 0feedad68..d0c3b9083 100644 --- a/include/portable.h +++ b/include/portable.h @@ -188,6 +188,19 @@ size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; #define vPortFreeStack vPortFree #endif +#if ( configUSE_MALLOC_FAILED_HOOK == 1 ) + +/** + * task.h + * @code{c} + * void vApplicationMallocFailedHook( void ) + * @endcode + * + * This hook function is called when allocation failed. + */ + void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */ +#endif + /* * Setup the hardware ready for the scheduler to take control. This generally * sets up a tick interrupt and sets timers for the correct tick frequency. diff --git a/portable/MemMang/heap_1.c b/portable/MemMang/heap_1.c index 67825f522..9c7c52315 100644 --- a/portable/MemMang/heap_1.c +++ b/portable/MemMang/heap_1.c @@ -118,7 +118,6 @@ void * pvPortMalloc( size_t xWantedSize ) { if( pvReturn == NULL ) { - extern void vApplicationMallocFailedHook( void ); vApplicationMallocFailedHook(); } } diff --git a/portable/MemMang/heap_2.c b/portable/MemMang/heap_2.c index 163a12edd..0700a0d7a 100644 --- a/portable/MemMang/heap_2.c +++ b/portable/MemMang/heap_2.c @@ -249,7 +249,6 @@ void * pvPortMalloc( size_t xWantedSize ) { if( pvReturn == NULL ) { - extern void vApplicationMallocFailedHook( void ); vApplicationMallocFailedHook(); } } diff --git a/portable/MemMang/heap_3.c b/portable/MemMang/heap_3.c index 6accd48c7..8ed3d1b4f 100644 --- a/portable/MemMang/heap_3.c +++ b/portable/MemMang/heap_3.c @@ -71,7 +71,6 @@ void * pvPortMalloc( size_t xWantedSize ) { if( pvReturn == NULL ) { - extern void vApplicationMallocFailedHook( void ); vApplicationMallocFailedHook(); } } diff --git a/portable/MemMang/heap_4.c b/portable/MemMang/heap_4.c index 33bb81838..90a20c54f 100644 --- a/portable/MemMang/heap_4.c +++ b/portable/MemMang/heap_4.c @@ -269,7 +269,6 @@ void * pvPortMalloc( size_t xWantedSize ) { if( pvReturn == NULL ) { - extern void vApplicationMallocFailedHook( void ); vApplicationMallocFailedHook(); } else diff --git a/portable/MemMang/heap_5.c b/portable/MemMang/heap_5.c index b33043986..4fea255b1 100644 --- a/portable/MemMang/heap_5.c +++ b/portable/MemMang/heap_5.c @@ -279,7 +279,6 @@ void * pvPortMalloc( size_t xWantedSize ) { if( pvReturn == NULL ) { - extern void vApplicationMallocFailedHook( void ); vApplicationMallocFailedHook(); } else