shadowm

Untitled

Apr 16th, 2015
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. void SDL_FreeSurface (SDL_Surface *surface)
  2. {
  3.     /* Free anything that's not NULL, and not the screen surface */
  4.     if ((surface == NULL) ||
  5.         (current_video &&
  6.         ((surface == SDL_ShadowSurface)||(surface == SDL_VideoSurface)))) {
  7.         return;
  8.     }
  9.     if ( --surface->refcount > 0 ) {
  10.         return;
  11.     }
  12.     while ( surface->locked > 0 ) {
  13.         SDL_UnlockSurface(surface);
  14.     }
  15.     if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
  16.             SDL_UnRLESurface(surface, 0);
  17.     }
  18.     if ( surface->format ) {
  19.         SDL_FreeFormat(surface->format);
  20.         surface->format = NULL;
  21.     }
  22.     if ( surface->map != NULL ) {
  23.         SDL_FreeBlitMap(surface->map);
  24.         surface->map = NULL;
  25.     }
  26.     if ( surface->hwdata ) {
  27.         SDL_VideoDevice *video = current_video;
  28.         SDL_VideoDevice *this  = current_video;
  29.         video->FreeHWSurface(this, surface);
  30.     }
  31.     if ( surface->pixels &&
  32.          ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) {
  33.         SDL_free(surface->pixels);
  34.     }
  35.     SDL_free(surface);
  36. #ifdef CHECK_LEAKS
  37.     --surfaces_allocated;
  38. #endif
  39. }
Advertisement
Add Comment
Please, Sign In to add comment