delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/15/07:55:21

Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE3535870@probe-2.acclaim-euro.net>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: -KWII- Allegro and RLE sprites
Date: Mon, 15 Feb 1999 12:53:36 -0000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1460.8)
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019