Page 2 of 2
Re: Making STL Vectors and SDL_Surfaces place nicely
Posted: Sun Oct 09, 2011 9:03 am
by dandymcgee
Word of advice: After you free a surface (or delete anything for that matter) you should set the pointer to NULL. In this case you don't even need to check for NULL before calling SDL_FreeSurface, because it handles them nicely, i.e., checks and does nothing.
Re: Making STL Vectors and SDL_Surfaces place nicely
Posted: Sun Oct 09, 2011 3:03 pm
by treyrust
dandymcgee wrote:Word of advice: After you free a surface (or delete anything for that matter) you should set the pointer to NULL. In this case you don't even need to check for NULL before calling SDL_FreeSurface, because it handles them nicely, i.e., checks and does nothing.
Neat, but you should be careful what NULL pointers you pass to any part of SDL, I'm not saying SDL_FreeSurface doesn't handle it well but other parts are not so nice. But good advice either way, you should never have a pointer that isn't either pointing to something useful or NULL.