gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Malloc on real hardware.

#144722 - SteveH - Tue Nov 06, 2007 1:17 am

Ok this is going to sound crazy, but it's driving me nuts right now.

I'm trying to allocate some memory in my currect project by using malloc, but it's crashing on real HW.

The code I've got is simply:

Code:

pbwNew = (pbaseWindow) malloc( sizeof( baseWindow ) );


where pbaseWindow is a pointer to a baseWindow struct. I can over come this I'm sure by using new - but I'm doing this in pure C - no classes, no fancy coding styles. I'm also having a strange issue with a switch statement, but the malloc is the most important one right now...

Any ideas on what's causing this? and that's the only malloc in the entire code base at the moment, if I comment out that one line, everything else works fine!!!

#144726 - SteveH - Tue Nov 06, 2007 1:46 am

Stupid brain fart - I worked out what the problem was - I was coping data to a malloced array and one of the bits of data was not passed correctly - DOH!!!!!