mirror of
https://github.com/izzy2lost/2ship2harkinian-Android.git
synced 2026-06-19 01:20:08 -07: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:
co-authored by
EllipticEllipsis
Tharo
Derek Hensley
parent
133e02a8a7
commit
c44e26a143
+3
-25
@@ -194,16 +194,7 @@ s32 func_80086D40(f64 param_1);
|
||||
f64 func_80086D6C(f64 param_1);
|
||||
s32 func_80086D8C(f32 param_1);
|
||||
s32 func_80086DAC(f64 param_1);
|
||||
void* SystemArena_Malloc(size_t size);
|
||||
void* SystemArena_MallocR(size_t size);
|
||||
void* SystemArena_Realloc(void* oldPtr, size_t newSize);
|
||||
void SystemArena_Free(void* ptr);
|
||||
void* SystemArena_Calloc(u32 elements, size_t size);
|
||||
void SystemArena_AnalyzeArena(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated);
|
||||
u32 SystemArena_CheckArena(void);
|
||||
void SystemArena_InitArena(void* start, size_t size);
|
||||
void SystemArena_Cleanup(void);
|
||||
u8 SystemArena_IsInitialized(void);
|
||||
|
||||
s32 Rand_Next(void);
|
||||
void Rand_Seed(u32 seed);
|
||||
f32 Rand_ZeroOne(void);
|
||||
@@ -212,20 +203,7 @@ void Rand_Seed_Variable(u32* rndNum, u32 seed);
|
||||
u32 Rand_Next_Variable(u32* param_1);
|
||||
f32 Rand_ZeroOne_Variable(u32* param_1);
|
||||
f32 Rand_Centered_Variable(u32* param_1);
|
||||
void ArenaImpl_LockInit(Arena* heap);
|
||||
void ArenaImpl_Lock(Arena* heap);
|
||||
void ArenaImpl_Unlock(Arena* heap);
|
||||
ArenaNode* ArenaImpl_GetLastBlock(Arena* param_1);
|
||||
void __osMallocInit(Arena* heap, void* heapBase, size_t heapSize);
|
||||
void __osMallocAddBlock(Arena* heap, void* start, s32 size);
|
||||
void __osMallocCleanup(Arena* heap);
|
||||
u8 __osMallocIsInitalized(Arena* heap);
|
||||
void* __osMalloc(Arena* heap, size_t size);
|
||||
void* __osMallocR(Arena* heap, size_t size);
|
||||
void __osFree(Arena* heap, void* ptr);
|
||||
void* __osRealloc(Arena* heap, void* oldPtr, size_t newSize);
|
||||
void __osAnalyzeArena(Arena* heap, size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated);
|
||||
u32 __osCheckArena(Arena* heap);
|
||||
|
||||
void* proutSprintf(void* s, const char* buf, size_t n);
|
||||
s32 vsprintf(char* dst, char* fmt, va_list args);
|
||||
s32 sprintf(char* s, char* fmt, ...);
|
||||
@@ -1769,7 +1747,7 @@ void* ZeldaArena_Realloc(void* oldPtr, size_t newSize);
|
||||
void ZeldaArena_Free(void* param_1);
|
||||
void* ZeldaArena_Calloc(u32 num, size_t size);
|
||||
void ZeldaArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated);
|
||||
void ZeldaArena_Check();
|
||||
s32 ZeldaArena_Check();
|
||||
void ZeldaArena_Init(void* start, size_t size);
|
||||
void ZeldaArena_Cleanup();
|
||||
u8 ZeldaArena_IsInitialized();
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#define _MACROS_H_
|
||||
|
||||
#include "libc/stdint.h"
|
||||
#include "convert.h"
|
||||
#include "ultra64/convert.h"
|
||||
#include "z64.h"
|
||||
|
||||
#define SCREEN_WIDTH 320
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef OS_MALLOC
|
||||
#define OS_MALLOC
|
||||
|
||||
#include "PR/ultratypes.h"
|
||||
#include "ultra64/message.h"
|
||||
#include "libc/stddef.h"
|
||||
|
||||
typedef struct ArenaNode {
|
||||
/* 0x0 */ s16 magic; // Should always be 0x7373
|
||||
/* 0x2 */ s16 isFree;
|
||||
/* 0x4 */ size_t size;
|
||||
/* 0x8 */ struct ArenaNode* next;
|
||||
/* 0xC */ struct ArenaNode* prev;
|
||||
} ArenaNode; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ ArenaNode* head;
|
||||
/* 0x04 */ void* start;
|
||||
/* 0x08 */ OSMesgQueue lock;
|
||||
/* 0x20 */ u8 unk20;
|
||||
/* 0x21 */ u8 isInit;
|
||||
/* 0x22 */ u8 flag;
|
||||
} Arena; // size = 0x24
|
||||
|
||||
void __osMallocInit(Arena* arena, void* heap, size_t size);
|
||||
void __osMallocCleanup(Arena* arena);
|
||||
u8 __osMallocIsInitalized(Arena* arena);
|
||||
void* __osMalloc(Arena* arena, size_t size);
|
||||
void* __osMallocR(Arena* arena, size_t size);
|
||||
void __osFree(Arena* arena, void* ptr);
|
||||
void* __osRealloc(Arena* arena, void* ptr, size_t newSize);
|
||||
void __osGetSizes(Arena* arena, size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated);
|
||||
s32 __osCheckArena(Arena* arena);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef SYSTEM_MALLOC
|
||||
#define SYSTEM_MALLOC
|
||||
|
||||
#include "PR/ultratypes.h"
|
||||
#include "os_malloc.h"
|
||||
|
||||
void* SystemArena_Malloc(size_t size);
|
||||
void* SystemArena_MallocR(size_t size);
|
||||
void* SystemArena_Realloc(void* oldPtr, size_t newSize);
|
||||
void SystemArena_Free(void* ptr);
|
||||
void* SystemArena_Calloc(u32 elements, size_t size);
|
||||
void SystemArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated);
|
||||
u32 SystemArena_CheckArena(void);
|
||||
void SystemArena_InitArena(void* start, size_t size);
|
||||
void SystemArena_Cleanup(void);
|
||||
u8 SystemArena_IsInitialized(void);
|
||||
|
||||
extern Arena gSystemArena;
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef _ULTRA64_CONVERT_H_
|
||||
#define _ULTRA64_CONVERT_H_
|
||||
#ifndef ULTRA64_CONVERT_H
|
||||
#define ULTRA64_CONVERT_H
|
||||
|
||||
#include "libc/stdint.h"
|
||||
|
||||
@@ -322,7 +322,6 @@ extern StackEntry sFaultThreadInfo;
|
||||
extern FaultThreadStruct gFaultStruct;
|
||||
extern FaultDrawer sFaultDrawerStruct;
|
||||
// extern UNK_TYPE4 D_8009CD10;
|
||||
// extern Arena gSystemArena;
|
||||
extern u32 sRandFloat;
|
||||
// extern UNK_TYPE4 sArenaLockMsg;
|
||||
extern OSTask tmp_task;
|
||||
@@ -3271,7 +3270,6 @@ extern s16 D_801F4E7A;
|
||||
// extern UNK_TYPE1 D_801F4F68;
|
||||
// extern UNK_TYPE1 D_801F4F6A;
|
||||
extern LightsBuffer sLightsBuffer;
|
||||
extern Arena sZeldaArena;
|
||||
// extern UNK_TYPE1 D_801F5130;
|
||||
// extern UNK_TYPE1 D_801F5270;
|
||||
// extern UNK_TYPE1 D_801F528E;
|
||||
|
||||
@@ -884,23 +884,6 @@ typedef struct {
|
||||
/* 0x120D8 */ UNK_TYPE1 pad120D8[0x8];
|
||||
} MessageContext; // size = 0x120E0
|
||||
|
||||
typedef struct ArenaNode {
|
||||
/* 0x0 */ s16 magic; // Should always be 0x7373
|
||||
/* 0x2 */ s16 isFree;
|
||||
/* 0x4 */ size_t size;
|
||||
/* 0x8 */ struct ArenaNode* next;
|
||||
/* 0xC */ struct ArenaNode* prev;
|
||||
} ArenaNode; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ ArenaNode* head;
|
||||
/* 0x04 */ void* start;
|
||||
/* 0x08 */ OSMesgQueue lock;
|
||||
/* 0x20 */ u8 unk20;
|
||||
/* 0x21 */ u8 isInit;
|
||||
/* 0x22 */ u8 flag;
|
||||
} Arena; // size = 0x24
|
||||
|
||||
typedef struct FaultAddrConvClient {
|
||||
/* 0x0 */ struct FaultAddrConvClient* next;
|
||||
/* 0x4 */ void* (*callback)(void*, void*);
|
||||
|
||||
Reference in New Issue
Block a user