From bcb51257d2a3fa6d0182cbb7c778c78ecf14bf54 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Tue, 7 Feb 2023 17:19:13 -0400 Subject: THeap: Match `THeap::THeap()` --- src/pso/THeap.cpp | 62 +++++++++++-------------------------------------------- 1 file changed, 12 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/pso/THeap.cpp b/src/pso/THeap.cpp index bf2a35a..54772ff 100644 --- a/src/pso/THeap.cpp +++ b/src/pso/THeap.cpp @@ -146,62 +146,24 @@ THeap::~THeap() { xfree(heap_nodes); } -// Getting closer, still not sure how to match though. -#ifndef MATCHING THeap::THeap(size_t size, int alignment) { - heap_size = 0; + mbr_0x0C = 0; mbr_0x10 = 0; align = alignment; heap_nodes = (heap_node *)xmalloc(size); if (heap_nodes != NULL) { - const u32 new_size = size - heap_offset; - heap_node *tmp_heap; + heap_node *tmp_node; + heap_node *next_tmp_node; + memset(heap_nodes, 0, size); - tmp_heap = heap_nodes; - tmp_heap->next = tmp_heap + 1; - heap_nodes->alloc_size = 0; - tmp_heap[1].align = 0; - tmp_heap[1].heap_size = new_size; + tmp_node = heap_nodes; + next_tmp_node = &tmp_node[1]; + tmp_node->next = next_tmp_node; + + heap_nodes->remaining_size = 0; + + next_tmp_node->next = NULL; + next_tmp_node->remaining_size = size - heap_offset; } } -#else -asm THeap::THeap(size_t size, int alignment) { -nofralloc -/* 801410F0 9421FFF0 */ stwu r1, -0x10(r1) -/* 801410F4 7C0802A6 */ mflr r0 -/* 801410F8 90010014 */ stw r0, 0x14(r1) -/* 801410FC 38000000 */ li r0, 0x0 -/* 80141100 BFC10008 */ stmw r30, 8(r1) -/* 80141104 7C7E1B78 */ mr r30, r3 -/* 80141108 7C9F2378 */ mr r31, r4 -/* 8014110C 9003000C */ stw r0, 0xc(r3) -/* 80141110 7FE3FB78 */ mr r3, r31 -/* 80141114 901E0010 */ stw r0, 0x10(r30) -/* 80141118 90BE0008 */ stw r5, 8(r30) -/* 8014111C 48299FC5 */ bl xmalloc -/* 80141120 907E0000 */ stw r3, 0(r30) -/* 80141124 807E0000 */ lwz r3, 0(r30) -/* 80141128 28030000 */ cmplwi r3, 0 -/* 8014112C 41820034 */ beq- lbl_80141160 -/* 80141130 7FE5FB78 */ mr r5, r31 -/* 80141134 38800000 */ li r4, 0x0 -/* 80141138 4BECD1FD */ bl memset -/* 8014113C 807E0000 */ lwz r3, 0(r30) -/* 80141140 38800000 */ li r4, 0x0 -/* 80141144 381FFFF8 */ addi r0, r31, -0x8 -/* 80141148 38A30008 */ addi r5, r3, 0x8 -/* 8014114C 90A30000 */ stw r5, 0(r3) -/* 80141150 807E0000 */ lwz r3, 0(r30) -/* 80141154 90830004 */ stw r4, 4(r3) -/* 80141158 90850000 */ stw r4, 0(r5) -/* 8014115C 90050004 */ stw r0, 4(r5) -lbl_80141160: -/* 80141160 7FC3F378 */ mr r3, r30 -/* 80141164 BBC10008 */ lmw r30, 8(r1) -/* 80141168 80010014 */ lwz r0, 0x14(r1) -/* 8014116C 7C0803A6 */ mtlr r0 -/* 80141170 38210010 */ addi r1, r1, 0x10 -/* 80141174 4E800020 */ blr -} -#endif -- cgit v1.2.3-13-gbd6f