It appears that the LinkCmd used by Project Builder does not correctly define the top of the heap -
I was testing a new "safeMalloc" routine to help diagnose the errors we came across in my scanline renderer, and found it was impossible to trigger the error condition (system malloc returning null). Mateo was able to compile offline and found that everything worked as expected on his system.
- Code: Select all
void* safeMalloc(size_t bytes){
void *const mem = malloc(bytes);
if(!mem){
_OS(cleanUp() );
asm("LD A,E_Memory");
asm("LD (errNo),A");
asm("JP _JErrorNo");
}
return mem;
}
elsewhere:
- Code: Select all
uint8_t *j = safeMalloc(700000);
if(!j) print("GOT NULL",0,0);
else print("HUGE MALLOC",0,0);
_OS(GetKey());