MCPcopy Create free account
hub / github.com/doldecomp/mkdd / allocFromHead

Method allocFromHead

libs/JSystem/JKernel/JKRAramHeap.cpp:44–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44JKRAramBlock *JKRAramHeap::allocFromHead(u32 size)
45{
46 u32 alignedSize = ALIGN_NEXT(size, 0x20);
47 u32 bestFreeSize = UINT32_MAX;
48 JKRAramBlock *bestBlock = nullptr;
49
50 for (JSUListIterator<JKRAramBlock> iterator = sAramList.getFirst(); iterator != sAramList.getEnd(); ++iterator)
51 {
52 JKRAramBlock *block = iterator.getObject();
53 if (block->mFreeSize < alignedSize)
54 continue;
55 if (bestFreeSize <= block->mFreeSize)
56 continue;
57
58 bestFreeSize = block->mFreeSize;
59 bestBlock = block;
60
61 if (block->mFreeSize == alignedSize)
62 {
63 break;
64 }
65 }
66
67 if (bestBlock)
68 {
69 return bestBlock->allocHead(alignedSize, mGroupID, this);
70 }
71
72 return nullptr;
73}
74
75JKRAramBlock *JKRAramHeap::allocFromTail(u32 size)
76{

Callers

nothing calls this directly

Calls 4

allocHeadMethod · 0.80
getFirstMethod · 0.45
getEndMethod · 0.45
getObjectMethod · 0.45

Tested by

no test coverage detected