summaryrefslogtreecommitdiff
path: root/arm9/lib/libnns/src/NNS_FND_allocator.c
diff options
context:
space:
mode:
authorAkira Akashi <rubenru09@aol.com>2021-08-30 23:07:56 +0100
committerGitHub <noreply@github.com>2021-08-30 23:07:56 +0100
commit6afd7bd12a7a7c5b9d3616dd843b7a8ef2df8f27 (patch)
treeeee378a2b4e09ff5e46faae7f4880f76ab075a26 /arm9/lib/libnns/src/NNS_FND_allocator.c
parent7994935696dcf9d81888e2d9d991f4b6a3e00738 (diff)
parentc17dcd24d24b9309ce2c1da1c709816afbea975b (diff)
Merge pull request #452 from PikalaxALT/pikalax_work
NNS fnd
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;
+}