File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 72
72
static int totalBytesProvidedBySBRK = 0 ;
73
73
#endif
74
74
extern char _end ; // Defined in the linker script
75
- static int heapBytesRemaining = configTOTAL_HEAP_SIZE ; // that's (&__HeapLimit)-(&__HeapBase)
75
+ static int heapBytesRemaining = -1 ; // configTOTAL_HEAP_SIZE is not constant will be init later
76
76
77
77
//! sbrk/_sbrk version supporting reentrant newlib (depends upon above symbols defined by linker control file).
78
78
char * sbrk (int incr ) {
79
79
static char * currentHeapEnd = & _end ;
80
80
vTaskSuspendAll (); // Note: safe to use before FreeRTOS scheduler started
81
+ if (heapBytesRemaining == -1 ) {
82
+ heapBytesRemaining = configTOTAL_HEAP_SIZE ;
83
+ }
81
84
char * previousHeapEnd = currentHeapEnd ;
82
85
if (currentHeapEnd + incr > & _end + configTOTAL_HEAP_SIZE ) {
83
86
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
@@ -145,6 +148,9 @@ void vPortFree( void *pv ) PRIVILEGED_FUNCTION {
145
148
146
149
size_t xPortGetFreeHeapSize ( void ) PRIVILEGED_FUNCTION {
147
150
struct mallinfo mi = mallinfo ();
151
+ if (heapBytesRemaining == -1 ) {
152
+ heapBytesRemaining = configTOTAL_HEAP_SIZE ;
153
+ }
148
154
return mi .fordblks + heapBytesRemaining ;
149
155
}
150
156
You can’t perform that action at this time.
0 commit comments