"L. Spiro Engine"
Static Public Member Functions

lsa::CMemLib Class Reference

#include <LSAMemLib.h>

List of all members.

Static Public Member Functions

static LSBOOL LSE_CALL Init (LSA_SIZE _sDefaultSize, LSBOOL _bGrowable)
static LSVOID LSE_CALL Destroy ()
static CStdAllocator *LSE_CALL GetAllocatorD (LSA_SIZE _sDefaultSize, LSBOOL _bGrowable)
static LSBOOL LSE_CALL DestroyAllocator (CStdAllocator *_psaAllocator)
static LSVOID *LSE_CALL AllocD (LSA_SIZE _sSize, LSUINT32 _ulAlign=0)
static LSVOID *LSE_CALL CAllocD (LSA_SIZE _sSize, LSUINT32 _ulAlign=0)
static LSBOOL LSE_CALL Free (LSVOID *_pvAddr)
static LSVOID *LSE_CALL ReAllocD (LSVOID *_pvAddr, LSA_SIZE _sSize)
static LSBOOL LSE_CALL Ready ()
static LSVOID LSE_CALL ReleaseEmptyPools ()
static LSUINT32 LSE_CALL GetAllocationCounter ()
static LSA_SIZE LSE_CALL PrintAllocations (LSUINT32 _ui32Count=0UL, LSUINT32 _ui32End=0xFFFFFFFFUL)
static LSA_SIZE LSE_CALL GetTotalAllocatedSize ()
template<class _cType >
static _cType *LSE_CALL New (CStdAllocator *_psaAllocator)
template<class _cType >
static LSVOID LSE_CALL Delete (CStdAllocator *_psaAllocator, _cType *_pcObject)

Detailed Description

Class CMemLib

Description: Initialize the memory manager, then allocate from it.


Member Function Documentation

static LSVOID* LSE_CALL lsa::CMemLib::AllocD ( LSA_SIZE  _sSize,
LSUINT32  _ulAlign = 0 
) [static]

Allocate memory.

Parameters:
_sSizeAmount of memory to allocate.
_ulAlignAlignment. Can be 16 or 32. Any other number is rounded down to one of these values.
Returns:
Returns the allocated memory or NULL if the allocation failed.
static LSVOID* LSE_CALL lsa::CMemLib::CAllocD ( LSA_SIZE  _sSize,
LSUINT32  _ulAlign = 0 
) [static]

Allocate memory, setting the allocated memory to 0's.

Parameters:
_sSizeAmount of memory to allocate.
_ulAlignAlignment. Can be 16 or 32. Any other number is rounded down to one of these values.
Returns:
Returns the allocated memory or NULL if the allocation failed.
template<class _cType >
LSVOID LSE_CALL lsa::CMemLib::Delete ( CStdAllocator *  _psaAllocator,
_cType *  _pcObject 
) [static]

Delete an object using an allocator.

Parameters:
_psaAllocatorThe allocator to use to delete the object.
_pcObjectPointer to the object to delete.
static LSVOID LSE_CALL lsa::CMemLib::Destroy ( ) [static]

Destroy the memory manager. Called once when the game is shutting down.

static LSBOOL LSE_CALL lsa::CMemLib::DestroyAllocator ( CStdAllocator *  _psaAllocator) [static]

Destroy an allocator.

Parameters:
_psaAllocatorThe allocator to destroy.
Returns:
Returns true if the given allocator exists and is destroyed.
static LSBOOL LSE_CALL lsa::CMemLib::Free ( LSVOID *  _pvAddr) [static]

Free memory.

Parameters:
_pvAddrAddress to free.
Returns:
Returns true if the address was allocated by this memory manager.
static LSUINT32 LSE_CALL lsa::CMemLib::GetAllocationCounter ( ) [static]

Get the allocation counter. Used for debugging. If LSA_DEBUG is not defined, this always returns 0. This does not return the actual number of allocations. It returns the unique allocation count to be assigned to the next allocation.

Returns:
Returns the allocation counter, or 0UL if LSA_DEBUG is not defined.
static CStdAllocator* LSE_CALL lsa::CMemLib::GetAllocatorD ( LSA_SIZE  _sDefaultSize,
LSBOOL  _bGrowable 
) [static]

Get an allocator from the memory manager. Having an extra allocator is like another pool of memory from which you can allocate memory. It is not necessary to use the memory manager.

Parameters:
_sDefaultSizeThe default size of the heap.
_bGrowableWhether the heap can grow.
Returns:
Returns a pointer to the new allocator or NULL if not enough memory exists to create an allocator.
static LSA_SIZE LSE_CALL lsa::CMemLib::GetTotalAllocatedSize ( ) [static]

Get the total amount of RAM allocated from the main heap. This is the amount of RAM that the main heap has allocated from the system for its own use, and includes the RAM that it gives to the application upon allocation requests.

Returns:
Returns the total amount of RAM allocated by the main heap.
static LSBOOL LSE_CALL lsa::CMemLib::Init ( LSA_SIZE  _sDefaultSize,
LSBOOL  _bGrowable 
) [static]

Initialize the memory manager.

Parameters:
_sDefaultSizeThe default size of the heap.
_bGrowableWhether the heap can grow.
Returns:
Returns true if the memory manager was initialized.
template<class _cType >
_cType *LSE_CALL lsa::CMemLib::New ( CStdAllocator *  _psaAllocator) [static]

Create a new object using an allocator.

Parameters:
_psaAllocatorThe allocator to use to create the new object of the given type.
Returns:
Returns the newly allocated and constructed object or NULL if there is not enough memory to perform the operation.
static LSA_SIZE LSE_CALL lsa::CMemLib::PrintAllocations ( LSUINT32  _ui32Count = 0UL,
LSUINT32  _ui32End = 0xFFFFFFFFUL 
) [static]

Print allocations with an allocation counter above or equal to the given number. If LSA_DEBUG is not defined, this does nothing. Prints only allocations on the default memory allocator.

Parameters:
_ui32CountAllocations with an allocation number above or equal to this value will be printed. Use 0UL to print all allocations.
_ui32EndEnding allocation number up to which to print allocations.
Returns:
Returns the combined size of the allocations printed.
LSE_INLINE LSBOOL LSE_CALL lsa::CMemLib::Ready ( ) [static]

Are we ready for allocation?

Returns:
Returns true if Init() has been called and Destroy() has not.
static LSVOID* LSE_CALL lsa::CMemLib::ReAllocD ( LSVOID *  _pvAddr,
LSA_SIZE  _sSize 
) [static]

Reallocate memory. The data at the given address is moved to the new address if and only if a new address is returned.

Parameters:
_pvAddrThe address to reallocate.
_sSizeThe new size of the address.
Returns:
Returns the new address of the allocated data or NULL. If NULL is returned, _pvAddr still points to allocated memory that must be freed.
static LSVOID LSE_CALL lsa::CMemLib::ReleaseEmptyPools ( ) [static]

Release empty pools excluding the initial pool.


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