Mail Archives: djgpp/1999/02/15/07:55:21
Uhfgood writes:
> But i've set it up to alias the frames in the datafile... I
> declared an array of rle sprites like so... RLE_SPRITE
> *jumpman[ 12 ]; first I want to know if that's ok...
Sure. The dat fields are just pointers to objects: you can do anything
you like with them.
> Then at the end of my program i have a loop to destroy the
> sprites like this:
> for( c = 0; c < 12; c++ )
> destroy_rle_sprites( jumpman[ c ] );
Bad idea. The datafile routines are in charge of allocating and freeing
memory: you shouldn't go anywhere near this yourself. You've just
copied the address of the sprite objects, not the object itself, so
you don't own it and should try to destroy it. Use unload_datafile()
when you want to free up the memory. Actually, I'm surprised that
it doesn't crash when you reach this code!
Shawn Hargreaves.
- Raw text -