NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
mem_frameHeap.h
1#ifndef RVL_SDK_MEM_FRAME_HEAP_H
2#define RVL_SDK_MEM_FRAME_HEAP_H
3#include <types.h>
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#define MEM_FRM_HEAP_MIN_SIZE (sizeof(MEMiHeapHead) + sizeof(MEMiFrmHeapHead))
9
10// Forward declarations
11typedef struct MEMiHeapHead MEMiHeapHead;
12
13// Specify how to free memory
14typedef enum {
15 MEM_FRM_HEAP_FREE_TO_HEAD = (1 << 0),
16 MEM_FRM_HEAP_FREE_TO_TAIL = (1 << 1),
17 MEM_FRM_HEAP_FREE_ALL =
18 MEM_FRM_HEAP_FREE_TO_HEAD | MEM_FRM_HEAP_FREE_TO_TAIL
19} MEMiFrmFreeFlag;
20
21typedef struct MEMiFrmHeapState {
22 u32 id; // at 0x0
23 u8* head; // at 0x4
24 u8* tail; // at 0x8
25 struct MEMiFrmHeapState* next; // at 0xC
27
28// Placed in heap after base heap head
29typedef struct MEMiFrmHeapHead {
30 u8* head; // at 0x0
31 u8* tail; // at 0x4
32 MEMiFrmHeapState* states; // at 0x8
34
35MEMiHeapHead* MEMCreateFrmHeapEx(void* start, u32 size, u16 opt);
36MEMiHeapHead* MEMDestroyFrmHeap(MEMiHeapHead* heap);
37void* MEMAllocFromFrmHeapEx(MEMiHeapHead* heap, u32 size, s32 align);
38void MEMFreeToFrmHeap(MEMiHeapHead* heap, u32 flags);
39u32 MEMGetAllocatableSizeForFrmHeapEx(MEMiHeapHead* heap, s32 align);
40BOOL MEMRecordStateForFrmHeap(MEMiHeapHead* heap, u32 id);
41BOOL MEMFreeByStateToFrmHeap(MEMiHeapHead* heap, u32 id);
42u32 MEMAdjustFrmHeap(MEMiHeapHead* heap);
43u32 MEMResizeForMBlockFrmHeap(MEMiHeapHead* heap, void* memBlock, u32 size);
44
45static MEMiHeapHead* MEMCreateFrmHeap(void* start, u32 size) {
46 return MEMCreateFrmHeapEx(start, size, 0);
47}
48
49static void* MEMAllocFromFrmHeap(MEMiHeapHead* heap, u32 size) {
50 return MEMAllocFromFrmHeapEx(heap, size, 4);
51}
52
53static u32 MEMGetAllocatableSizeForFrmHeap(MEMiHeapHead* heap) {
54 return MEMGetAllocatableSizeForFrmHeapEx(heap, 4);
55}
56
57#ifdef __cplusplus
58}
59#endif
60#endif