diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index dd6049af0..e322437b8 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -571,9 +571,7 @@ SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) mouse->cursors = cursor; } - if (temp) { - SDL_FreeSurface(temp); - } + SDL_FreeSurface(temp); return cursor; } diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index 96047833d..2c7e72449 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -1012,10 +1012,8 @@ SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format) break; } - if (swdata->display) { - SDL_FreeSurface(swdata->display); - swdata->display = NULL; - } + SDL_FreeSurface(swdata->display); + swdata->display = NULL; return 0; } @@ -1338,12 +1336,8 @@ SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) SDL_free(swdata->pixels); SDL_free(swdata->colortab); SDL_free(swdata->rgb_2_pix); - if (swdata->stretch) { - SDL_FreeSurface(swdata->stretch); - } - if (swdata->display) { - SDL_FreeSurface(swdata->display); - } + SDL_FreeSurface(swdata->stretch); + SDL_FreeSurface(swdata->display); SDL_free(swdata); } } diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 108f0b394..9244b28db 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -398,9 +398,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) if (src) { SDL_RWseek(src, fp_offset, RW_SEEK_SET); } - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); surface = NULL; } if (freesrc && src) { diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index dcf049468..53de05710 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1432,9 +1432,7 @@ SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon) return; } - if (window->icon) { - SDL_FreeSurface(window->icon); - } + SDL_FreeSurface(window->icon); /* Convert the icon into ARGB8888 */ window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0); @@ -2183,9 +2181,7 @@ SDL_DestroyWindow(SDL_Window * window) /* Free memory associated with the window */ SDL_free(window->title); - if (window->icon) { - SDL_FreeSurface(window->icon); - } + SDL_FreeSurface(window->icon); SDL_free(window->gamma); while (window->data) { SDL_WindowUserData *data = window->data; diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c index 74c958ab0..e373d4beb 100644 --- a/src/video/directfb/SDL_DirectFB_window.c +++ b/src/video/directfb/SDL_DirectFB_window.c @@ -237,8 +237,7 @@ DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) } return; error: - if (surface) - SDL_FreeSurface(surface); + SDL_FreeSurface(surface); SDL_DFB_RELEASE(windata->icon); return; } diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index f3904918a..f18ceea26 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -38,9 +38,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma /* Free the old framebuffer surface */ surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE); - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); /* Create a new one */ SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); @@ -83,9 +81,7 @@ void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window) SDL_Surface *surface; surface = (SDL_Surface *) SDL_SetWindowData(window, DUMMY_SURFACE, NULL); - if (surface) { - SDL_FreeSurface(surface); - } + SDL_FreeSurface(surface); } #endif /* SDL_VIDEO_DRIVER_DUMMY */ diff --git a/test/testautomation_render.c b/test/testautomation_render.c index 858679d82..e380181f7 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -190,10 +190,8 @@ int render_testPrimitives (void *arg) _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); /* Clean up. */ - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -333,10 +331,8 @@ int render_testPrimitivesBlend (void *arg) _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); /* Clean up. */ - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -400,10 +396,8 @@ render_testBlit(void *arg) /* Clean up. */ SDL_DestroyTexture( tface ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -470,10 +464,8 @@ render_testBlitColor (void *arg) /* Clean up. */ SDL_DestroyTexture( tface ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -543,10 +535,8 @@ render_testBlitAlpha (void *arg) /* Clean up. */ SDL_DestroyTexture( tface ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -655,37 +645,29 @@ render_testBlitBlend (void *arg) _testBlitBlendMode( tface, SDL_BLENDMODE_NONE ); referenceSurface = SDLTest_ImageBlitBlendNone(); _compare(referenceSurface, ALLOWABLE_ERROR_OPAQUE ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; /* Test Blend. */ _testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ); referenceSurface = SDLTest_ImageBlitBlend(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; /* Test Add. */ _testBlitBlendMode( tface, SDL_BLENDMODE_ADD ); referenceSurface = SDLTest_ImageBlitBlendAdd(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; /* Test Mod. */ _testBlitBlendMode( tface, SDL_BLENDMODE_MOD); referenceSurface = SDLTest_ImageBlitBlendMod(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED ); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; /* Clear surface. */ _clearScreen(); @@ -733,10 +715,8 @@ render_testBlitBlend (void *arg) /* Check to see if final image matches. */ referenceSurface = SDLTest_ImageBlitBlendAll(); _compare(referenceSurface, ALLOWABLE_ERROR_BLENDED); - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; return TEST_COMPLETED; } @@ -996,9 +976,7 @@ _compare(SDL_Surface *referenceSurface, int allowable_error) /* Clean up. */ SDL_free(pixels); - if (testSurface != NULL) { - SDL_FreeSurface(testSurface); - } + SDL_FreeSurface(testSurface); } /** diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index 97cc81d84..d81491837 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -63,14 +63,10 @@ _surfaceSetUp(void *arg) void _surfaceTearDown(void *arg) { - if (referenceSurface != NULL) { - SDL_FreeSurface(referenceSurface); - referenceSurface = NULL; - } - if (testSurface != NULL) { - SDL_FreeSurface(testSurface); - testSurface = NULL; - } + SDL_FreeSurface(referenceSurface); + referenceSurface = NULL; + SDL_FreeSurface(testSurface); + testSurface = NULL; } /** @@ -193,10 +189,8 @@ void _testBlitBlendMode(int mode) SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4); /* Clean up */ - if (face != NULL) { - SDL_FreeSurface(face); - face = NULL; - } + SDL_FreeSurface(face); + face = NULL; } /* Helper to check that a file exists */ @@ -250,14 +244,10 @@ surface_testSaveLoadBitmap(void *arg) unlink(sampleFilename); /* Clean up */ - if (face != NULL) { SDL_FreeSurface(face); face = NULL; - } - if (rface != NULL) { SDL_FreeSurface(rface); rface = NULL; - } return TEST_COMPLETED; } @@ -294,14 +284,10 @@ surface_testSurfaceConversion(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (face != NULL) { - SDL_FreeSurface( face ); - face = NULL; - } - if (rface != NULL) { - SDL_FreeSurface( rface ); - rface = NULL; - } + SDL_FreeSurface(face); + face = NULL; + SDL_FreeSurface(rface); + rface = NULL; return TEST_COMPLETED; } @@ -427,9 +413,7 @@ surface_testBlit(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -452,9 +436,7 @@ surface_testBlitColorMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -477,9 +459,7 @@ surface_testBlitAlphaMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -503,9 +483,7 @@ surface_testBlitBlendNone(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -528,9 +506,7 @@ surface_testBlitBlendBlend(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -553,9 +529,7 @@ surface_testBlitBlendAdd(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -578,9 +552,7 @@ surface_testBlitBlendMod(void *arg) SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface( compareSurface ); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; } @@ -603,9 +575,7 @@ surface_testBlitBlendLoop(void *arg) { SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret); /* Clean up. */ - if (compareSurface != NULL) { - SDL_FreeSurface(compareSurface); - } + SDL_FreeSurface(compareSurface); return TEST_COMPLETED; diff --git a/test/testshape.c b/test/testshape.c index 785ba1acf..c202d8ec6 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -90,8 +90,7 @@ int main(int argc,char** argv) if(pictures[i].surface == NULL) { j = 0; for(j=0;j