|
cppcore
A small, portable C++ core library
|
A simple scratch allocator. More...
#include <TScratchAllocator.h>
Public Member Functions | |
| TScratchAllocator ()=default | |
| The default class constructor. | |
| TScratchAllocator (size_t numItems) | |
| The class constructor with the pool size. | |
| ~TScratchAllocator () | |
| The class destructor. | |
| T * | alloc (size_t numItems) |
| Will allocate the number of items. | |
| void | reserve (size_t size) |
| Will reserve the pool. | |
| void | clear () |
| Will clear the pool, memory will be deallocated. | |
| size_t | capacity () const |
| Returns the capacity of items in the pool allocator. | |
| size_t | reservedMem () const |
| Will return the reserved memory in bytes. | |
| size_t | freeMem () const |
| Will return the free memory in the pool in bytes. | |
A simple scratch allocator.
You can use it to manage all the dynamic allocations without caring about cleaning it up. All Allocations will be a one-shot alloc, which do not need to get released. When calling clear all allocation will be invalidated and cannot be used anymore.
Definition at line 42 of file TScratchAllocator.h.
|
default |
The default class constructor.
|
inlineexplicit |
The class constructor with the pool size.
| [in] | numItems | The buffer size. |
Definition at line 89 of file TScratchAllocator.h.
References reserve().
|
inline |
|
inline |
Will allocate the number of items.
| [in] | numItems | The number of items. |
Definition at line 99 of file TScratchAllocator.h.
|
inline |
Returns the capacity of items in the pool allocator.
Definition at line 138 of file TScratchAllocator.h.
|
inline |
Will clear the pool, memory will be deallocated.
Definition at line 131 of file TScratchAllocator.h.
Referenced by reserve(), and ~TScratchAllocator().
|
inline |
Will return the free memory in the pool in bytes.
Definition at line 148 of file TScratchAllocator.h.
| void cppcore::TScratchAllocator< T >::reserve | ( | size_t | size | ) |
Will reserve the pool.
@apram[in] size The pool size to reserve.
Definition at line 123 of file TScratchAllocator.h.
References clear().
Referenced by TScratchAllocator().
|
inline |
Will return the reserved memory in bytes.
Definition at line 143 of file TScratchAllocator.h.