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.
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.
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.
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?
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.
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?
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?
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:
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:
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: