"L. Spiro Engine"
|
#include <LSAStdAllocatorHeap.h>
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 |
CStdAllocatorHeap * | m_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 |
Class CStdAllocatorHeap
Description: Manage a single block of RAM.
typedef struct lsa::CStdAllocatorHeap::LSA_ALLOCATIONHEADER * lsa::CStdAllocatorHeap::LPLSA_ALLOCATIONHEADER [protected] |
An allocation header. Without debugging information, it should be smaller than or equal to the alignment (LSA_MIN_ALIGN).
typedef struct lsa::CStdAllocatorHeap::LSA_FREEHEADER * lsa::CStdAllocatorHeap::LPLSA_FREEHEADER [protected] |
A free-store header. This tells gives us information regarding free blocks of memory.
LSVOID* LSE_CALL lsa::CStdAllocatorHeap::Alloc | ( | LSA_SIZE | _sSize, |
LSUINT32 | _ui32Align = (1UL<< 4UL) |
||
) |
Allocate bytes.
_sSize | Number of bytes to allocate. |
_ui32Align | Alignment of the allocation. |
LSBOOL LSE_CALL lsa::CStdAllocatorHeap::Free | ( | LSVOID * | _pvAddr | ) |
Free bytes.
_pvAddr | Address to free. |
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.
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.
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.
_bReport | If true, non-empty blocks are printed to the debug stream. |
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.
_ui32Count | Allocations with an allocation number above or equal to this value will be printed. Use 0UL to print all allocations. |
_ui32End | Ending allocation number up to which to print allocations. |
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.
_lpahHeader | Header. |
_pvAddr | Block to resize. |
_sSize | New size of the block. |
LSE_INLINE LSVOID LSE_CALL lsa::CStdAllocatorHeap::Set | ( | LSVOID * | _pvHeap, |
LSA_SIZE | _sSizeOfHeap | ||
) | [protected] |
Set the starting point and size of the heap.
_pvHeap | Heap starting address. |
_sSizeOfHeap | Size of the heap. |
LSVOID LSE_CALL lsa::CStdAllocatorHeap::Trash | ( | ) |
Trash the contents of the block. Resets it to a clean slate ready for allocation.
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.
LPLSA_ALLOCATIONHEADER lsa::CStdAllocatorHeap::m_lpahAllocatedBlocks[64] [protected] |
Hash table for allocated blocks.
LPLSA_FREEHEADER lsa::CStdAllocatorHeap::m_lpfhFreeBlocks[64] [protected] |
Hash table for free blocks.
Head of the linked list of free blocks.
CStdAllocatorHeap* lsa::CStdAllocatorHeap::m_psahNext [protected] |
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.
LSUINT16 lsa::CStdAllocatorHeap::m_usLowestFreeBlockInHashTable [protected] |
Index of the first free block in the hash table.