Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SDL_FreeSurface (SDL_Surface *surface)
- {
- /* Free anything that's not NULL, and not the screen surface */
- if ((surface == NULL) ||
- (current_video &&
- ((surface == SDL_ShadowSurface)||(surface == SDL_VideoSurface)))) {
- return;
- }
- if ( --surface->refcount > 0 ) {
- return;
- }
- while ( surface->locked > 0 ) {
- SDL_UnlockSurface(surface);
- }
- if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
- SDL_UnRLESurface(surface, 0);
- }
- if ( surface->format ) {
- SDL_FreeFormat(surface->format);
- surface->format = NULL;
- }
- if ( surface->map != NULL ) {
- SDL_FreeBlitMap(surface->map);
- surface->map = NULL;
- }
- if ( surface->hwdata ) {
- SDL_VideoDevice *video = current_video;
- SDL_VideoDevice *this = current_video;
- video->FreeHWSurface(this, surface);
- }
- if ( surface->pixels &&
- ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) {
- SDL_free(surface->pixels);
- }
- SDL_free(surface);
- #ifdef CHECK_LEAKS
- --surfaces_allocated;
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment