Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 37cc3a0

Browse filesBrowse files
committed
Update Newlib heap implementation
Use STM32 linker and FreeRTOS config definitions. Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent 915c7e0 commit 37cc3a0
Copy full SHA for 37cc3a0

File tree

Expand file treeCollapse file tree

1 file changed

+5
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-5
lines changed

‎portable/MemMang/heap_useNewlib.c

Copy file name to clipboardExpand all lines: portable/MemMang/heap_useNewlib.c
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#warning "This wrapper was verified for newlib version 2.5.0; please ensure newlib's external requirements for malloc-family are unchanged!"
5858
#endif
5959

60-
#include "freeRTOS.h" // defines public interface we're implementing here
60+
#include "FreeRTOS.h" // defines public interface we're implementing here
6161
#if !defined(configUSE_NEWLIB_REENTRANT) || (configUSE_NEWLIB_REENTRANT!=1)
6262
#warning "#define configUSE_NEWLIB_REENTRANT 1 // Required for thread-safety of newlib sprintf, strtok, etc..."
6363
// If you're *really* sure you don't need FreeRTOS's newlib reentrancy support, remove this warning...
@@ -71,15 +71,15 @@
7171
#ifndef NDEBUG
7272
static int totalBytesProvidedBySBRK = 0;
7373
#endif
74-
extern char __HeapBase, __HeapLimit, HEAP_SIZE; // make sure to define these symbols in linker command file
75-
static int heapBytesRemaining = (int)&HEAP_SIZE; // that's (&__HeapLimit)-(&__HeapBase)
74+
extern char _end; // Defined in the linker script
75+
static int heapBytesRemaining = configTOTAL_HEAP_SIZE; // that's (&__HeapLimit)-(&__HeapBase)
7676

7777
//! sbrk/_sbrk version supporting reentrant newlib (depends upon above symbols defined by linker control file).
7878
char * sbrk(int incr) {
79-
static char *currentHeapEnd = &__HeapBase;
79+
static char *currentHeapEnd = &_end;
8080
vTaskSuspendAll(); // Note: safe to use before FreeRTOS scheduler started
8181
char *previousHeapEnd = currentHeapEnd;
82-
if (currentHeapEnd + incr > &__HeapLimit) {
82+
if (currentHeapEnd + incr > &_end + configTOTAL_HEAP_SIZE) {
8383
#if( configUSE_MALLOC_FAILED_HOOK == 1 )
8484
{
8585
extern void vApplicationMallocFailedHook( void );

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.