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

lsa::CStdAllocatorHeap Class Reference

#include <LSAStdAllocatorHeap.h>

List of all members.

Classes

struct  LSA_ALLOCATIONHEADER
struct  LSA_FREEHEADER

Public Member Functions

LSVOID *LSE_CALL Alloc (LSA_SIZE _sSize, LSUINT32 _ui32Align=(1UL<< 4UL))
LSBOOL LSE_CALL Free (LSVOID *_pvAddr)
LSBOOL LSE_CALL IsEmpty (LSBOOL _bReport) const
LSVOID LSE_CALL Trash ()
LSA_SIZE LSE_CALL PrintAllocations (LSUINT32 _ui32Count=0UL, LSUINT32 _ui32End=0xFFFFFFFFUL) const
LSE_INLINE LSA_SIZE LSE_CALL GetHeapSize () const

Static Public Member Functions

static LSUINT32 LSE_CALL GetAllocationCounter ()

Protected Types

typedef struct
lsa::CStdAllocatorHeap::LSA_FREEHEADER
LPLSA_FREEHEADER
typedef struct
lsa::CStdAllocatorHeap::LSA_FREEHEADER 
LPCLSA_FREEHEADER
typedef struct
lsa::CStdAllocatorHeap::LSA_ALLOCATIONHEADER
LPLSA_ALLOCATIONHEADER
typedef struct
lsa::CStdAllocatorHeap::LSA_ALLOCATIONHEADER 
LPCLSA_ALLOCATIONHEADER

Protected Member Functions

LSE_INLINE LSVOID LSE_CALL Set (LSVOID *_pvHeap, LSA_SIZE _sSizeOfHeap)
LSVOID *LSE_CALL ReAlloc (LPLSA_ALLOCATIONHEADER &_lpahHeader, LSVOID *_pvAddr, LSA_SIZE _sSize)
LSE_INLINE LSUINT32 LSE_CALL GetHashKey (LSVOID *_pvAddr) const
LPLSA_ALLOCATIONHEADER LSE_CALL GetPrevAlloc (LPLSA_ALLOCATIONHEADER _pahFrom) const
LSVOID *LSE_CALL AddAllocInternal (LPLSA_FREEHEADER _lpfhPrevFree, LPLSA_ALLOCATIONHEADER _lpahNextAllocated, LSVOID *_pvAddr, LSA_SIZE _sSize, LSUINT32 _ui32Align)
LSVOID *LSE_CALL AddAlloc (LPLSA_ALLOCATIONHEADER _lpahNextAllocated, LSVOID *_pvAddr, LSA_SIZE _sSize, LSUINT32 _ui32Align)
LSVOID LSE_CALL RemAlloc (LPLSA_ALLOCATIONHEADER _lpahAllocated)
LSVOID LSE_CALL AddFreeBlockInternal (LPLSA_FREEHEADER _lpfhAfterMe, LPLSA_FREEHEADER _lpfhBeforeMe, LSVOID *_pvAddr, LSA_SIZE _sSize)
LSVOID LSE_CALL RemFreeBlockInternal (LPLSA_FREEHEADER _lpfhRemoveMe)
LSVOID LSE_CALL AddFreeBlock (LPLSA_FREEHEADER _lpfhAfterMe, LPLSA_FREEHEADER _lpfhBeforeMe, LSVOID *_pvAddr, LSA_SIZE _sSize)
LSBOOL LSE_CALL MergeFreeStoreBlocks (LPLSA_FREEHEADER _lpfhFirst)
LSE_INLINE
LPLSA_ALLOCATIONHEADER
LSE_CALL 
GetAllocationHead () const
LSE_INLINE
LPLSA_ALLOCATIONHEADER
LSE_CALL 
GetNextAllocatedBlock (LPLSA_FREEHEADER _lpAfterMe) const
LSE_INLINE LPLSA_FREEHEADER
LSE_CALL 
GetNextFreeBlock (LPLSA_ALLOCATIONHEADER _lpahAfterMe)
LSE_INLINE LSVOID LSE_CALL FixUpAllocationFreeBlockPointers (LPLSA_FREEHEADER _lpfhAfterMe)
LSE_INLINE LSVOID LSE_CALL ReplaceAllocationFreeBlockPointers (LPLSA_ALLOCATIONHEADER _lpahStart, LPLSA_FREEHEADER _lpfhReplaceMe, LPLSA_FREEHEADER _lpfhWithMe)
LPLSA_FREEHEADER LSE_CALL FindFreeStoreBlock (LSA_SIZE _sSize, LSUINT32 _ui32Align)
LSE_INLINE
LPLSA_ALLOCATIONHEADER
LSE_CALL 
FindAllocationBlock (LSVOID *_pvAddr)

Static Protected Member Functions

