wut  v1.7.0
Wii U Toolchain
memblockheap.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "memheap.h"
4 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
17 typedef struct MEMBlockHeap MEMBlockHeap;
18 
20 {
21  WUT_UNKNOWN_BYTES(0x8);
22 
25 
27  uint32_t blockCount;
28 };
29 WUT_CHECK_OFFSET(MEMBlockHeapTracking, 0x08, blocks);
30 WUT_CHECK_OFFSET(MEMBlockHeapTracking, 0x0C, blockCount);
31 WUT_CHECK_SIZE(MEMBlockHeapTracking, 0x10);
32 
34 {
36  void *start;
37 
39  void *end;
40 
43 
46 
49 };
50 WUT_CHECK_OFFSET(MEMBlockHeapBlock, 0x00, start);
51 WUT_CHECK_OFFSET(MEMBlockHeapBlock, 0x04, end);
52 WUT_CHECK_OFFSET(MEMBlockHeapBlock, 0x08, isFree);
53 WUT_CHECK_OFFSET(MEMBlockHeapBlock, 0x0c, prev);
54 WUT_CHECK_OFFSET(MEMBlockHeapBlock, 0x10, next);
55 WUT_CHECK_SIZE(MEMBlockHeapBlock, 0x14);
56 
57 struct WUT_PACKED MEMBlockHeap
58 {
60 
63 
66 
69 
72 
75 
77  uint32_t numFreeBlocks;
78 };
79 WUT_CHECK_OFFSET(MEMBlockHeap, 0x00, header);
80 WUT_CHECK_OFFSET(MEMBlockHeap, 0x40, defaultTrack);
81 WUT_CHECK_OFFSET(MEMBlockHeap, 0x50, defaultBlock);
82 WUT_CHECK_OFFSET(MEMBlockHeap, 0x64, firstBlock);
83 WUT_CHECK_OFFSET(MEMBlockHeap, 0x68, lastBlock);
84 WUT_CHECK_OFFSET(MEMBlockHeap, 0x6C, firstFreeBlock);
85 WUT_CHECK_OFFSET(MEMBlockHeap, 0x70, numFreeBlocks);
86 WUT_CHECK_SIZE(MEMBlockHeap, 0x74);
87 
90  void *start,
91  void *end,
92  MEMBlockHeapTracking *blocks,
93  uint32_t size,
94  uint32_t flags);
95 
96 void *
98 
99 int
101  MEMBlockHeapTracking *tracking,
102  uint32_t size);
103 
104 void *
106  void *addr,
107  uint32_t size);
108 
109 void *
111  uint32_t size,
112  int32_t align);
113 
114 void
116  void *data);
117 
118 uint32_t
120  int32_t align);
121 
122 uint32_t
124 
125 uint32_t
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
MEMHeapHeader header
Definition: memblockheap.h:59
MEMBlockHeapBlock * next
Link to next block, always set.
Definition: memblockheap.h:48
uint32_t blockCount
Number of blocks in this tracking heap.
Definition: memblockheap.h:27
MEMBlockHeapBlock * firstBlock
First block in this heap.
Definition: memblockheap.h:68
uint32_t numFreeBlocks
Free block count.
Definition: memblockheap.h:77
MEMBlockHeapBlock * blocks
Pointer to first memory block.
Definition: memblockheap.h:21
void * start
First address of the data region this block has allocated.
Definition: memblockheap.h:36
void * end
End address of the data region this block has allocated.
Definition: memblockheap.h:39
MEMBlockHeapBlock * firstFreeBlock
First free block.
Definition: memblockheap.h:74
BOOL isFree
TRUE if the block is free, FALSE if allocated.
Definition: memblockheap.h:42
MEMBlockHeapBlock defaultBlock
Default block, used so we don't have an empty block list.
Definition: memblockheap.h:65
MEMBlockHeapBlock * prev
Link to previous block, note that this is only set for allocated blocks.
Definition: memblockheap.h:45
MEMBlockHeapTracking defaultTrack
Default tracking heap, tracks only defaultBlock.
Definition: memblockheap.h:62
MEMBlockHeapBlock * lastBlock
Last block in this heap.
Definition: memblockheap.h:71
void * MEMAllocFromBlockHeapEx(MEMHeapHandle heap, uint32_t size, int32_t align)
int MEMAddBlockHeapTracking(MEMHeapHandle heap, MEMBlockHeapTracking *tracking, uint32_t size)
uint32_t MEMGetTrackingLeftInBlockHeap(MEMHeapHandle heap)
MEMHeapHandle MEMInitBlockHeap(MEMBlockHeap *heap, void *start, void *end, MEMBlockHeapTracking *blocks, uint32_t size, uint32_t flags)
void * MEMAllocFromBlockHeapAt(MEMHeapHandle heap, void *addr, uint32_t size)
void * MEMDestroyBlockHeap(MEMHeapHandle heap)
uint32_t MEMGetTotalFreeSizeForBlockHeap(MEMHeapHandle heap)
void MEMFreeToBlockHeap(MEMHeapHandle heap, void *data)
uint32_t MEMGetAllocatableSizeForBlockHeapEx(MEMHeapHandle heap, int32_t align)
int32_t BOOL
Definition: wut_types.h:7