![]() |
Raven Engine v0.1
|
Fixed-size chunk pool allocator. More...
#include <MalevolentAllocator.h>
Public Member Functions | |
| MalevolentAllocator (usize chunkSize, usize chunkCount) | |
| Constructs the allocator with specified chunk size and count. | |
| ~MalevolentAllocator () noexcept | |
| Releases all allocated memory. | |
| void * | Allocate () |
| Allocates one chunk from the pool. | |
| void | Deallocate (void *ptr) |
| Returns a previously allocated chunk to the pool. | |
Fixed-size chunk pool allocator.
Pre-allocates a block of memory divided into chunkCount chunks of chunkSize bytes. Maintains a free list for O(1) Allocate and Deallocate operations.
Implements a simple pool allocator that pre-allocates a contiguous block of memory divided into equal-sized chunks. Allocation and deallocation operate in constant time via a free list. This allocator is useful for fast, repetitive allocations of objects with identical size requirements.
Constructs the allocator with specified chunk size and count.
| chunkSize | Size in bytes of each chunk. |
| chunkCount | Number of chunks to allocate in the pool. |
|
noexcept |
Releases all allocated memory.
| void * Raven::MalevolentAllocator::Allocate | ( | ) |
Allocates one chunk from the pool.
| void Raven::MalevolentAllocator::Deallocate | ( | void * | ptr | ) |
Returns a previously allocated chunk to the pool.
| ptr | Pointer to the memory chunk to deallocate. |