![]() |
MAGE
v0.171.0
Matthias Advanced Game Engine
|
#include <memory_arena.hpp>
Classes | |
class | Allocator |
Public Member Functions | |
MemoryArena (std::size_t maximum_block_size, std::size_t alignment) | |
MemoryArena (const MemoryArena &arena)=delete | |
MemoryArena (MemoryArena &&arena) | |
~MemoryArena () | |
MemoryArena & | operator= (const MemoryArena &arena)=delete |
MemoryArena & | operator= (MemoryArena &&arena)=delete |
std::size_t | GetAlignment () const noexcept |
std::size_t | GetMaximumBlockSize () const noexcept |
std::size_t | GetCurrentBlockSize () const noexcept |
std::size_t | GetTotalBlockSize () const noexcept |
void * | GetCurrentBlockPtr () const noexcept |
void | Reset () |
void * | Alloc (std::size_t size) |
template<typename T > | |
T * | AllocData (std::size_t count=1u, bool initialization=false) |
template<typename T > | |
Allocator< T > | GetAllocator () noexcept |
Private Types | |
using | MemoryBlock = std::pair< std::size_t, U8 *> |
Private Attributes | |
const std::size_t | m_alignment |
const std::size_t | m_maximum_block_size |
MemoryBlock | m_current_block |
std::size_t | m_current_block_pos |
std::list< MemoryBlock > | m_used_blocks |
std::list< MemoryBlock > | m_available_blocks |
A class of memory arenas.
|
private |
A type definition for a memory block.
|
explicit |
Constructs a memory arena with the given block size.
[in] | maximum_block_size | The maximum block size in bytes. |
[in] | alignment | The alignment in bytes. |
|
delete |
Constructs a memory arena from the given memory arena.
[in] | arena | A reference to the memory arena to copy. |
|
default |
Constructs a memory arena by moving the given memory arena.
[in] | arena | A reference to the memory arena to move. |
mage::MemoryArena::~MemoryArena | ( | ) |
Destructs this memory arena.
void * mage::MemoryArena::Alloc | ( | std::size_t | size | ) |
Allocates a block of memory of the given size on this memory arena.
[in] | size | The requested size in bytes to allocate in memory. |
nullptr
if the allocation failed. T* mage::MemoryArena::AllocData | ( | std::size_t | count = 1u , |
bool | initialization = false |
||
) |
Allocates a block of memory on this memory arena.
T | The data type. |
[in] | count | The number of objects of type T to allocate in memory. |
[in] | initialization | Flag indicating whether the objects need to be initialized (i.e. the constructor needs to be called). |
nullptr
if the allocation failed.
|
noexcept |
Returns the alignment of this memory arena.
|
noexcept |
Returns an allocator for this memory arena.
T | The data type of the allocator. |
|
noexcept |
Returns a pointer to the current block of this memory arena.
|
noexcept |
Returns the block size (in bytes) of the current block of this memory arena.
|
noexcept |
Returns the maximum block size of this memory arena.
|
noexcept |
Returns the block size (in bytes) of all blocks of this memory arena.
|
delete |
Copies the given memory arena to this memory arena.
[in] | arena | A reference to the memory arena to copy. |
|
delete |
Moves the given memory arena to this memory arena.
[in] | arena | A reference to the memory arena to move. |
void mage::MemoryArena::Reset | ( | ) |
Resets this memory arena.
|
private |
The alignment in bytes of this memory arena.
|
private |
A collection containing the available blocks of this memory arena.
|
private |
The current block of this memory arena.
|
private |
The current block position of this memory arena.
|
private |
The maximum block size in bytes of this memory arena.
|
private |
A collection containing the used blocks of this memory arena.