"L. Spiro Engine"
Public Member Functions | Protected Attributes | Static Protected Attributes

lstl::CAllocator Class Reference

Basic allocation methods. More...

#include <LSTLAllocator.h>

List of all members.

Public Member Functions

virtual LSVOID *LSE_CALL Alloc (LSUINTPTR _uiptrSize)
virtual LSVOID *LSE_CALL ReAlloc (LSVOID *_pvAddr, LSUINTPTR _uiptrSize)
virtual LSVOID LSE_CALL Free (LSVOID *_pvAddr)
LSVOID LSE_CALL SetAllocator (CStdAllocator *_psaAllocator)
CStdAllocator *LSE_CALL GetAllocator ()
const CStdAllocator *LSE_CALL GetAllocator () const
LSVOID LSE_CALL Trash ()

Protected Attributes

CStdAllocator * m_psaAllocator
LSUINT32 m_ui32TotalAllocs

Static Protected Attributes

static LSUINT32 m_ui32AllocCount
static LSUINT32 m_ui32ObjCount
static CCriticalSection * m_pcsCrit

Detailed Description

Basic allocation methods.

Class CAllocator Description: Provide a base interface for allocation. All objects in this library use this when they want to allocate RAM. Inherit from this and modify the Alloc, ReAlloc, and Free functions, then pass your class to the templates in this library to make them use your allocation methods instead.


Member Function Documentation

virtual LSVOID* LSE_CALL lstl::CAllocator::Alloc ( LSUINTPTR  _uiptrSize) [virtual]

Allocate.

Parameters:
_uiptrSizeNumber of bytes to allocate.
Returns:
Returns the allocated bytes or NULL on failure.
virtual LSVOID LSE_CALL lstl::CAllocator::Free ( LSVOID *  _pvAddr) [virtual]

Free memory previously allocated with Alloc() or ReAlloc().

Parameters:
_pvAddrThe address to free or NULL.
CStdAllocator* LSE_CALL lstl::CAllocator::GetAllocator ( )

Get the allocator used by this object.

Returns:
Returns the allocator used by this object.
const CStdAllocator* LSE_CALL lstl::CAllocator::GetAllocator ( ) const

Get the allocator used by this object.

Returns:
Returns the allocator used by this object.
virtual LSVOID* LSE_CALL lstl::CAllocator::ReAlloc ( LSVOID *  _pvAddr,
LSUINTPTR  _uiptrSize 
) [virtual]

Reallocate memory.

Parameters:
_pvAddrThe address whose allocation size is to be changed. If NULL, this behaves exactly the same way as Alloc().
_uiptrSizeThe new size of the allocated data.
Returns:
Returns the reallocated pointer or NULL on failure. Upon failure, the original data is not modified and _pvAddr remains valid.
LSVOID LSE_CALL lstl::CAllocator::SetAllocator ( CStdAllocator *  _psaAllocator)

Set the allocator we use.

Parameters:
_psaAllocatorThe allocator to be used by this object.
LSVOID LSE_CALL lstl::CAllocator::Trash ( )

Trash this allocator. Assumes a special heap has been assigned to this allocator and that heap is about to be trashed.


Member Data Documentation

CCriticalSection* lstl::CAllocator::m_pcsCrit [static, protected]

Thread safety.

CStdAllocator* lstl::CAllocator::m_psaAllocator [protected]

The base allocator.

LSUINT32 lstl::CAllocator::m_ui32AllocCount [static, protected]

Allocation count. Very simple counter that increases with each allocation and decreases with each release. If not 0 at the end of the game's life, something was leaked or over-deallocated.

LSUINT32 lstl::CAllocator::m_ui32ObjCount [static, protected]

Class counter. Keeps track of the number of this object in existance. When this reaches 0, m_ui32AllocCount is checked for being 0UL. If not, debug information is printed.

The number of allocations we have made.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator