Skip to content

Commit 1715641

Browse files
committed
Use thread-safe memory manager using C runtime (Newlib)
By default, the heap_useNewlib.c will be used. As suggested by @ppescher, use -1 as the number of heap implementations might grow in future versions. Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 37cc3a0 commit 1715641

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/FreeRTOSConfig_Default.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@
8484
*----------------------------------------------------------*/
8585

8686
/* Begin custom definitions for STM32 */
87-
/* Default (3) Memory allocation implementations (heap_[1-5].c) */
87+
/* Define memory allocation implementations to use:
88+
* 1 to 5 for heap_[1-5].c
89+
* -1 for heap_useNewlib.c
90+
* Default -1 see heap.c
91+
*/
8892
/*#define configMEMMANG_HEAP_NB 3*/
8993
/* End custom definitions for STM32 */
9094

src/heap.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @file heap.c
33
* @author Frederic Pillon <[email protected]> for STMicroelectronics.
44
* @brief Provide Memory allocation implementations included in the FreeRTOS source
5+
* heap_useNewlib - thread-safe memory manager using C runtime (Newlib)
56
* heap_1 - the very simplest, does not permit memory to be freed
67
* heap_2 - permits memory to be freed, but not does coalescence adjacent free blocks.
78
* heap_3 - simply wraps the standard malloc() and free() for thread safety
@@ -11,10 +12,12 @@
1112
#include "FreeRTOS.h"
1213

1314
#ifndef configMEMMANG_HEAP_NB
14-
#define configMEMMANG_HEAP_NB 3
15+
#define configMEMMANG_HEAP_NB -1
1516
#endif
1617

17-
#if (configMEMMANG_HEAP_NB == 1)
18+
#if (configMEMMANG_HEAP_NB == -1)
19+
#include "../portable/MemMang/heap_useNewlib.c"
20+
#elif (configMEMMANG_HEAP_NB == 1)
1821
#include "../portable/MemMang/heap_1.c"
1922
#elif (configMEMMANG_HEAP_NB == 2)
2023
#include "../portable/MemMang/heap_2.c"

0 commit comments

Comments
 (0)