GP32 Free Mem


pea

developer
Joined
Oct 3, 2004
Messages
1,089
Age
46
Location
New Zealand
Website
www.projectitis.com
Hi all,

Relatively simple I shoul;d hope for someone in the know:
How do I return the available free memory using Mr.Mirkos SDK?
I use 'malloc' for all manual memory allocation.

EDIT: Changed 'memset' to 'malloc'. Stupid me :)
 
pea posted on Apr 26 2005 at 07:03 AM said:
Hi all,

Relatively simple I shoul;d hope for someone in the know:
How do I return the available free memory using Mr.Mirkos SDK?
I use 'memset' for all manual memory allocation.

I don't know, but I hope you made a mistake and wanted to say malloc(), calloc() or similar instead of memset()!!
Because if you initialize your memory instead of allocating it, you we'll end having a lot of troubles!!

Oankali
 
Last edited by a moderator:
Mirko doesn't replace any of the memory functions, so it'll be standard "malloc" and "free". I don't think there's a way of getting the current amount of memory free, unless you want to walk the free list and do lots of pointer calculations.
 
There is the function:
mallinfo();
Which returns a struct with lots of useful info (including used and free memory, in bytes). This is available within malloc.h, but when I try to compile it with Mr.Mirkos SDK, I get a couple of linker errors:

/cygdrive/c/gp32_MrMirko/bin/../lib/gcc/arm-elf/3.4.0/../../../../arm-elf/lib/li
bc.a(mstats.o)(.text+0x30): In function `malloc_stats':
: undefined reference to `_malloc_stats_r'
/cygdrive/c/gp32_MrMirko/bin/../lib/gcc/arm-elf/3.4.0/../../../../arm-elf/lib/li
bc.a(mstats.o)(.text+0x7c): In function `_mstats_r':
: undefined reference to `_malloc_stats_r'
collect2: ld returned 1 exit status

So there are a couple of functions it can't find. Any ideas?
Do I need to recompile libc.a? If I do, is this difficult?
 
Back
Top