A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Kinoko::EGG::ExpHeap Class Reference

#include <ExpHeap.hh>

Description

High-level implementation of a memory heap for managing dynamic memory allocation. Allocation may occur anywhere within the memory space the heap is created from.

Due to requesting chunks from a provided memory block, internal fragmentation is non-existent, but external fragmentation is still possible. Allocating temporary blocks from the tail, and scene-permanent blocks from the head, is recommended. The memory overhead per allocation is sizeof(Abstract::Memory::MEMiExpBlockHead).

Definition at line 15 of file ExpHeap.hh.

Inheritance diagram for Kinoko::EGG::ExpHeap:

Classes

class  GroupSizeRecord
 Memory blocks have group IDs assigned to them (default 0). This class is a record of the total sum of those blocks' sizes, categorized by group ID. Used for memory profiling. More...

Public Member Functions

void destroy () override
Kind getHeapKind () const override
void * alloc (size_t size, s32 align) override
void free (void *block) override
u32 getAllocatableSize (s32 align=4) const override
void calcGroupSize (GroupSizeRecord *record)
void setGroupID (u16 groupID)
u16 getGroupID () const
Abstract::Memory::MEMiExpHeapHeaddynamicCastHandleToExp ()
const Abstract::Memory::MEMiExpHeapHeaddynamicCastHandleToExp () const
Public Member Functions inherited from Kinoko::EGG::Heap
 Heap (Abstract::Memory::MEMiHeapHead *handle)
void dispose ()
void disableAllocation ()
void enableAllocation ()
bool tstDisableAllocation () const
void appendDisposer (Disposer *disposer)
void removeDisposer (Disposer *disposer)
Heap * becomeAllocatableHeap ()
Heap * becomeCurrentHeap ()
void registerHeapBuffer (void *buffer)
void * getStartAddress ()
void * getEndAddress ()
const char * getName () const
HeapgetParentHeap () const
void setName (const char *name)
void setParentHeap (Heap *heap)

Static Public Member Functions

static void addGroupSize (void *block, Abstract::Memory::MEMiHeapHead *heap, uintptr_t param)
static ExpHeap * create (void *startAddress, size_t size, u16 opt)
static ExpHeap * create (size_t size, Heap *heap, u16 opt)
Static Public Member Functions inherited from Kinoko::EGG::Heap
static void initialize ()
static void * alloc (size_t size, int align, Heap *pHeap)
static void free (void *block, Heap *pHeap)
static Heap * findHeap (Abstract::Memory::MEMiHeapHead *handle)
static Heap * findContainHeap (const void *block)
static ExpHeapdynamicCastToExp (Heap *heap)
static HeapgetCurrentHeap ()
static constexpr uintptr_t getOffset ()

Private Member Functions

 ExpHeap (Abstract::Memory::MEMiHeapHead *handle)

Additional Inherited Members

Public Types inherited from Kinoko::EGG::Heap
enum class  Kind {
  None ,
  Expanded ,
  Frame ,
  Unit ,
  Assert
}
Protected Types inherited from Kinoko::EGG::Heap
enum class  eFlags { Lock = 0 }
typedef TBitFlag< u16, eFlags > Flags
Protected Attributes inherited from Kinoko::EGG::Heap
Abstract::Memory::MEMiHeapHeadm_handle
void * m_block
Heapm_parentHeap
Flags m_flags
Abstract::Memory::MEMLink m_link
Abstract::Memory::MEMList m_children
const char * m_name
Static Protected Attributes inherited from Kinoko::EGG::Heap
static Abstract::Memory::MEMList s_heapList = MEMList(EGG::Heap::getOffset())
static Heaps_currentHeap = nullptr
static Heaps_allocatableHeap = nullptr

Constructor & Destructor Documentation

◆ ~ExpHeap()

Kinoko::EGG::ExpHeap::~ExpHeap ( )
override0x802269A8

Definition at line 12 of file ExpHeap.cc.

◆ ExpHeap()

Kinoko::EGG::ExpHeap::ExpHeap ( Abstract::Memory::MEMiHeapHead * handle)
private

Definition at line 9 of file ExpHeap.cc.

Member Function Documentation

◆ addGroupSize()

void Kinoko::EGG::ExpHeap::addGroupSize ( void * block,
Abstract::Memory::MEMiHeapHead * heap,
uintptr_t param )
static0x80226CA0

Definition at line 95 of file ExpHeap.cc.

◆ alloc()

void * Kinoko::EGG::ExpHeap::alloc ( size_t size,
s32 align )
nodiscardoverridevirtual0x80226C04

Implements Kinoko::EGG::Heap.

Definition at line 76 of file ExpHeap.cc.

◆ calcGroupSize()

void Kinoko::EGG::ExpHeap::calcGroupSize ( GroupSizeRecord * record)
0x80226CFC

Definition at line 105 of file ExpHeap.cc.

◆ create() [1/2]

ExpHeap * Kinoko::EGG::ExpHeap::create ( size_t size,
Heap * heap,
u16 opt )
staticnodiscard0x80226AC8

Definition at line 42 of file ExpHeap.cc.

◆ create() [2/2]

ExpHeap * Kinoko::EGG::ExpHeap::create ( void * startAddress,
size_t size,
u16 opt )
staticnodiscard0x80226A1C

Definition at line 18 of file ExpHeap.cc.

◆ destroy()

void Kinoko::EGG::ExpHeap::destroy ( )
overridevirtual0x80226B94

Implements Kinoko::EGG::Heap.

Definition at line 67 of file ExpHeap.cc.

◆ dynamicCastHandleToExp() [1/2]

MEMiExpHeapHead * Kinoko::EGG::ExpHeap::dynamicCastHandleToExp ( )
nodiscard

Definition at line 119 of file ExpHeap.cc.

◆ dynamicCastHandleToExp() [2/2]

const MEMiExpHeapHead * Kinoko::EGG::ExpHeap::dynamicCastHandleToExp ( ) const
nodiscard

Definition at line 123 of file ExpHeap.cc.

◆ free()

void Kinoko::EGG::ExpHeap::free ( void * block)
overridevirtual0x80226C78

Implements Kinoko::EGG::Heap.

Definition at line 85 of file ExpHeap.cc.

◆ getAllocatableSize()

u32 Kinoko::EGG::ExpHeap::getAllocatableSize ( s32 align = 4) const
nodiscardoverridevirtual0x80226C90

Implements Kinoko::EGG::Heap.

Definition at line 90 of file ExpHeap.cc.

◆ getGroupID()

u16 Kinoko::EGG::ExpHeap::getGroupID ( ) const
nodiscard

Definition at line 115 of file ExpHeap.cc.

◆ getHeapKind()

Kind Kinoko::EGG::ExpHeap::getHeapKind ( ) const
inlinenodiscardoverridevirtual0x80226EFC

Implements Kinoko::EGG::Heap.

Definition at line 40 of file ExpHeap.hh.

◆ setGroupID()

void Kinoko::EGG::ExpHeap::setGroupID ( u16 groupID)
0x80226C98

Definition at line 111 of file ExpHeap.cc.