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>

List of all members.

Public Member Functions

 GHeap (size_t nMinBlockSize)
virtual ~GHeap ()
char * add (const char *szString)
 Allocate space in the heap and copy a string to it. Returns a pointer to the string.
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.
char * allocate (size_t nLength)
 Allocate space in the heap and return a pointer to it.
char * allocAligned (size_t nLength)
 Allocate space in the heap and return a pointer to it.

Protected Attributes

char * m_pCurrentBlock
size_t m_nMinBlockSize
size_t m_nCurrentPos

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]
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.

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

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


Member Data Documentation

size_t GClasses::GHeap::m_nCurrentPos [protected]