From 67e8cd84005b624b82affc936b88d7f37a329d1a Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Tue, 22 Oct 2024 22:20:03 -0400 Subject: [PATCH] Decomped DoAlloc Decomped by Kermalis --- asm/memory_1.s | 12 ------------ include/memory.h | 1 + src/memory_mid.c | 6 +++++- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/asm/memory_1.s b/asm/memory_1.s index 325f933cc..6ece0344e 100644 --- a/asm/memory_1.s +++ b/asm/memory_1.s @@ -5,18 +5,6 @@ .text - thumb_func_start DoAlloc -DoAlloc: - push {lr} - movs r3, 0x80 - lsls r3, 1 - orrs r3, r2 - adds r2, r3, 0 - bl _LocateSet - pop {r1} - bx r1 - thumb_func_end DoAlloc - thumb_func_start DoFree DoFree: push {r4-r7,lr} diff --git a/include/memory.h b/include/memory.h index 980c20dba..48bba1793 100644 --- a/include/memory.h +++ b/include/memory.h @@ -87,5 +87,6 @@ void *MemoryAlloc(s32 size, s32 group); void MemoryFree(void *a); struct HeapDescriptor *DoCreateSubHeap(struct unkMemoryStruct *a, u32 b); void xxx_unused_memory_free(struct HeapDescriptor *a1); +void *DoAlloc(struct HeapDescriptor *heap, s32 size, u32 a2); #endif // GUARD_MEMORY_H diff --git a/src/memory_mid.c b/src/memory_mid.c index ba605254a..949bf099f 100644 --- a/src/memory_mid.c +++ b/src/memory_mid.c @@ -89,7 +89,6 @@ struct HeapDescriptor *MemoryLocate_LocalCreate(struct HeapDescriptor *parentHea return iVar3; } -// Note: This is called after _LocateSetBack which currently returns a HeapDescriptor* which is incorrect struct HeapDescriptor *DoCreateSubHeap(struct unkMemoryStruct *a, u32 b) { struct HeapMemoryBlock2 s2; @@ -134,3 +133,8 @@ void xxx_unused_memory_free(struct HeapDescriptor *a1) DoFree(a1->parentHeap, a1); } } + +void *DoAlloc(struct HeapDescriptor *heap, s32 size, u32 a2) +{ + return _LocateSet(heap, size, a2 | 0x100); +}