libbbb  1.2.1
Groups common code used in some applications and libraries.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
bbb::DynStack Class Reference

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
 

Detailed Description

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.

Member Function Documentation

bool bbb::DynStack::isEmpty ( void  )
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


The documentation for this class was generated from the following files: