diff --git a/src/n64sys.c b/src/n64sys.c index d3d042f52..139e11e84 100644 --- a/src/n64sys.c +++ b/src/n64sys.c @@ -202,11 +202,10 @@ void die(void) void sys_get_heap_stats(heap_stats_t *stats) { - extern char *__heap_end; - extern char *__heap_top; + extern int __heap_total_size; struct mallinfo m = mallinfo(); - stats->total = (int)((unsigned long)__heap_top - (unsigned long)__heap_end); + stats->total = __heap_total_size; stats->used = m.uordblks; } diff --git a/src/system.c b/src/system.c index 2987c752d..e019fdc1f 100644 --- a/src/system.c +++ b/src/system.c @@ -45,6 +45,9 @@ */ #define STACK_SIZE 0x10000 + +/** Total Size of the heap */ +int __heap_total_size = 0; /** End of the heap */ char *__heap_end = 0; /** Top of the heap */ @@ -1024,6 +1027,7 @@ void *sbrk( int incr ) { __heap_end = (char*)HEAP_START_ADDR; __heap_top = (char*)KSEG0_START_ADDR + get_memory_size() - STACK_SIZE; + __heap_total_size = (int)((unsigned long)__heap_top - (unsigned long)__heap_end); } prev_heap_end = __heap_end;