[SDL] Problens with free surface

Lilith Calbridge lilith at dcccd.edu
Sat Jul 14 08:27:58 PDT 2007



>>> On 7/14/2007 at 9:23 AM, "David Olsen" <jolynsbass at gmail.com>
wrote:

> ----- Original Message ----- 
> From: "Ulrich Eckhardt" <doomster at knuut.de>
> To: <sdl at lists.libsdl.org>
> Sent: Friday, July 13, 2007 5:04 AM
> Subject: Re: [SDL] Problens with free surface
> 
> 
> *snip*
> 
>>
>> I can't find this function anywhere in SDL, are you using the
external
>> SDL_Resize lib? If so, this function supposedly returns a new
surface(!)
>> which obviously needs to be used from then on and also freed.
Digging into
>> said library, it gets even worse: it seems like the input surface
is
>> destroyed(WTF?) so you must not use sfcResized after calling this 
>> function.
>> This library is so broken, words fail me. Well, after all the
behaviour is
>> documented (read the headers!) but still.
>>
> 
> Hi Ulrich,
> I don't understand why you say it is "so broken" that words fail you!
It 
> works great for me and I know other people have used it just fine as
well... 
> 
> Ruben was using it incorrectly, no wonder he had problems. (I had
trouble 
> using SDL at first... it wasn't because SDL was broken - I had to
learn how 
> to use it!)
> Of course it returns a new surface - if you want a resized surface,
it can't 
> be just the old one! Is there something "broken" about returning an 
> SDL_Surface *?

I won't claim expertise on this since I haven't studied the source
code.  But this relates to something that ran through my head when I was
looking at the SDL_ConvertSurface function.  It too returns a new
surface.  In my mind it would be beneficial to actually convert/resize a
surface and return a pointer that can be re-assigned to the pointer of
the surface being passed in the  convert/resize function.

SDL_Surface *blah;
.
// do stuff with surface
.
blah = SDL_ConvertSurface (blah, ...... ;

where you pass the pointer to the surface to the function and return a
value that can be re-assigned to the same pointer.  This would probably
require some internal freeing of the original surface rather than leave
it to the programmer to do some temporary trade outs.  At the same time
the function would have to be safe enough to assign the converted
surface to a totally new surface pointer also.

-- 
Lilith


More information about the SDL mailing list