diff --git a/sim/FreeRTOS.cpp b/sim/FreeRTOS.cpp index b8bef42..d64e194 100644 --- a/sim/FreeRTOS.cpp +++ b/sim/FreeRTOS.cpp @@ -1,5 +1,5 @@ #include "FreeRTOS.h" -#include +#include #include #include #include @@ -20,9 +20,10 @@ void *pvPortMalloc( size_t xWantedSize ) { void* ptr = malloc(xWantedSize); allocatedMemory[ptr] = xWantedSize; - size_t currentSize = 0; - std::for_each(allocatedMemory.begin(), allocatedMemory.end(), [¤tSize](const std::pair& item){ - currentSize += item.second; + const size_t currentSize = std::accumulate( + allocatedMemory.begin(), allocatedMemory.end(), 0, + [](const size_t lhs, const std::pair& item){ + return lhs + item.second; }); currentFreeHeap = configTOTAL_HEAP_SIZE - currentSize;