1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-30 03:26:13 +01:00

Update freeMemory.cpp

Add explanatory comment.
This commit is contained in:
Neil McKechnie 2021-03-10 10:33:42 +00:00
parent eb54c78d74
commit 0b3c0bfe9e

View File

@ -50,6 +50,11 @@ static inline int freeMemory() {
// by estimation or inspection, that may be used by other // by estimation or inspection, that may be used by other
// called subroutines. Must be called with interrupts disabled. // called subroutines. Must be called with interrupts disabled.
// //
// Although __brkval may go up and down as heap memory is allocated
// and freed, this function records only the worst case encountered.
// So even if all of the heap is freed, the reported minimum free
// memory will not increase.
//
void updateMinimumFreeMemory(unsigned char extraBytes) { void updateMinimumFreeMemory(unsigned char extraBytes) {
int spare = freeMemory()-extraBytes; int spare = freeMemory()-extraBytes;
if (spare < 0) spare = 0; if (spare < 0) spare = 0;