From: RĂ©mi Duraffort Date: Wed, 12 Mar 2008 10:42:46 +0000 (+0100) Subject: Remove useless test before a free(). X-Git-Tag: 0.9.0-test0~2155 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=0f00164eb903cee76c89575ed26117332ed1ee99;p=vlc Remove useless test before a free(). --- diff --git a/modules/video_filter/atmo/AtmoConfig.h b/modules/video_filter/atmo/AtmoConfig.h index 7d3b6d6029..52c57f3fd9 100644 --- a/modules/video_filter/atmo/AtmoConfig.h +++ b/modules/video_filter/atmo/AtmoConfig.h @@ -138,7 +138,7 @@ class CAtmoConfig { #if defined(_ATMO_VLC_PLUGIN_) char *getSerialDevice() { return m_devicename; } - void setSerialDevice(char *newdevice) { if(m_devicename) free(m_devicename); if(newdevice) m_devicename = strdup(newdevice); else m_devicename = NULL; } + void setSerialDevice(char *newdevice) { free( m_devicename ); if(newdevice) m_devicename = strdup(newdevice); else m_devicename = NULL; } #else int getComport() { return m_Comport; } void setComport(int value) { m_Comport = value; } diff --git a/modules/video_filter/clone.c b/modules/video_filter/clone.c index c4d3319c85..479ebc794f 100644 --- a/modules/video_filter/clone.c +++ b/modules/video_filter/clone.c @@ -264,7 +264,7 @@ static int Init( vout_thread_t *p_vout ) msg_Err( p_vout, "failed to clone %i vout threads", p_vout->p_sys->i_clones ); p_vout->p_sys->i_clones = i_vout; - if( psz_default_vout ) free( psz_default_vout ); + free( psz_default_vout ); RemoveAllVout( p_vout ); return VLC_EGENERIC; } @@ -272,7 +272,7 @@ static int Init( vout_thread_t *p_vout ) ADD_CALLBACKS( p_vout->p_sys->pp_vout[ i_vout ], SendEvents ); } - if( psz_default_vout ) free( psz_default_vout ); + free( psz_default_vout ); ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES ); ADD_PARENT_CALLBACKS( SendEventsToChild ); diff --git a/modules/video_filter/gradient.c b/modules/video_filter/gradient.c index 300fb8bc55..604a3ac146 100644 --- a/modules/video_filter/gradient.c +++ b/modules/video_filter/gradient.c @@ -736,8 +736,8 @@ static void FilterHough( filter_t *p_filter, picture_t *p_inpic, } } - if( p_hough ) free( p_hough ); - if( p_smooth ) free( p_smooth ); + free( p_hough ); + free( p_smooth ); } #undef p_pre_hough diff --git a/modules/video_filter/marq.c b/modules/video_filter/marq.c index fe806e9a90..619c485f16 100644 --- a/modules/video_filter/marq.c +++ b/modules/video_filter/marq.c @@ -238,8 +238,8 @@ static void DestroyFilter( vlc_object_t *p_this ) filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys = p_filter->p_sys; - if( p_sys->p_style ) free( p_sys->p_style ); - if( p_sys->psz_marquee ) free( p_sys->psz_marquee ); + free( p_sys->p_style ); + free( p_sys->psz_marquee ); /* Delete the marquee variables */ #define DEL_VAR(var) \ @@ -341,7 +341,7 @@ static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var, if( !strncmp( psz_var, "marq-marquee", 7 ) ) { - if( p_sys->psz_marquee ) free( p_sys->psz_marquee ); + free( p_sys->psz_marquee ); p_sys->psz_marquee = strdup( newval.psz_string ); } else if ( !strncmp( psz_var, "marq-x", 6 ) ) diff --git a/modules/video_filter/osdmenu.c b/modules/video_filter/osdmenu.c index 45465673ed..c52644af1b 100644 --- a/modules/video_filter/osdmenu.c +++ b/modules/video_filter/osdmenu.c @@ -281,8 +281,8 @@ error: osd_MenuDelete( p_this, p_sys->p_menu ); p_sys->p_menu = NULL; - if( p_sys->psz_file ) free( p_sys->psz_file ); - if( p_sys ) free( p_sys ); + free( p_sys->psz_file ); + free( p_sys ); return VLC_EGENERIC; } @@ -328,8 +328,8 @@ static void DestroyFilter( vlc_object_t *p_this ) osd_MenuDelete( p_filter, p_sys->p_menu ); - if( p_sys->psz_file ) free( p_sys->psz_file ); - if( p_sys ) free( p_sys ); + free( p_sys->psz_file ); + free( p_sys ); } /***************************************************************************** diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index 7d60b26cf8..a43ceba7ca 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -348,8 +348,8 @@ static void DestroyFilter( vlc_object_t *p_this ) vlc_mutex_lock( &p_sys->lock ); - if( p_sys->p_style ) free( p_sys->p_style ); - if( p_sys->psz_marquee ) free( p_sys->psz_marquee ); + free( p_sys->p_style ); + free( p_sys->psz_marquee ); free( p_sys->psz_urls ); FreeRSS( p_filter ); vlc_mutex_unlock( &p_sys->lock ); @@ -740,11 +740,8 @@ static int FetchRSS( filter_t *p_filter) return 1; case XML_READER_STARTELEM: - if( psz_eltname ) - { - free( psz_eltname ); - psz_eltname = NULL; - } + free( psz_eltname ); + psz_eltname = NULL; psz_eltname = xml_ReaderName( p_xml_reader ); if( !psz_eltname ) { @@ -816,18 +813,15 @@ static int FetchRSS( filter_t *p_filter) } else { - if( psz_href ) free( psz_href ); + free( psz_href ); } - if( psz_rel ) free( psz_rel ); + free( psz_rel ); } break; case XML_READER_ENDELEM: - if( psz_eltname ) - { - free( psz_eltname ); - psz_eltname = NULL; - } + free( psz_eltname ); + psz_eltname = NULL; psz_eltname = xml_ReaderName( p_xml_reader ); if( !psz_eltname ) { diff --git a/modules/video_output/directfb.c b/modules/video_output/directfb.c index 28deb8018e..080b7b75ab 100644 --- a/modules/video_output/directfb.c +++ b/modules/video_output/directfb.c @@ -255,8 +255,7 @@ static void End( vout_thread_t *p_vout ) { vout_sys_t *p_sys = p_vout->p_sys; - if( p_sys->p_pixels ) - free( p_sys->p_pixels ); + free( p_sys->p_pixels ); } static void Destroy( vlc_object_t *p_this ) @@ -265,7 +264,7 @@ static void Destroy( vlc_object_t *p_this ) vout_sys_t *p_sys = p_vout->p_sys; CloseDisplay( p_vout ); - if( p_sys ) free( p_sys ); + free( p_sys ); p_sys = NULL; } diff --git a/modules/video_output/ggi.c b/modules/video_output/ggi.c index 0d697d284e..dc6c140741 100644 --- a/modules/video_output/ggi.c +++ b/modules/video_output/ggi.c @@ -395,7 +395,7 @@ static int OpenDisplay( vout_thread_t *p_vout ) psz_display = config_GetPsz( p_vout, "ggi_display" ); p_vout->p_sys->p_display = ggiOpen( psz_display, NULL ); - if( psz_display ) free( psz_display ); + free( psz_display ); if( p_vout->p_sys->p_display == NULL ) { diff --git a/modules/video_output/msw/directx.c b/modules/video_output/msw/directx.c index 915af9f1e2..82c1da11ab 100644 --- a/modules/video_output/msw/directx.c +++ b/modules/video_output/msw/directx.c @@ -527,11 +527,8 @@ static void CloseVideo( vlc_object_t *p_this ) p_vout->p_sys->i_spi_screensavetimeout, NULL, 0); } - if( p_vout->p_sys ) - { - free( p_vout->p_sys ); - p_vout->p_sys = NULL; - } + free( p_vout->p_sys ); + p_vout->p_sys = NULL; } /***************************************************************************** @@ -837,7 +834,7 @@ BOOL WINAPI DirectXEnumCallback( GUID* p_guid, LPTSTR psz_desc, if( ( !device.psz_string || !*device.psz_string ) && hmon == p_vout->p_sys->hmonitor ) { - if( device.psz_string ) free( device.psz_string ); + free( device.psz_string ); } else if( strcmp( psz_drivername, device.psz_string ) == 0 ) { @@ -863,11 +860,11 @@ BOOL WINAPI DirectXEnumCallback( GUID* p_guid, LPTSTR psz_desc, } p_vout->p_sys->hmonitor = hmon; - if( device.psz_string ) free( device.psz_string ); + free( device.psz_string ); } else { - if( device.psz_string ) free( device.psz_string ); + free( device.psz_string ); return TRUE; /* Keep enumerating */ } @@ -1328,11 +1325,8 @@ static void DirectXCloseDDraw( vout_thread_t *p_vout ) p_vout->p_sys->hddraw_dll = NULL; } - if( p_vout->p_sys->p_display_driver != NULL ) - { - free( p_vout->p_sys->p_display_driver ); - p_vout->p_sys->p_display_driver = NULL; - } + free( p_vout->p_sys->p_display_driver ); + p_vout->p_sys->p_display_driver = NULL; p_vout->p_sys->hmonitor = NULL; } diff --git a/modules/video_output/msw/events.c b/modules/video_output/msw/events.c index 0c50caf4a3..975519fdbe 100644 --- a/modules/video_output/msw/events.c +++ b/modules/video_output/msw/events.c @@ -316,7 +316,7 @@ void E_(EventThread)( event_thread_t *p_event ) var_Get( p_event->p_vout, "video-title", &val ); if( !val.psz_string || !*val.psz_string ) /* Default video title */ { - if( val.psz_string ) free( val.psz_string ); + free( val.psz_string ); #ifdef MODULE_NAME_IS_wingdi val.psz_string = strdup( VOUT_TITLE " (WinGDI output)" ); diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c index a8835a9ce4..a3b1ba9a7d 100644 --- a/modules/video_output/opengl.c +++ b/modules/video_output/opengl.c @@ -495,7 +495,7 @@ static int Init( vout_thread_t *p_vout ) p_sys->i_effect = OPENGL_EFFECT_NONE; #endif } - if( val.psz_string ) free( val.psz_string ); + free( val.psz_string ); if( p_sys->i_effect & ( OPENGL_EFFECT_CUBE | OPENGL_EFFECT_TRANSPARENT_CUBE ) ) @@ -553,8 +553,8 @@ static void End( vout_thread_t *p_vout ) /* Free the texture buffer*/ glDeleteTextures( 2, p_sys->p_textures ); - if( p_sys->pp_buffer[0] ) free( p_sys->pp_buffer[0] ); - if( p_sys->pp_buffer[1] ) free( p_sys->pp_buffer[1] ); + free( p_sys->pp_buffer[0] ); + free( p_sys->pp_buffer[1] ); if( p_sys->p_vout->pf_unlock ) { diff --git a/modules/video_output/x11/xcommon.c b/modules/video_output/x11/xcommon.c index aa1b36f679..0563c19c8b 100644 --- a/modules/video_output/x11/xcommon.c +++ b/modules/video_output/x11/xcommon.c @@ -224,10 +224,10 @@ int E_(Activate) ( vlc_object_t *p_this ) msg_Err( p_vout, "cannot open display %s", XDisplayName( psz_display ) ); free( p_vout->p_sys ); - if( psz_display ) free( psz_display ); + free( psz_display ); return VLC_EGENERIC; } - if( psz_display ) free( psz_display ); + free( psz_display ); /* Replace error handler so we can intercept some non-fatal errors */ XSetErrorHandler( X11ErrorHandler ); @@ -1698,7 +1698,7 @@ static int CreateWindow( vout_thread_t *p_vout, x11_window_t *p_win ) XStoreName( p_vout->p_sys->p_display, p_win->base_window, val.psz_string ); } - if( val.psz_string ) free( val.psz_string ); + free( val.psz_string ); if( !p_vout->b_fullscreen ) {