From 94683c43d16fb7efdbf97e82ac0946f4a9d0bab2 Mon Sep 17 00:00:00 2001 From: plutoo Date: Sat, 16 Sep 2017 20:29:55 +0200 Subject: [PATCH] Improving heap init a little --- nx/source/heap/heap.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/nx/source/heap/heap.c b/nx/source/heap/heap.c index b085e101..f0558256 100644 --- a/nx/source/heap/heap.c +++ b/nx/source/heap/heap.c @@ -32,9 +32,19 @@ void heapInit(void* base, size_t size) { void heapSetup() { // Called by crt0. - #define HEAP_SIZE 0x1000000 - static u8 g_Heap[HEAP_SIZE]; - heapInit(&g_Heap[0], HEAP_SIZE); + #define INNER_HEAP_SIZE 0x20000 + #define OUTER_HEAP_SIZE (0x2000000*4) + + void* addr; + Result rc = svcSetHeapSize(&addr, OUTER_HEAP_SIZE); + + if (R_SUCCEEDED(rc)) { + heapInit(addr, OUTER_HEAP_SIZE); + } + else { + static u8 g_Heap[INNER_HEAP_SIZE]; + heapInit(&g_Heap[0], INNER_HEAP_SIZE); + } } void* heapAllocPages(size_t size) {