static LSE_INLINE LSVOID *LSE_CALL GetStartAddress (const LPLSA_ALLOCATIONHEADER _lpahHeader)
static LSE_INLINE LSA_SIZE LSE_CALL GetActualSizeOfBlock (LSVOID *_pvAddr, LSA_SIZE _sSize, LSUINT32 _ui32Align)
static LSE_INLINE LSA_SIZE LSE_CALL GetSize (const LPLSA_ALLOCATIONHEADER _lpahHeader)
static LSE_INLINE LSUINT32 LSE_CALL GetHashKey (LSA_SIZE _sSize)
static LSE_INLINE LSA_SIZE LSE_CALL RoundUp (LSA_SIZE _sSize)
static LSE_INLINE LSUINT32 LSE_CALL CreateSizeKey (LSA_SIZE _sSize)
static LSE_INLINE LSUINT32 LSE_CALL GetAlignment (LSUINT32 _ui32Key)

Protected Attributes

LSVOID * m_pvHeap
LSA_SIZE m_sSize
CStdAllocatorHeapm_psahNext
LPLSA_ALLOCATIONHEADER m_lpahAllocatedBlocks [64]
LPLSA_FREEHEADER m_lpfhFreeBlocks [64]
LPLSA_FREEHEADER m_lpfhFreeHead
LSUINT16 m_usLowestFreeBlockInHashTable
LSDOUBLE m_dInvSize

Static Protected Attributes

static LSBOOL m_bMadeTable
static LSDOUBLE m_dSinTable [0x10000]

Friends

class CStdAllocator

Detailed Description

Class CStdAllocatorHeap

Description: Manage a single block of RAM.


Member Typedef Documentation

An allocation header. Without debugging information, it should be smaller than or equal to the alignment (LSA_MIN_ALIGN).

A free-store header. This tells gives us information regarding free blocks of memory.


Member Function Documentation

LSVOID* LSE_CALL lsa::CStdAllocatorHeap::Alloc ( LSA_SIZE  _sSize,
LSUINT32  _ui32Align = (1UL<< 4UL) 
)

Allocate bytes.

Parameters:
_sSizeNumber of bytes to allocate.
_ui32AlignAlignment of the allocation.
Returns:
Returns the allocated bytes or NULL.
LSBOOL LSE_CALL lsa::CStdAllocatorHeap::Free ( LSVOID *  _pvAddr)

Free bytes.

Parameters:
_pvAddrAddress to free.
Returns:
Returns true if the address was allocated by this heap object.
static LSUINT32 LSE_CALL lsa::CStdAllocatorHeap::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.
LSE_INLINE LSA_SIZE LSE_CALL lsa::CStdAllocatorHeap::GetHeapSize ( ) const

Get the size of the heap. This is the entire size of the heap, not just the amount of RAM allocated from the heap.

Returns:
Returns the full size of this heap.
LSBOOL LSE_CALL lsa::CStdAllocatorHeap::IsEmpty ( LSBOOL  _bReport) const

Are we empty? In debug mode it also prints files and line numbers of remaining allocations.

Parameters:
_bReportIf true, non-empty blocks are printed to the debug stream.
Returns:
Returns true if the heap is empty.
LSA_SIZE LSE_CALL lsa::CStdAllocatorHeap::PrintAllocations ( LSUINT32  _ui32Count = 0UL,
LSUINT32  _ui32End = 0xFFFFFFFFUL 
) const

Print allocations with an allocation counter above or equal to the given number. If LSA_DEBUG is not defined, this does nothing.

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.
LSVOID* LSE_CALL lsa::CStdAllocatorHeap::ReAlloc ( LPLSA_ALLOCATIONHEADER _lpahHeader,
LSVOID *  _pvAddr,
LSA_SIZE  _sSize 
) [protected]

Adjust the length of an allocation. If it cannot be adjusted in place it is copied to a new location. NULL is returned if it cannot be adjusted.

Parameters:
_lpahHeaderHeader.
_pvAddrBlock to resize.
_sSizeNew size of the block.
Returns:
Returns the new address of the allocation or NULL.
LSE_INLINE LSVOID LSE_CALL lsa::CStdAllocatorHeap::Set ( LSVOID *  _pvHeap,
LSA_SIZE  _sSizeOfHeap 
) [protected]

Set the starting point and size of the heap.

Parameters:
_pvHeapHeap starting address.
_sSizeOfHeapSize of the heap.
LSVOID LSE_CALL lsa::CStdAllocatorHeap::Trash ( )

Trash the contents of the block. Resets it to a clean slate ready for allocation.


Member Data Documentation

LSBOOL lsa::CStdAllocatorHeap::m_bMadeTable [static, protected]

Have we made the sin table?

LSDOUBLE lsa::CStdAllocatorHeap::m_dInvSize [protected]

The inverse size of the heap.

LSDOUBLE lsa::CStdAllocatorHeap::m_dSinTable[0x10000] [static, protected]

The sin table.

Hash table for allocated blocks.

Hash table for free blocks.

Head of the linked list of free blocks.

Next block in the linked list of blocks.

LSVOID* lsa::CStdAllocatorHeap::m_pvHeap [protected]

Pointer to the start of the block of memory.

LSA_SIZE lsa::CStdAllocatorHeap::m_sSize [protected]

Size of the block.

Index of the first free block in the hash table.


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