I have a couple of questions concerning the functions for dynamic memory allocation.
1) Before using malloc3()/free3() it is necessary to execute InitHeap3(): if I understand correctly this should be invoked just once in the whole application lifecycle to clear the whole available heap, correct? What is the exact purpose of this function? What does it mean initializing the heap?
2) How do I calculate the available heap? According to this schema and from source sample found around, the formula is:
Code: Select all
typedef unsigned long u32;
unsigned long _ramsize = 0x00200000; // 2MB
unsigned long _stacksize = 0x00008000; // 32K
#define STACK (0x80000000 + _ramsize - _stacksize)
u32 heap_base[4];
InitHeap3((u32*)heap_base, STACK-(u32)heap_base);
Thanks for any clarification.