Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
JKRExpHeap.h
Go to the documentation of this file.
1#ifndef JKREXPHEAP_H
2#define JKREXPHEAP_H
3
5
10class JKRExpHeap : public JKRHeap {
11public:
14 };
15
16 class CMemBlock {
17 friend class JKRExpHeap;
18
19 public:
25 int free(JKRExpHeap* heap);
26 static CMemBlock* getHeapBlock(void* ptr);
27
29 bool isValid() const { return mMagic == 'HM'; }
30 bool _isTempMemBlock() const { return (mFlags & 0x80) ? true : false; }
31 int getAlignment() const { return mFlags & 0x7f; }
32 void* getContent() const { return (void*)(this + 1); }
33 CMemBlock* getPrevBlock() const { return mPrev; }
34 CMemBlock* getNextBlock() const { return mNext; }
35 u32 getSize() const { return size; }
36 u8 getGroupId() const { return mGroupId; }
37 static CMemBlock* getBlock(void* data) { return (CMemBlock*)((u32)data + -0x10); }
38
39 private:
40 /* 0x0 */ u16 mMagic;
41 /* 0x2 */ u8 mFlags; // a|bbbbbbb a=temporary b=alignment
42 /* 0x3 */ u8 mGroupId;
43 /* 0x4 */ u32 size;
44 /* 0x8 */ CMemBlock* mPrev;
45 /* 0xC */ CMemBlock* mNext;
46 }; // Size: 0x10
47 friend class CMemBlock;
48
49protected:
50 JKRExpHeap(void* data, u32 size, JKRHeap* parent, bool errorFlag);
51 virtual ~JKRExpHeap();
52
53 void* allocFromHead(u32 size, int align);
54 void* allocFromHead(u32 size);
55 void* allocFromTail(u32 size, int align);
56 void* allocFromTail(u32 size);
63
64public:
66 s32 getTotalUsedSize(void) const;
67
70 mAllocMode = mode;
71 }
72
73public:
74 /* vt[04] */ virtual u32 getHeapType(); /* override */
75 /* vt[05] */ virtual bool check(); /* override */
76 /* vt[06] */ virtual bool dump_sort(); /* override */
77 /* vt[07] */ virtual bool dump(); /* override */
78 /* vt[08] */ virtual void do_destroy(); /* override */
79 /* vt[09] */ virtual void* do_alloc(u32 size, int alignment); /* override */
80 /* vt[10] */ virtual void do_free(void* ptr); /* override */
81 /* vt[11] */ virtual void do_freeAll(); /* override */
82 /* vt[12] */ virtual void do_freeTail(); /* override */
83 /* vt[13] */ virtual void do_fillFreeArea(); /* override */
84 /* vt[14] */ virtual s32 do_resize(void* ptr, u32 size); /* override */
85 /* vt[15] */ virtual s32 do_getSize(void* ptr); /* override */
86 /* vt[16] */ virtual s32 do_getFreeSize(); /* override */
87 /* vt[17] */ virtual void* do_getMaxFreeBlock(); /* override */
88 /* vt[18] */ virtual s32 do_getTotalFreeSize(); /* override */
89 /* vt[19] */ virtual s32 do_changeGroupID(u8 newGroupID); /* override */
90 /* vt[20] */ virtual u8 do_getCurrentGroupId(); /* override */
91 /* vt[21] */ virtual void state_register(JKRHeap::TState* p, u32 id) const; /* override */
92 /* vt[22] */ virtual bool state_compare(JKRHeap::TState const& r1,
93 JKRHeap::TState const& r2) const; /* override */
94
95 /* 0x6C */ u8 mAllocMode;
96 /* 0x6D */ u8 mCurrentGroupId;
97 /* 0x6E */ bool field_0x6e;
98
99private:
100 /* 0x70 */ void* field_0x70;
101 /* 0x74 */ u32 field_0x74;
106
107public:
108 static JKRExpHeap* createRoot(int maxHeaps, bool errorFlag);
109 static JKRExpHeap* create(u32 size, JKRHeap* parent, bool errorFlag);
110 static JKRExpHeap* create(void* ptr, u32 size, JKRHeap* parent, bool errorFlag);
111};
112
116
117#endif /* JKREXPHEAP_H */
static unsigned long int next
Definition CARDUnlock.c:76
JKRExpHeap * JKRCreateExpHeap(u32 size, JKRHeap *parent, bool errorFlag)
Definition JKRExpHeap.h:113
T cLib_calcTimer(T *value)
Definition c_lib.h:74
static s32 r2
Definition c_math.cpp:176
static s32 r1
Definition c_math.cpp:173
Definition JKRExpHeap.h:16
bool isValid() const
Definition JKRExpHeap.h:29
JKRExpHeap::CMemBlock * allocBack(u32 size, u8 groupId1, u8 alignment1, u8 groupId2, u8 alignment2)
Definition JKRExpHeap.cpp:947
u32 size
Definition JKRExpHeap.h:43
u8 mFlags
Definition JKRExpHeap.h:41
JKRExpHeap::CMemBlock * allocFore(u32 size, u8 groupId1, u8 alignment1, u8 groupId2, u8 alignment2)
Definition JKRExpHeap.cpp:929
static CMemBlock * getHeapBlock(void *ptr)
Definition JKRExpHeap.cpp:974
bool _isTempMemBlock() const
Definition JKRExpHeap.h:30
int getAlignment() const
Definition JKRExpHeap.h:31
CMemBlock * mPrev
Definition JKRExpHeap.h:44
CMemBlock * getPrevBlock() const
Definition JKRExpHeap.h:33
u8 mGroupId
Definition JKRExpHeap.h:42
u8 getGroupId() const
Definition JKRExpHeap.h:36
void * getContent() const
Definition JKRExpHeap.h:32
CMemBlock * mNext
Definition JKRExpHeap.h:45
static CMemBlock * getBlock(void *data)
Definition JKRExpHeap.h:37
void initiate(CMemBlock *prev, CMemBlock *next, u32 size, u8 groupId, u8 alignment)
Definition JKRExpHeap.cpp:917
u32 getSize() const
Definition JKRExpHeap.h:35
int free(JKRExpHeap *heap)
Definition JKRExpHeap.cpp:967
void newGroupId(u8 groupId)
Definition JKRExpHeap.h:28
u16 mMagic
Definition JKRExpHeap.h:40
CMemBlock * getNextBlock() const
Definition JKRExpHeap.h:34
Definition JKRHeap.h:18
Definition JKRHeap.h:16
static u16 data[4]
Definition d_vibration.cpp:114
p
Definition e_acos.c:98
static u8 block[48]
Definition fstload.c:39
Definition d_a_balloon_2D.h:178
void * field_0x70
Definition JKRExpHeap.h:100
static JKRExpHeap * createRoot(int maxHeaps, bool errorFlag)
Definition JKRExpHeap.cpp:11
virtual s32 do_changeGroupID(u8 newGroupID)
Definition JKRExpHeap.cpp:431
void removeUsedBlock(CMemBlock *block)
Definition JKRExpHeap.cpp:647
virtual ~JKRExpHeap()
Definition JKRExpHeap.cpp:116
void appendUsedList(CMemBlock *newblock)
Definition JKRExpHeap.cpp:581
u8 mAllocMode
Definition JKRExpHeap.h:95
bool field_0x6e
Definition JKRExpHeap.h:97
CMemBlock * mHeadUsedList
Definition JKRExpHeap.h:104
CMemBlock * getHeadUsedList() const
Definition JKRExpHeap.h:68
CMemBlock * mTailFreeList
Definition JKRExpHeap.h:103
virtual s32 do_getFreeSize()
Definition JKRExpHeap.cpp:507
void setAllocationMode(EAllocMode mode)
Definition JKRExpHeap.h:69
virtual bool check()
Definition JKRExpHeap.cpp:737
void recycleFreeBlock(CMemBlock *block)
Definition JKRExpHeap.cpp:666
CMemBlock * mTailUsedList
Definition JKRExpHeap.h:105
s32 getUsedSize(u8 groupId) const
Definition JKRExpHeap.cpp:548
void * allocFromHead(u32 size, int align)
Definition JKRExpHeap.cpp:171
virtual void do_destroy()
Definition JKRExpHeap.cpp:90
virtual void state_register(JKRHeap::TState *p, u32 id) const
Definition JKRExpHeap.cpp:986
virtual bool state_compare(JKRHeap::TState const &r1, JKRHeap::TState const &r2) const
Definition JKRExpHeap.cpp:1011
virtual u32 getHeapType()
Definition JKRExpHeap.cpp:1025
u8 mCurrentGroupId
Definition JKRExpHeap.h:96
u32 field_0x74
Definition JKRExpHeap.h:101
virtual void do_freeTail()
Definition JKRExpHeap.cpp:411
virtual s32 do_getSize(void *ptr)
Definition JKRExpHeap.cpp:495
EAllocMode
Definition JKRExpHeap.h:12
@ ALLOC_MODE_1
Definition JKRExpHeap.h:13
virtual void do_fillFreeArea()
Definition JKRExpHeap.cpp:427
virtual bool dump_sort()
Definition JKRExpHeap.cpp:854
void joinTwoBlocks(CMemBlock *block)
Definition JKRExpHeap.cpp:720
virtual void do_free(void *ptr)
Definition JKRExpHeap.cpp:387
virtual void * do_alloc(u32 size, int alignment)
Definition JKRExpHeap.cpp:121
virtual void * do_getMaxFreeBlock()
Definition JKRExpHeap.cpp:521
CMemBlock * mHeadFreeList
Definition JKRExpHeap.h:102
virtual void do_freeAll()
Definition JKRExpHeap.cpp:399
static JKRExpHeap * create(u32 size, JKRHeap *parent, bool errorFlag)
Definition JKRExpHeap.cpp:28
void * allocFromTail(u32 size, int align)
Definition JKRExpHeap.cpp:313
void setFreeBlock(CMemBlock *block, CMemBlock *prev, CMemBlock *next)
Definition JKRExpHeap.cpp:606
virtual s32 do_getTotalFreeSize()
Definition JKRExpHeap.cpp:537
virtual u8 do_getCurrentGroupId()
Definition JKRExpHeap.cpp:1030
virtual s32 do_resize(void *ptr, u32 size)
Definition JKRExpHeap.cpp:440
void removeFreeBlock(CMemBlock *block)
Definition JKRExpHeap.cpp:628
virtual bool dump()
Definition JKRExpHeap.cpp:806
s32 getTotalUsedSize(void) const
Definition JKRExpHeap.cpp:566
unsigned long u32
Definition types.h:10
unsigned short u16
Definition types.h:9
signed long s32
Definition types.h:6
unsigned char u8
Definition types.h:8