FreeRTOS: use more specific std::algorithm instead of std::foreach
This commit is contained in:
parent
c2488a2d28
commit
d67a74dd15
1 changed files with 5 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include <algorithm>
|
#include <numeric>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -20,9 +20,10 @@ void *pvPortMalloc( size_t xWantedSize ) {
|
||||||
void* ptr = malloc(xWantedSize);
|
void* ptr = malloc(xWantedSize);
|
||||||
allocatedMemory[ptr] = xWantedSize;
|
allocatedMemory[ptr] = xWantedSize;
|
||||||
|
|
||||||
size_t currentSize = 0;
|
const size_t currentSize = std::accumulate(
|
||||||
std::for_each(allocatedMemory.begin(), allocatedMemory.end(), [¤tSize](const std::pair<void*, size_t>& item){
|
allocatedMemory.begin(), allocatedMemory.end(), 0,
|
||||||
currentSize += item.second;
|
[](const size_t lhs, const std::pair<void*, size_t>& item){
|
||||||
|
return lhs + item.second;
|
||||||
});
|
});
|
||||||
|
|
||||||
currentFreeHeap = configTOTAL_HEAP_SIZE - currentSize;
|
currentFreeHeap = configTOTAL_HEAP_SIZE - currentSize;
|
||||||
|
|
Loading…
Reference in a new issue