blob: 63b2391ebb69de3f94f08cdc776a37b76796e8f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <revolution/mem/allocator.h>
#include <revolution/mem/expHeap.h>
static void* AllocatorAllocForExpHeap_(MEMAllocator *pAllocator, u32 size) {
return MEMAllocFromExpHeapEx(pAllocator->pHeap, size, pAllocator->heapParam1);
}
static void AllocatorFreeForExpHeap_(MEMAllocator *pAllocator, void *pBlock) {
MEMFreeToExpHeap(pAllocator->pHeap, pBlock);
}
void* MEMAllocFromAllocator(MEMAllocator *pAllocator, u32 size) {
return (*pAllocator->pFunc->pfAlloc)(pAllocator, size);
}
void MEMFreeToAllocator(MEMAllocator *pAllocator, void *pBlock) {
(*pAllocator->pFunc->pfFree)(pAllocator, pBlock);
}
void MEMInitAllocatorForExpHeap(MEMAllocator *pAllocator, MEMHeapHandle handle, int align) {
static const MEMAllocatorFunc sAllocatorFunc =
{
AllocatorAllocForExpHeap_,
AllocatorFreeForExpHeap_,
};
pAllocator->pFunc = &sAllocatorFunc;
pAllocator->pHeap = handle;
pAllocator->heapParam1 = align;
pAllocator->heapParam2 = 0;
}
|