firmware/src/platform/esp32/SimpleAllocator.cpp
Tom Fifield cf392a4c20
Address some FIXME comments (#4435)
* Address some FIXME comments

These comments have since been addressed by more modern code.
Remove them to reduce the clutter in the codebase.

* Remove 'dumb idea' from SimpleAllocator

4 year old code that was set never to run can probably be safely
deleted.
2024-08-11 07:06:38 -05:00

29 lines
484 B
C++

#include "SimpleAllocator.h"
#include "assert.h"
#include "configuration.h"
SimpleAllocator::SimpleAllocator()
{
reset();
}
void *SimpleAllocator::alloc(size_t size)
{
assert(nextFree + size <= sizeof(bytes));
void *res = &bytes[nextFree];
nextFree += size;
LOG_DEBUG("Total simple allocs %u\n", nextFree);
return res;
}
void SimpleAllocator::reset()
{
nextFree = 0;
}
void *operator new(size_t size, SimpleAllocator &p)
{
return p.alloc(size);
}