Fixed bug #255
authorSam Lantinga <slouken@libsdl.org>
Sat, 24 Jun 2006 03:41:14 +0000
changeset 188161f86f36afb9
parent 1880 9d940db55a91
child 1882 339d733e3699
Fixed bug #255

Fixed memory leaks in the windib driver.
src/video/windib/SDL_dibvideo.c
     1.1 --- a/src/video/windib/SDL_dibvideo.c	Sat Jun 24 01:59:43 2006 +0000
     1.2 +++ b/src/video/windib/SDL_dibvideo.c	Sat Jun 24 03:41:14 2006 +0000
     1.3 @@ -413,6 +413,7 @@
     1.4  	ReleaseDC(SDL_Window, hdc);
     1.5  	return(depth);
     1.6  #else
     1.7 +    int depth;
     1.8      int dib_size;
     1.9      LPBITMAPINFOHEADER dib_hdr;
    1.10      HDC hdc;
    1.11 @@ -441,21 +442,23 @@
    1.12      DeleteObject(hbm);
    1.13      ReleaseDC(NULL, hdc);
    1.14  
    1.15 +    depth = 0;
    1.16      switch( dib_hdr->biBitCount )
    1.17      {
    1.18 -    case 8:     return 8;
    1.19 -    case 24:    return 24;
    1.20 -    case 32:    return 32;
    1.21 +    case 8:     depth = 8; break;
    1.22 +    case 24:    depth = 24; break;
    1.23 +    case 32:    depth = 32; break;
    1.24      case 16:
    1.25          if( dib_hdr->biCompression == BI_BITFIELDS ) {
    1.26              /* check the red mask */
    1.27              switch( ((DWORD*)((char*)dib_hdr + dib_hdr->biSize))[0] ) {
    1.28 -                case 0xf800: return 16;    /* 565 */
    1.29 -                case 0x7c00: return 15;    /* 555 */
    1.30 +                case 0xf800: depth = 16; break;   /* 565 */
    1.31 +                case 0x7c00: depth = 15; break;   /* 555 */
    1.32              }
    1.33          }
    1.34      }
    1.35 -    return 0;    /* poo. */
    1.36 +    SDL_free(dib_hdr);
    1.37 +    return depth;
    1.38  #endif /* NO_GETDIBITS */
    1.39  }
    1.40  
    1.41 @@ -1024,6 +1027,8 @@
    1.42  
    1.43  void DIB_VideoQuit(_THIS)
    1.44  {
    1.45 +	int i, j;
    1.46 +
    1.47  	/* Destroy the window and everything associated with it */
    1.48  	if ( SDL_Window ) {
    1.49  		/* Delete the screen bitmap (also frees screen->pixels) */
    1.50 @@ -1061,7 +1066,18 @@
    1.51  			aygshell = NULL;
    1.52  		}
    1.53  #endif
    1.54 +	}
    1.55  
    1.56 +	for ( i=0; i < SDL_arraysize(SDL_modelist); ++i ) {
    1.57 +		if ( !SDL_modelist[i] ) {
    1.58 +			continue;
    1.59 +		}
    1.60 +		for ( j=0; SDL_modelist[i][j]; ++j ) {
    1.61 +			SDL_free(SDL_modelist[i][j]);
    1.62 +		}
    1.63 +		SDL_free(SDL_modelist[i]);
    1.64 +		SDL_modelist[i] = NULL;
    1.65 +		SDL_nummodes[i] = 0;
    1.66  	}
    1.67  }
    1.68