mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-11 23:21:25 +00:00
21 lines
396 B
C++
21 lines
396 B
C++
![]() |
#include "SimpleAllocator.h"
|
||
|
#include "assert.h"
|
||
|
|
||
|
SimpleAllocator::SimpleAllocator() { reset(); }
|
||
|
|
||
|
void *SimpleAllocator::alloc(size_t size)
|
||
|
{
|
||
|
assert(nextFree + size <= sizeof(bytes));
|
||
|
void *res = &bytes[nextFree];
|
||
|
nextFree += size;
|
||
|
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
void SimpleAllocator::reset() { nextFree = 0; }
|
||
|
|
||
|
void *operator new(size_t size, SimpleAllocator &p)
|
||
|
{
|
||
|
return p.alloc(size);
|
||
|
}
|