summaryrefslogtreecommitdiff
path: root/arm9/lib
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2021-08-18 20:11:27 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2021-08-18 20:11:27 -0400
commit0a7f7fc909c2bc0120002693a6b2052704a375fd (patch)
tree99d9116fa1efb9b9bc52d27a24f91a82b0f23ec0 /arm9/lib
parentbb16d9a030161b764029628f99eb22a8834b96d5 (diff)
NNS_FND_allocator
Diffstat (limited to 'arm9/lib')
-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..31d0eb70
--- /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"
+
+void *AllocatorAllocForExpHeap(NNSFndAllocator * pAllocator, u32 size)
+{
+ return NNS_FndAllocFromExpHeapEx(pAllocator->pHeap, size, pAllocator->heapParam1);
+}
+
+void AllocatorFreeForExpHeap(NNSFndAllocator * pAllocator, void *memBlock)
+{
+ NNS_FndFreeToExpHeap(pAllocator->pHeap, memBlock);
+}
+
+void *NNS_FndAllocFromAllocator(NNSFndAllocator * pAllocator, u32 size)
+{
+ return pAllocator->pFunc->pfAlloc(pAllocator, size);
+}
+
+void NNS_FndFreeToAllocator(NNSFndAllocator * pAllocator, void *memBlock)
+{
+ pAllocator->pFunc->pfFree(pAllocator, memBlock);
+}
+
+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;
+}