From d8fdc85090226dcaf7309102d386bf37db3ff284 Mon Sep 17 00:00:00 2001 From: Pheenoh Date: Sun, 3 Jan 2021 16:58:49 -0500 Subject: [PATCH] countUsed OK --- include/JSystem/JKernel/JKRExpHeap/JKRExpHeap.h | 1 + src/m_Do/m_Do_main.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/JSystem/JKernel/JKRExpHeap/JKRExpHeap.h b/include/JSystem/JKernel/JKRExpHeap/JKRExpHeap.h index 72b16a4c5b4..02705f338f9 100644 --- a/include/JSystem/JKernel/JKRExpHeap/JKRExpHeap.h +++ b/include/JSystem/JKernel/JKRExpHeap/JKRExpHeap.h @@ -57,6 +57,7 @@ protected: public: s32 getUsedSize(u8) const; s32 getTotalUsedSize(void) const; + CMemBlock* getHeadUsedList() { return mHeadUsedList; } public: /* vt[04] */ virtual u32 getHeapType(); /* override */ diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index d558e5e4fc9..a9848ccc993 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -67,8 +67,19 @@ asm void CheckHeap(u32 param_1) { } #endif -asm int countUsed(JKRExpHeap* heap){nofralloc -#include "m_Do/m_Do_main/asm/func_80005848.s" +int countUsed(JKRExpHeap* heap) { + + OSDisableScheduler(); + int counter = 0; + JKRExpHeap::CMemBlock* used_blocks_head = heap->getHeadUsedList(); + + while (used_blocks_head) { + used_blocks_head = used_blocks_head->getNextBlock(); + counter++; + }; + + OSEnableScheduler(); + return counter; } s32 HeapCheck::getUsedCount(void) const {