GClasses
GClasses::GHeap Class Reference

Provides a heap in which to put strings or whatever you need to store. If you need to allocate space for a lot of small objects, it's much more efficient to use this class than the C++ heap. Plus, you can delete them all by simply deleting the heap. You can't, however, reuse the space for individual objects in this heap. More...

#include <GHeap.h>

Public Member Functions

 GHeap (size_t nMinBlockSize)
 
 GHeap (const GHeap &that)
 
virtual ~GHeap ()
 
char * add (const char *szString)
 Allocate space in the heap and copy a string to it. Returns a pointer to the string. More...
 
char * add (const char *pString, size_t nLength)
 Allocate space in the heap and copy a string to it. Returns a pointer to the string. More...
 
char * allocAligned (size_t nLength)
 Allocate space in the heap and return a pointer to it. The returned pointer will be aligned to start at a location divisible by the size of a pointer, so it will be suitable for use with placement new even on architectures that require aligned pointers. More...
 
char * allocate (size_t nLength)
 Allocate space in the heap and return a pointer to it. More...
 
void clear ()
 Deletes all the blocks and frees up memory. More...
 

Protected Attributes

size_t m_nCurrentPos
 
size_t m_nMinBlockSize
 
char * m_pCurrentBlock
 

Detailed Description

Provides a heap in which to put strings or whatever you need to store. If you need to allocate space for a lot of small objects, it's much more efficient to use this class than the C++ heap. Plus, you can delete them all by simply deleting the heap. You can't, however, reuse the space for individual objects in this heap.

Constructor & Destructor Documentation

GClasses::GHeap::GHeap ( size_t  nMinBlockSize)
inline
GClasses::GHeap::GHeap ( const GHeap that)
inline
virtual GClasses::GHeap::~GHeap ( )
virtual

Member Function Documentation

char* GClasses::GHeap::add ( const char *  szString)
inline

Allocate space in the heap and copy a string to it. Returns a pointer to the string.

char* GClasses::GHeap::add ( const char *  pString,
size_t  nLength 
)
inline

Allocate space in the heap and copy a string to it. Returns a pointer to the string.

char* GClasses::GHeap::allocAligned ( size_t  nLength)
inline

Allocate space in the heap and return a pointer to it. The returned pointer will be aligned to start at a location divisible by the size of a pointer, so it will be suitable for use with placement new even on architectures that require aligned pointers.

char* GClasses::GHeap::allocate ( size_t  nLength)
inline

Allocate space in the heap and return a pointer to it.

void GClasses::GHeap::clear ( )

Deletes all the blocks and frees up memory.

Member Data Documentation

size_t GClasses::GHeap::m_nCurrentPos
protected
size_t GClasses::GHeap::m_nMinBlockSize
protected
char* GClasses::GHeap::m_pCurrentBlock
protected