void *debug_osal_alloc_mem(uint16 sz)
{
void *ptr = osal_alloc_mem(sz);
if (ptr == NULL)
{
// so the memory _hasn't_ been allocated. So flash an LED or send a serial message
serial_printf("Failed to allocate %d bytes\n", sz);
// you may want to try the following to print out the return address (the address of the call to this function)
// use this line if function pointers are 16 bits
serial_printf("osal_alloc_mem called from 0x%X\n", *((uint16*)(((char*)&sz)+sizeof(sz))));
// or use this line if function pointers are 32 bits
serial_printf("osal_alloc_mem called from 0x%X\n", *((uint32*)(((char*)&sz)+sizeof(sz))));
// you may want to halt execution here...
}
return ptr;
}