From d67a74dd15cd5bbcf478ebf851f1924c95451028 Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Wed, 3 May 2023 20:42:23 +0200 Subject: [PATCH] FreeRTOS: use more specific std::algorithm instead of std::foreach --- sim/FreeRTOS.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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;