diff options
Diffstat (limited to 'src/memory_mid.c')
-rw-r--r-- | src/memory_mid.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/memory_mid.c b/src/memory_mid.c index 51c927a..546820a 100644 --- a/src/memory_mid.c +++ b/src/memory_mid.c @@ -2,15 +2,17 @@ #include "memory.h" extern u32 gUnknown_80B7F14; +extern u32 gUnknown_80B7F88; extern const char gLocateSetErrorMessage[]; extern struct HeapDescriptor gMainHeapDescriptor; - +extern const char gLocalCreateErrorMessage[]; extern s32 MemorySearchFromBack(struct HeapDescriptor *heap, s32, s32); extern s32 MemorySearchFromFront(struct HeapDescriptor *heap, s32, s32); extern struct HeapDescriptor * _LocateSetBack(struct HeapDescriptor *, u32, u32, u32, u32); extern struct HeapDescriptor * _LocateSetFront(struct HeapDescriptor *, u32, u32, u32, u32); void DoFree(struct HeapDescriptor *, void *); void *DoAlloc(struct HeapDescriptor *, s32, u32); +extern struct HeapDescriptor *DoCreateSubHeap(u32 *, u32); void FatalError(u32 *, const char *, ...) __attribute__((noreturn)); @@ -61,3 +63,28 @@ void MemoryFree(void *a) { DoFree(&gMainHeapDescriptor, a); } + +struct HeapDescriptor *MemoryLocate_LocalCreate(struct HeapDescriptor *parentHeap,u32 size,u32 param_3,u32 group) +{ + int index; + struct HeapDescriptor *iVar2; + struct HeapDescriptor *iVar3; + s32 local_1c[2]; + + if (parentHeap == NULL) { + parentHeap = &gMainHeapDescriptor; + } + + index = MemorySearchFromBack(parentHeap,9,size); + if (index < 0) + // Memroy LocalCreate buffer %08x size can't locate + FatalError(&gUnknown_80B7F88,gLocalCreateErrorMessage,size); + + iVar2 = _LocateSetBack(parentHeap,index,9,size,group); + local_1c[0] = iVar2->freeCount; + local_1c[1] = iVar2->freeListLength; + + iVar3 = DoCreateSubHeap(local_1c,param_3); + iVar3->parentHeap = parentHeap; + return iVar3; +} |