|
|
using | DataPointer = uint8_t * |
| |
|
| | StackAllocator () |
| |
| void | Init (DataPointer data, size_t bytes) |
| |
| | StackAllocator (DataPointer data, size_t bytes) |
| |
| DataPointer | GetBase () |
| |
| DataPointer | RawAlloc (size_t bytes, size_t align=1) |
| |
| void | RawFree (uint8_t *ptr) |
| |
| template<typename T , typename... Args> |
| T * | Alloc (Args &&... args) |
| |
| template<typename T , typename... Args> |
| auto | StackAlloc (Args &&... args) |
| |
| template<typename T > |
| void | Free (T *ptr) |
| |
| void | Dump (std::ostream &out) |
| |
§ StackAllocator() [1/2]
| MxEngine::StackAllocator::StackAllocator |
( |
| ) |
|
|
inline |
creates empty stack allocator (nullptr chunk pointer, size = 0)
§ StackAllocator() [2/2]
| MxEngine::StackAllocator::StackAllocator |
( |
DataPointer |
data, |
|
|
size_t |
bytes |
|
) |
| |
|
inline |
constructs stack allocator, assigning it memory chunk
- Parameters
-
| data | begin of memory chunk |
| bytes | size in bytes of memory chunk |
§ Alloc()
template<typename T , typename... Args>
| T* MxEngine::StackAllocator::Alloc |
( |
Args &&... |
args | ) |
|
|
inline |
constructs object of type T in memory and returns pointer to it
- Parameters
-
| args | arguments for object construction |
- Returns
- pointer to unmanaged object
§ Dump()
| void MxEngine::StackAllocator::Dump |
( |
std::ostream & |
out | ) |
|
|
inline |
prints whole memory chunk byte by byte in hex format into stream provided
- Parameters
-
§ Free()
template<typename T >
| void MxEngine::StackAllocator::Free |
( |
T * |
ptr | ) |
|
|
inline |
destroyes object of type T, calling its destructor
- Parameters
-
- Warning
- ptr MUST be a pointer to last allocated object, calling Free on some other object will probably result in crash
§ GetBase()
| DataPointer MxEngine::StackAllocator::GetBase |
( |
| ) |
|
|
inline |
memory chunk getter
- Returns
- pointer to begin of memory chunk
§ Init()
| void MxEngine::StackAllocator::Init |
( |
DataPointer |
data, |
|
|
size_t |
bytes |
|
) |
| |
|
inline |
assigns new memory chunk to stack allocator
- Parameters
-
| data | begin of memory chunk |
| bytes | size in bytes of memory chunk |
§ RawAlloc()
| DataPointer MxEngine::StackAllocator::RawAlloc |
( |
size_t |
bytes, |
|
|
size_t |
align = 1 |
|
) |
| |
|
inline |
returns pointer to raw allocated memory
- Parameters
-
| bytes | minimal requested block size |
| align | minimal alignment of pointer (defaults to 1) |
- Returns
- pointer to memory
§ RawFree()
| void MxEngine::StackAllocator::RawFree |
( |
uint8_t * |
ptr | ) |
|
|
inline |
frees raw allocated memory by pointer to its begin
- Parameters
-
- Warning
- ptr MUST be a pointer to last allocated chunk, calling RawFree on some other chunk will probably result in crash
§ StackAlloc()
template<typename T , typename... Args>
| auto MxEngine::StackAllocator::StackAlloc |
( |
Args &&... |
args | ) |
|
|
inline |
constructs object of type T
- Parameters
-
| args | arguments for object construction |
- Returns
- smart pointer to object with custom deleter
- Warning
- you should NOT change order of destruction of allocated objects (by moving them, for example) in any way, as it will probably results in crash
The documentation for this class was generated from the following file: