mirror of
https://github.com/zeldaret/mm.git
synced 2026-05-24 07:10:44 -04:00
c44e26a143
* __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>
52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
#include "global.h"
|
|
#include "os_malloc.h"
|
|
|
|
Arena gSystemArena;
|
|
|
|
void* SystemArena_Malloc(size_t size) {
|
|
return __osMalloc(&gSystemArena, size);
|
|
}
|
|
|
|
void* SystemArena_MallocR(size_t size) {
|
|
return __osMallocR(&gSystemArena, size);
|
|
}
|
|
|
|
void* SystemArena_Realloc(void* oldPtr, size_t newSize) {
|
|
return __osRealloc(&gSystemArena, oldPtr, newSize);
|
|
}
|
|
|
|
void SystemArena_Free(void* ptr) {
|
|
__osFree(&gSystemArena, ptr);
|
|
}
|
|
|
|
void* SystemArena_Calloc(u32 elements, size_t size) {
|
|
void* ptr;
|
|
size_t totalSize = elements * size;
|
|
|
|
ptr = __osMalloc(&gSystemArena, totalSize);
|
|
if (ptr != NULL) {
|
|
bzero(ptr, totalSize);
|
|
}
|
|
return ptr;
|
|
}
|
|
|
|
void SystemArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated) {
|
|
__osGetSizes(&gSystemArena, maxFreeBlock, bytesFree, bytesAllocated);
|
|
}
|
|
|
|
u32 SystemArena_CheckArena(void) {
|
|
return __osCheckArena(&gSystemArena);
|
|
}
|
|
|
|
void SystemArena_InitArena(void* start, size_t size) {
|
|
__osMallocInit(&gSystemArena, start, size);
|
|
}
|
|
|
|
void SystemArena_Cleanup(void) {
|
|
__osMallocCleanup(&gSystemArena);
|
|
}
|
|
|
|
u8 SystemArena_IsInitialized(void) {
|
|
return __osMallocIsInitalized(&gSystemArena);
|
|
}
|