SDCC and malloc() - allocating much less memory than is available
- by Duncan Bayne
When I run compile this code with SDCC 3.1.0, and run it on an Amstrad CPC 464 (under emulation, with WinCPC 0.9.26 running on Wine):
void _test_malloc()
{
long idx = 0;
while (1)
{
if (malloc(5))
{
printf("%ld\r\n", ++idx);
}
else
{
printf("done");
break;
}
}
}
... it consistently taps out at 92 malloc()s. I make that 460 bytes, which leads me to a couple of questions:
What is malloc() doing on this system? I was sort of hoping for an order of magnitude more storage even on a 64kB system
The behaviour is consistent on 64kB systems and 128kB systems; do I have to perform some sort of magic to access the additional memory, like manual bank switching?