summaryrefslogtreecommitdiff
path: root/arm9/lib/libnns/src/NNS_FND_allocator.c
diff options
context:
space:
mode:
authorRémi Calixte <remicalixte.rmc@gmail.com>2021-08-31 08:30:47 +0200
committerRémi Calixte <remicalixte.rmc@gmail.com>2021-08-31 08:30:47 +0200
commit12bafff5c0ca6bfdcca3553a0717c80f21e27182 (patch)
tree7c07954a140c879b8c71e33a71c603f27076ab56 /arm9/lib/libnns/src/NNS_FND_allocator.c
parent4e4192cd7007d16cefe00facbc7b721353c94f60 (diff)
parent05ded46ab7f556956a2eee2411a8d2968b7e8ad6 (diff)
Merge branch 'master' into unk_02006D98
Diffstat (limited to 'arm9/lib/libnns/src/NNS_FND_allocator.c')
-rw-r--r--arm9/lib/libnns/src/NNS_FND_allocator.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/arm9/lib/libnns/src/NNS_FND_allocator.c b/arm9/lib/libnns/src/NNS_FND_allocator.c
new file mode 100644
index 00000000..c459c3d0
--- /dev/null
+++ b/arm9/lib/libnns/src/NNS_FND_allocator.c
@@ -0,0 +1,32 @@
+#include "nitro.h"
+#include "NNS_FND_allocator.h"
+#include "NNS_FND_expheap.h"
+
+ARM_FUNC void *AllocatorAllocForExpHeap(NNSFndAllocator * pAllocator, u32 size)
+{
+ return NNS_FndAllocFromExpHeapEx(pAllocator->pHeap, size, pAllocator->heapParam1);
+}
+
+ARM_FUNC void AllocatorFreeForExpHeap(NNSFndAllocator * pAllocator, void *memBlock)
+{
+ NNS_FndFreeToExpHeap(pAllocator->pHeap, memBlock);
+}
+
+ARM_FUNC void *NNS_FndAllocFromAllocator(NNSFndAllocator * pAllocator, u32 size)
+{
+ return pAllocator->pFunc->pfAlloc(pAllocator, size);
+}
+
+ARM_FUNC void NNS_FndFreeToAllocator(NNSFndAllocator * pAllocator, void *memBlock)
+{
+ pAllocator->pFunc->pfFree(pAllocator, memBlock);
+}
+
+ARM_FUNC void NNS_FndInitAllocatorForExpHeap(NNSFndAllocator * pAllocator, NNSFndHeapHandle pHeap, int alignment)
+{
+ static const NNSFndAllocatorFunc pFunc = {AllocatorAllocForExpHeap, AllocatorFreeForExpHeap};
+ pAllocator->pFunc = &pFunc;
+ pAllocator->pHeap = pHeap;
+ pAllocator->heapParam1 = alignment;
+ pAllocator->heapParam2 = 0;
+}