diff --git a/cores/nRF5/freertos/Source/include/portable.h b/cores/nRF5/freertos/Source/include/portable.h index 8aac353e..6d448ae4 100644 --- a/cores/nRF5/freertos/Source/include/portable.h +++ b/cores/nRF5/freertos/Source/include/portable.h @@ -128,6 +128,7 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEG */ void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; void vPortFree( void *pv ) PRIVILEGED_FUNCTION; +void *pvPortRealloc( void* pv, size_t new_size) PRIVILEGED_FUNCTION; // Adafruit TODO remove later void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; diff --git a/cores/nRF5/freertos/Source/portable/MemMang/heap_3.c b/cores/nRF5/freertos/Source/portable/MemMang/heap_3.c index 3455669e..447faa62 100644 --- a/cores/nRF5/freertos/Source/portable/MemMang/heap_3.c +++ b/cores/nRF5/freertos/Source/portable/MemMang/heap_3.c @@ -93,5 +93,28 @@ void vPortFree( void *pv ) } } +void *pvPortRealloc( void* pv, size_t new_size) +{ + void *pvReturn; + + vTaskSuspendAll(); + { + pvReturn = realloc( pv, new_size ); + traceMALLOC( pvReturn, new_size ); + } + ( void ) xTaskResumeAll(); + + #if( configUSE_MALLOC_FAILED_HOOK == 1 ) + { + if( pvReturn == NULL ) + { + extern void vApplicationMallocFailedHook( void ); + vApplicationMallocFailedHook(); + } + } + #endif + + return pvReturn; +} diff --git a/cores/nRF5/rtos.h b/cores/nRF5/rtos.h index 5696b5cf..7eacfc87 100644 --- a/cores/nRF5/rtos.h +++ b/cores/nRF5/rtos.h @@ -83,6 +83,12 @@ static inline void rtos_free( void *pv ) { return (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) ? free(pv) : vPortFree(pv); } + +// TODO used by nffs, removed later +static inline void* rtos_realloc(void* pv, size_t new_size) +{ + return (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) ? realloc(pv, new_size) : pvPortRealloc(pv, new_size); +} #endif #ifdef __cplusplus // Visible only with cplusplus