#include <FixedPoolAllocator.hpp>
A pool of fixed-size that allocates raw memory in same-sized blocks. All memory managed by the allocator is created at construction and deleted at destruction.
Public Member Functions | |
FixedPoolAllocator ()=default | |
FixedPoolAllocator (const size_t block_size, const uint32_t max_blocks) | |
FixedPoolAllocator (const FixedPoolAllocator &other)=delete | |
FixedPoolAllocator & | operator= (const FixedPoolAllocator &other)=delete |
FixedPoolAllocator (FixedPoolAllocator &&other) noexcept | |
FixedPoolAllocator & | operator= (FixedPoolAllocator &&other) noexcept |
~FixedPoolAllocator () | |
void * | allocate () |
Allocates a new block of memory from the pool and returns a pointer to it. More... | |
bool | free (void *data) |
void | reset () |
Resets the pool and zeroes out all memory. More... | |
uint32_t | block_capacity () |
Gets the maximum number of blocks the pool can allocate. More... | |
uint32_t | blocks_initialized () |
Gets the current number of blocks allocated. More... | |
|
default |
|
inline |
Initializes the allocator with block_size
bytes allocated per memory block and max_blocks
number of blocks capacity
|
delete |
|
inlinenoexcept |
|
inline |
|
inline |
Allocates a new block of memory from the pool and returns a pointer to it.
|
inline |
Gets the maximum number of blocks the pool can allocate.
|
inline |
Gets the current number of blocks allocated.
|
inline |
Frees memory allocated by allocate()
. If the data wasn't allocated by the internal pool, this function causes undefined behaviour and will log an error
|
delete |
|
inlinenoexcept |
|
inline |
Resets the pool and zeroes out all memory.