[SDL] sdl_freesurface()

Sam Lantinga slouken at devolution.com
Fri Jul 26 21:42:01 PDT 2002

> what are the conditions under which SDL_FreeSurface() will fail? I have
> a surface pointer that is not null, yet sometimes freeing it causes a
> seg fault. What are the conditions under which a surface may not be
> freed?

Do not free the surface if you have already freed it.  In C, pointers
are not automatically set to NULL when they are deallocated, so just
checking to see if the pointer is NULL is not a valid check to see
whether or not it has been freed.  If you don't already track that
information, you may want to implement some sort of reference count
tracking system.

See ya,
	-Sam Lantinga, Software Engineer, Blizzard Entertainment

More information about the SDL mailing list