mirror of
https://github.com/zeldaret/mm.git
synced 2026-07-09 13:45:23 -04:00
__osMalloc.c OK (#395)
* __osRealloc * match __osCheckArena * cleanup * Import bss, unreferenced strings and cleanup * format * Reviews * Move convert.h to ultra64/ * Make the os_malloc.h header * potato * renames and fixes * format * small doc pass } * format * minor changes * Introduce system_malloc.h * Docs pass * fix * format * stuff * Apply suggestions from code review Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> * review * format * remove repeated sentence * Apply suggestions from code review Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> * include headers * review * Rename __osMallocAddHeap * remove @brief * Update src/boot_O2/__osMalloc.c Co-authored-by: Derek Hensley <hensley.derek58@gmail.com> Co-authored-by: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com> Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
This commit is contained in:
+2
-1
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
s32 gFramerateDivisor = 1;
|
||||
f32 gFramerateDivisorF = 1.0f;
|
||||
@@ -174,7 +175,7 @@ void GameState_Realloc(GameState* gameState, size_t size) {
|
||||
alloc = &gameState->alloc;
|
||||
THA_Dt(&gameState->heap);
|
||||
GameAlloc_Free(alloc, heapStart);
|
||||
SystemArena_AnalyzeArena(&systemMaxFree, &bytesFree, &bytesAllocated);
|
||||
SystemArena_GetSizes(&systemMaxFree, &bytesFree, &bytesAllocated);
|
||||
size = ((systemMaxFree - (sizeof(ArenaNode))) < size) ? (0) : (size);
|
||||
if (size == 0) {
|
||||
size = systemMaxFree - (sizeof(ArenaNode));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
void GameAlloc_Log(GameAlloc* this) {
|
||||
GameAllocEntry* iter;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
|
||||
#include "overlays/gamestates/ovl_file_choose/z_file_choose.h"
|
||||
#include "overlays/gamestates/ovl_opening/z_opening.h"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
ListAlloc* ListAlloc_Init(ListAlloc* this) {
|
||||
this->prev = NULL;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177390.s")
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cmpdma/func_80178750.s")
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801857C0.s")
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s")
|
||||
|
||||
|
||||
+2
-1
@@ -1,11 +1,12 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
GameInfo* gGameInfo;
|
||||
|
||||
void GameInfo_Init(void) {
|
||||
s32 i;
|
||||
|
||||
gGameInfo = (GameInfo*)SystemArena_Malloc(sizeof(GameInfo));
|
||||
gGameInfo = SystemArena_Malloc(sizeof(GameInfo));
|
||||
if (1) {}
|
||||
gGameInfo->unk_00 = 0;
|
||||
gGameInfo->unk_01 = 0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo/func_80163DC0.s")
|
||||
|
||||
|
||||
+6
-3
@@ -1,4 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "os_malloc.h"
|
||||
|
||||
Arena sZeldaArena;
|
||||
|
||||
void* ZeldaArena_Malloc(size_t size) {
|
||||
void* ptr = __osMalloc(&sZeldaArena, size);
|
||||
@@ -34,11 +37,11 @@ void* ZeldaArena_Calloc(u32 num, size_t size) {
|
||||
}
|
||||
|
||||
void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc) {
|
||||
__osAnalyzeArena(&sZeldaArena, outMaxFree, outFree, outAlloc);
|
||||
__osGetSizes(&sZeldaArena, outMaxFree, outFree, outAlloc);
|
||||
}
|
||||
|
||||
void ZeldaArena_Check() {
|
||||
__osCheckArena(&sZeldaArena);
|
||||
s32 ZeldaArena_Check() {
|
||||
return __osCheckArena(&sZeldaArena);
|
||||
}
|
||||
|
||||
void ZeldaArena_Init(void* start, size_t size) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_vismono/func_801418B0.s")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user