Using SDL_FreeSurface

Hello,

Another basic question: I stumbled upon a post in the archives that said that you were not supposed to use SDL_FreeSurface() on a surface created through SDL_SetVideoMode(). Is this so?

The documentation mentions nothing about this and I just want to make sure that the documentation is correct.

Cheers
/ Daniel_________________________________________________________________
Hitta hetaste singlarna p? MSN Dejting!
http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952

Daniel,

That is correct, when SDL quits it will do it for you.

Tim Jones
www.sdltutorials.comOn Tue, Jun 9, 2009 at 2:57 PM, Daniel Johansson <vild.vacker at hotmail.com>wrote:

Hello,

Another basic question: I stumbled upon a post in the archives that said
that you were not supposed to use SDL_FreeSurface() on a surface created
through SDL_SetVideoMode(). Is this so?

The documentation mentions nothing about this and I just want to make
sure that the documentation is correct.

Cheers
/ Daniel


L?gg till karta och v?gbeskrivning f?r din fest. Visa v?gen!http://www.microsoft.com/windows/windowslive/events.aspx


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

If you look at the code for SDL_FreeSurface, it does actually check if the
surface you’re trying to free is the screen surface before actually freeing
it.

Calling SDL_FreeSurface on a surface created with SDL_SetVideoMode simply will
not do anything. It won’t crash your program or cause memory leaks or
whatever.On Tuesday, 9 June 2009 14:58:47 Tim Jones wrote:

Another basic question: I stumbled upon a post in the archives that
said that you were not supposed to use SDL_FreeSurface() on a surface
created through SDL_SetVideoMode(). Is this so?
That is correct, when SDL quits it will do it for you.

Ok, thanks!

Perhaps the installed documentation for SDL_FreeSurface could be updated with something like “Freeing a surface created through SDL_SetVideoMode has no effect.”

Where/who can I turn to with suggestions like these?

Cheers!
/ Daniel> From: llubnek at gmail.com

To: sdl at lists.libsdl.org
Date: Tue, 9 Jun 2009 19:52:28 -0400
Subject: Re: [SDL] Using SDL_FreeSurface

On Tuesday, 9 June 2009 14:58:47 Tim Jones wrote:

Another basic question: I stumbled upon a post in the archives that
said that you were not supposed to use SDL_FreeSurface() on a surface
created through SDL_SetVideoMode(). Is this so?
That is correct, when SDL quits it will do it for you.

If you look at the code for SDL_FreeSurface, it does actually check if the
surface you’re trying to free is the screen surface before actually freeing
it.

Calling SDL_FreeSurface on a surface created with SDL_SetVideoMode simply will
not do anything. It won’t crash your program or cause memory leaks or
whatever.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


V?rk?nslor och pirr i magen? Hitta din dr?mpartner h?r!
http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952

The SDL doc wiki, if you want: http://www.libsdl.org/cgi/docwiki.cgi/

I believe this fact is already mentioned under SDL_SetVideoMode(), but
a note under SDL_FreeSurface wouldn’t do any harm.On Wed, Jun 10, 2009 at 7:56 AM, Daniel Johansson<vild.vacker at hotmail.com> wrote:

Ok, thanks!

Perhaps the installed documentation for SDL_FreeSurface could be updated
with something like “Freeing a surface created through SDL_SetVideoMode has
no effect.”

Where/who can I turn to with suggestions like these?

Cheers!
/ Daniel

Thanks!

Is the wiki the source of the documents that are installed under the SDL/docs/… in my local installation?

Cheers!
/ Daniel> Date: Wed, 10 Jun 2009 16:04:05 +0100

From: brian.ripoff at gmail.com
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Using SDL_FreeSurface

The SDL doc wiki, if you want: http://www.libsdl.org/cgi/docwiki.cgi/

I believe this fact is already mentioned under SDL_SetVideoMode(), but
a note under SDL_FreeSurface wouldn’t do any harm.

On Wed, Jun 10, 2009 at 7:56 AM, Daniel Johansson<@Daniel_Johansson> wrote:

Ok, thanks!

Perhaps the installed documentation for SDL_FreeSurface could be updated
with something like “Freeing a surface created through SDL_SetVideoMode has
no effect.”

Where/who can I turn to with suggestions like these?

Cheers!
/ Daniel


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Vi vet vem du passar ihop med! Klicka h?r f?r att f? veta!
http://dejting.se.msn.com/channel/index.aspx?trackingid=1002952

No, for those you should probably submit a bug report
(http://bugzilla.libsdl.org/).On Wednesday, 10 June 2009 17:01:22 Daniel Johansson wrote:

Thanks!

Is the wiki the source of the documents that are installed under the
SDL/docs/… in my local installation?

Cheers!
/ Daniel

I’m trying to understand the correct way to use SDL_FreeSurface. According to the documentation found here: http://www.libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode

On success. The returned surface is freed by SDL_Quit and must not be freed by the caller…

a surface created using SDL_SetVideoMode() should not be freed using SDL_FreeSurface. At least that is how I understand it. But I have found a tutorial that uses SDL_FreeSurface on this surface: http://www.sdltutorials.com/sdl-tutorial-basics/

So if I understand correctly the tutorial is wrong. It should not be freeing that surface because it is freed by the function SDL_Quit. So if I create a window:

Code:
SDL_Surface *mwindow;
mwindow = SDL_SetVideoMode(640, 480, 32, SDL_ANYFORMAT);

then at the end of the code I should not use:

Code:
SDL_FreeSurface(mwindow);

Would somebody please confirm this for me.------------------------
OS:
Windows XP Professional
Lubuntu/Ubuntu Linux 10.10

I confirm that you don’t need to use SDL_FreeSurface on the video
SDL_Surface. The tutorial needs to be updated/fixed.On Mon, Mar 7, 2011 at 10:58 AM, Deluge wrote:

I’m trying to understand the correct way to use SDL_FreeSurface.
According to the documentation found here:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode

Quote:

On success. The returned surface is freed by SDL_Quit and must not be
freed by the caller…

a surface created using SDL_SetVideoMode() should not be freed using
SDL_FreeSurface. At least that is how I understand it. But I have found a
tutorial that uses SDL_FreeSurface on this surface:
http://www.sdltutorials.com/sdl-tutorial-basics/

So if I understand correctly the tutorial is wrong. It should not be
freeing that surface because it is freed by the function SDL_Quit. So if I
create a window:

Code:

SDL_Surface *mwindow;
mwindow = SDL_SetVideoMode(640, 480, 32, SDL_ANYFORMAT);

then at the end of the code I should not use:

Code:

SDL_FreeSurface(mwindow);

Would somebody please confirm this for me.


OS:
Windows XP Professional
Lubuntu/Ubuntu Linux 10.10


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thank you for confirming.------------------------
OS:
Windows XP Professional
Lubuntu/Ubuntu Linux 10.10