From 6411526fe052a033300e73045b07c0aaee089e88 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Duraffort?= Date: Fri, 14 Mar 2008 00:24:00 +0100 Subject: [PATCH] One more removing session. (useless test before a free()) --- modules/control/http/http.c | 18 +++++------------- modules/control/http/util.c | 10 ++-------- modules/control/lirc.c | 3 +-- modules/control/ntservice.c | 9 +++------ modules/demux/flac.c | 12 ++++-------- modules/demux/mjpeg.c | 5 +---- modules/demux/mp4/libmp4.c | 3 +-- modules/demux/nuv.c | 10 +++------- modules/demux/playlist/itml.h | 8 ++++---- modules/demux/playlist/pls.c | 25 +++++++------------------ modules/demux/subtitle_asa.c | 8 ++------ modules/demux/ts.c | 9 +++------ modules/demux/ty.c | 33 +++++++++++---------------------- 13 files changed, 47 insertions(+), 106 deletions(-) diff --git a/modules/control/http/http.c b/modules/control/http/http.c index 6a0e593de2..ff46c7d4d5 100644 --- a/modules/control/http/http.c +++ b/modules/control/http/http.c @@ -201,8 +201,7 @@ static int Open( vlc_object_t *p_this ) TAB_APPEND( p_sys->i_handlers, p_sys->pp_handlers, p_handler ); } } - if( psz_src != NULL ) - free( psz_src ); + free( psz_src ); #endif /* determine SSL configuration */ @@ -275,11 +274,8 @@ static int Open( vlc_object_t *p_this ) }; unsigned i; - if( psz_src != NULL ) - { - free( psz_src ); - psz_src = NULL; - } + free( psz_src ); + psz_src = NULL; for( i = 0; ppsz_paths[i] != NULL; i++ ) if( !DirectoryCheck( ppsz_paths[i] ) ) @@ -372,10 +368,7 @@ static void Close ( vlc_object_t *p_this ) free( p_sys->pp_files[i]->name ); free( p_sys->pp_files[i] ); } - if( p_sys->pp_files ) - { - free( p_sys->pp_files ); - } + free( p_sys->pp_files ); for( i = 0; i < p_sys->i_handlers; i++ ) { http_association_t *p_handler = p_sys->pp_handlers[i]; @@ -794,8 +787,7 @@ int E_(HandlerCallback)( httpd_handler_sys_t *p_args, NULL ); TAB_REMOVE( p_args->p_association->i_argc, p_args->p_association->ppsz_argv, psz_file ); - if( psz_cwd != NULL ) - free( psz_cwd ); + free( psz_cwd ); while( i_env ) TAB_REMOVE( i_env, ppsz_env, ppsz_env[0] ); diff --git a/modules/control/http/util.c b/modules/control/http/util.c index a6a2a27846..564ab4a358 100644 --- a/modules/control/http/util.c +++ b/modules/control/http/util.c @@ -328,14 +328,8 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root, } } - if( user ) - { - free( user ); - } - if( password ) - { - free( password ); - } + free( user ); + free( password ); ACL_Destroy( p_acl ); closedir( p_dir ); diff --git a/modules/control/lirc.c b/modules/control/lirc.c index 67cd2962ed..0957985e1e 100644 --- a/modules/control/lirc.c +++ b/modules/control/lirc.c @@ -123,8 +123,7 @@ static void Close( vlc_object_t *p_this ) intf_thread_t *p_intf = (intf_thread_t *)p_this; /* Destroy structure */ - if( p_intf->p_sys->psz_file ) - free( p_intf->p_sys->psz_file ); + free( p_intf->p_sys->psz_file ); lirc_freeconfig( p_intf->p_sys->config ); lirc_deinit(); free( p_intf->p_sys ); diff --git a/modules/control/ntservice.c b/modules/control/ntservice.c index b8b567bf8b..4d52d14a84 100644 --- a/modules/control/ntservice.c +++ b/modules/control/ntservice.c @@ -196,7 +196,7 @@ static int NTServiceInstall( intf_thread_t *p_intf ) strcat( psz_path, " --ntservice-extraintf " ); strcat( psz_path, psz_extra ); } - if( psz_extra ) free( psz_extra ); + free( psz_extra ); psz_extra = config_GetPsz( p_intf, "ntservice-options" ); if( psz_extra && *psz_extra ) @@ -204,7 +204,7 @@ static int NTServiceInstall( intf_thread_t *p_intf ) strcat( psz_path, " " ); strcat( psz_path, psz_extra ); } - if( psz_extra ) free( psz_extra ); + free( psz_extra ); SC_HANDLE service = CreateService( handle, p_sys->psz_service, p_sys->psz_service, @@ -338,10 +338,7 @@ static void WINAPI ServiceDispatch( DWORD numArgs, char **args ) free( psz_temp ); } } - if( psz_modules ) - { - free( psz_modules ); - } + free( psz_modules ); /* Initialization complete - report running status */ p_sys->status.dwCurrentState = SERVICE_RUNNING; diff --git a/modules/demux/flac.c b/modules/demux/flac.c index 9be5869b68..756573d292 100644 --- a/modules/demux/flac.c +++ b/modules/demux/flac.c @@ -150,8 +150,7 @@ static int Open( vlc_object_t * p_this ) module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 ); if( !p_sys->p_packetizer->p_module ) { - if( p_sys->p_packetizer->fmt_in.p_extra ) - free( p_sys->p_packetizer->fmt_in.p_extra ); + free( p_sys->p_packetizer->fmt_in.p_extra ); vlc_object_release( p_sys->p_packetizer ); msg_Err( p_demux, "cannot find flac packetizer" ); @@ -189,8 +188,7 @@ static void Close( vlc_object_t * p_this ) /* Unneed module */ module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module ); - if( p_sys->p_packetizer->fmt_in.p_extra ) - free( p_sys->p_packetizer->fmt_in.p_extra ); + free( p_sys->p_packetizer->fmt_in.p_extra ); /* Delete the decoder */ vlc_object_release( p_sys->p_packetizer ); @@ -712,10 +710,8 @@ static void ParsePicture( demux_t *p_demux, const uint8_t *p_data, int i_data ) p_sys->i_cover_score = pi_cover_score[i_type]; } error: - if( psz_mime ) - free( psz_mime ); - if( psz_description ) - free( psz_description ); + free( psz_mime ); + free( psz_description ); } #undef RM diff --git a/modules/demux/mjpeg.c b/modules/demux/mjpeg.c index c3e77e8f82..c7096ed2b9 100644 --- a/modules/demux/mjpeg.c +++ b/modules/demux/mjpeg.c @@ -511,10 +511,7 @@ static void Close ( vlc_object_t * p_this ) demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys = p_demux->p_sys; - if( p_sys->psz_separator ) - { - free( p_sys->psz_separator ); - } + free( p_sys->psz_separator ); free( p_sys ); } diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c index a8af7fd5e3..b28a989622 100644 --- a/modules/demux/mp4/libmp4.c +++ b/modules/demux/mp4/libmp4.c @@ -1208,8 +1208,7 @@ static int MP4_ReadBox_sample_soun( stream_t *p_stream, MP4_Box_t *p_box ) if( p_box->i_type == FOURCC_alac ) { - if( p_box->data.p_sample_soun->p_qt_description ) - free( p_box->data.p_sample_soun->p_qt_description ); + free( p_box->data.p_sample_soun->p_qt_description ); p_box->data.p_sample_soun->p_qt_description = malloc( i_read ); p_box->data.p_sample_soun->i_qt_description = i_read; diff --git a/modules/demux/nuv.c b/modules/demux/nuv.c index 5b41cd8294..4856c8636d 100644 --- a/modules/demux/nuv.c +++ b/modules/demux/nuv.c @@ -316,8 +316,7 @@ static void Close( vlc_object_t * p_this ) demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys = p_demux->p_sys; - if( p_sys->p_extra_f ) - free( p_sys->p_extra_f ); + free( p_sys->p_extra_f ); demux_IndexClean( &p_sys->idx ); free( p_sys ); } @@ -644,11 +643,8 @@ static void demux_IndexInit( demux_index_t *p_idx ) } static void demux_IndexClean( demux_index_t *p_idx ) { - if( p_idx->idx ) - { - free( p_idx->idx ); - p_idx->idx = NULL; - } + free( p_idx->idx ); + p_idx->idx = NULL; } static void demux_IndexAppend( demux_index_t *p_idx, int64_t i_time, int64_t i_offset ) diff --git a/modules/demux/playlist/itml.h b/modules/demux/playlist/itml.h index b1514345f6..4042a96d88 100644 --- a/modules/demux/playlist/itml.h +++ b/modules/demux/playlist/itml.h @@ -26,10 +26,10 @@ */ /* defines */ -#define FREE(v) if (v) {free(v);v=NULL;} -#define FREE_NAME() if (psz_name) {free(psz_name);psz_name=NULL;} -#define FREE_VALUE() if (psz_value) {free(psz_value);psz_value=NULL;} -#define FREE_KEY() if (psz_key) {free(psz_key);psz_key=NULL;} +#define FREE(v) free(v);v=NULL; +#define FREE_NAME() free(psz_name);psz_name=NULL; +#define FREE_VALUE() free(psz_value);psz_value=NULL; +#define FREE_KEY() free(psz_key);psz_key=NULL; #define FREE_ATT() FREE_NAME();FREE_VALUE() #define FREE_ATT_KEY() FREE_NAME();FREE_VALUE();FREE_KEY() diff --git a/modules/demux/playlist/pls.c b/modules/demux/playlist/pls.c index 649be46f6f..7006b49a02 100644 --- a/modules/demux/playlist/pls.c +++ b/modules/demux/playlist/pls.c @@ -73,10 +73,7 @@ int E_(Import_PLS)( vlc_object_t *p_this ) void E_(Close_PLS)( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; - if( p_demux->p_sys->psz_prefix ) - { - free( p_demux->p_sys->psz_prefix ); - } + free( p_demux->p_sys->psz_prefix ); free( p_demux->p_sys ); } @@ -172,11 +169,8 @@ static int Demux( demux_t *p_demux ) { msg_Warn( p_demux, "no file= part found for item %d", i_item ); } - if( psz_name ) - { - free( psz_name ); - psz_name = NULL; - } + free( psz_name ); + psz_name = NULL; i_duration = -1; i_item = i_new_item; i_new_item = 0; @@ -184,8 +178,7 @@ static int Demux( demux_t *p_demux ) if( !strncasecmp( psz_key, "file", sizeof("file") -1 ) || !strncasecmp( psz_key, "Ref", sizeof("Ref") -1 ) ) { - if( psz_mrl_orig ) - free( psz_mrl_orig ); + free( psz_mrl_orig ); psz_mrl_orig = psz_mrl = E_(ProcessMRL)( psz_value, p_demux->p_sys->psz_prefix ); @@ -202,8 +195,7 @@ static int Demux( demux_t *p_demux ) } else if( !strncasecmp( psz_key, "title", sizeof("title") -1 ) ) { - if( psz_name ) - free( psz_name ); + free( psz_name ); psz_name = strdup( psz_value ); } else if( !strncasecmp( psz_key, "length", sizeof("length") -1 ) ) @@ -234,11 +226,8 @@ static int Demux( demux_t *p_demux ) { msg_Warn( p_demux, "no file= part found for item %d", i_item ); } - if( psz_name ) - { - free( psz_name ); - psz_name = NULL; - } + free( psz_name ); + psz_name = NULL; HANDLE_PLAY_AND_RELEASE; return 0; /* Needed for correct operation of go back */ diff --git a/modules/demux/subtitle_asa.c b/modules/demux/subtitle_asa.c index 99f091310b..0d3f67005f 100644 --- a/modules/demux/subtitle_asa.c +++ b/modules/demux/subtitle_asa.c @@ -310,12 +310,8 @@ static void Close( vlc_object_t *p_this ) int i; for( i = 0; i < p_sys->i_subtitles; i++ ) - { - if( p_sys->subtitle[i].psz_text ) - free( p_sys->subtitle[i].psz_text ); - } - if( p_sys->subtitle ) - free( p_sys->subtitle ); + free( p_sys->subtitle[i].psz_text ); + free( p_sys->subtitle ); free( p_sys ); } diff --git a/modules/demux/ts.c b/modules/demux/ts.c index becc5b7f7b..bf78f9783d 100644 --- a/modules/demux/ts.c +++ b/modules/demux/ts.c @@ -2399,12 +2399,9 @@ static void IODFree( iod_descriptor_t *p_iod ) } else { - if( es_descr.dec_descr.p_decoder_specific_info != NULL ) - { - free( es_descr.dec_descr.p_decoder_specific_info ); - es_descr.dec_descr.p_decoder_specific_info = NULL; - es_descr.dec_descr.i_decoder_specific_info_len = 0; - } + free( es_descr.dec_descr.p_decoder_specific_info ); + es_descr.dec_descr.p_decoder_specific_info = NULL; + es_descr.dec_descr.i_decoder_specific_info_len = 0; } } es_descr.b_ok = 0; diff --git a/modules/demux/ty.c b/modules/demux/ty.c index 51e8a05995..04547b1b84 100644 --- a/modules/demux/ty.c +++ b/modules/demux/ty.c @@ -545,8 +545,7 @@ static void Close( vlc_object_t *p_this ) XdsExit( &p_sys->xds ); cc_Exit( &p_sys->cc ); free( p_sys->rec_hdrs ); - if( p_sys->seq_table ) - free( p_sys->seq_table ); + free( p_sys->seq_table ); free(p_sys); } @@ -1127,23 +1126,16 @@ static void XdsInit( xds_t *h ) static void XdsExit( xds_t *h ) { /* */ - if( h->meta.psz_channel_name ) - free( h->meta.psz_channel_name ); - if( h->meta.psz_channel_call_letter ) - free( h->meta.psz_channel_call_letter ); - if( h->meta.psz_channel_number ) - free( h->meta.psz_channel_number ); + free( h->meta.psz_channel_name ); + free( h->meta.psz_channel_call_letter ); + free( h->meta.psz_channel_number ); /* */ - if( h->meta.current.psz_name ) - free( h->meta.current.psz_name ); - if( h->meta.current.psz_rating ) - free( h->meta.current.psz_rating ); + free( h->meta.current.psz_name ); + free( h->meta.current.psz_rating ); /* */ - if( h->meta.future.psz_name ) - free( h->meta.future.psz_name ); - if( h->meta.future.psz_rating ) - free( h->meta.future.psz_rating ); + free( h->meta.future.psz_name ); + free( h->meta.future.psz_rating ); } static void XdsStringUtf8( char dst[2*32+1], const uint8_t *p_src, int i_src ) { @@ -1179,8 +1171,7 @@ static vlc_bool_t XdsChangeString( xds_t *h, char **ppsz_dst, const char *psz_ne if( *ppsz_dst == NULL && psz_new == NULL ) return VLC_FALSE; - if( *ppsz_dst ) - free( *ppsz_dst ); + free( *ppsz_dst ); if( psz_new ) *ppsz_dst = strdup( psz_new ); else @@ -1641,8 +1632,7 @@ static void parse_master(demux_t *p_demux) entire table directly from the stream into memory in place. */ /* clear the SEQ table */ - if (p_sys->seq_table != NULL) - free(p_sys->seq_table); + free(p_sys->seq_table); /* parse header info */ stream_Read(p_demux->s, mst_buf, 32); @@ -1900,8 +1890,7 @@ static int get_chunk_header(demux_t *p_demux) /*msg_Dbg( p_demux, "chunk has %d records", i_num_recs );*/ - if (p_sys->rec_hdrs) - free(p_sys->rec_hdrs); + free(p_sys->rec_hdrs); /* skip past the 4 bytes we "peeked" earlier */ stream_Read( p_demux->s, NULL, 4 ); -- 2.39.2