The class provides a fast way of allocating memory in certain limits. More...
#include <dynstack.h>
Public Member Functions | |
DynStack (int sz) | |
constructor; | |
~DynStack (void) | |
destructor; | |
bool | isNull (void) |
tell if the instance is valid or not | |
bool | isEmpty (void) |
tell if the instance is empty or not More... | |
void | reset (void) |
sets the top of the stack to 0 More... | |
void | resetForced (void) |
sets the top of the stack to 0 without checking the free status | |
bool | reinit (int sz) |
reinitialise with a different size More... | |
bool | isInStack (void *ptr) |
tell if the memory chunk was allocated from the internal buffer | |
bool | isDynamic (void *ptr) |
tell if the memory chunk was allocated using malloc | |
void * | alloc (int sz) |
allocate a memory chunk | |
void | release (void *ptr) |
free a memory chunk | |
Protected Member Functions | |
void * | topPointer (void) |
top | |
The class provides a fast way of allocating memory in certain limits.
The class allocates a large chunk of memory in the constructor then it uses a stack based allocator. Both allocating and freeing is very fast provided that the limit was not reached.
For requests that are larger than the buffer standard malloc is used.
|
inline |
tell if the instance is empty or not
This will only check the stack, not dynamic blocks.
bool DynStack::reinit | ( | int | sz | ) |
reinitialise with a different size
This is only allowed if the stack is empty
void DynStack::reset | ( | void | ) |
sets the top of the stack to 0
All the memory that was allocaed is asserted that was freed at this time