FreeRTOS: use more specific std::algorithm instead of std::foreach

main
Reinhold Gschweicher 2023-05-03 20:42:23 +07:00
parent c2488a2d28
commit d67a74dd15
1 changed files with 5 additions and 4 deletions

@ -1,5 +1,5 @@
#include "FreeRTOS.h"
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <stdio.h>
#include <stdlib.h>
@ -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(), [&currentSize](const std::pair<void*, size_t>& item){
currentSize += item.second;
const size_t currentSize = std::accumulate(
allocatedMemory.begin(), allocatedMemory.end(), 0,
[](const size_t lhs, const std::pair<void*, size_t>& item){
return lhs + item.second;
});
currentFreeHeap = configTOTAL_HEAP_SIZE - currentSize;