From: RĂ©mi Duraffort Date: Tue, 11 Mar 2008 21:26:54 +0000 (+0100) Subject: Remove useless test before a free (again). X-Git-Tag: 0.9.0-test0~2176 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=bcddfd6382fb71b0021008eb63f1bc4a1b1bae0e;p=vlc Remove useless test before a free (again). --- diff --git a/modules/demux/asf/libasf.c b/modules/demux/asf/libasf.c index 8453b0f017..0ac06b7dab 100644 --- a/modules/demux/asf/libasf.c +++ b/modules/demux/asf/libasf.c @@ -314,10 +314,10 @@ static void ASF_FreeObject_metadata( asf_object_t *p_obj ) for( i = 0; i < p_meta->i_record_entries_count; i++ ) { - if( p_meta->record[i].psz_name ) free( p_meta->record[i].psz_name ); - if( p_meta->record[i].p_data ) free( p_meta->record[i].p_data ); + free( p_meta->record[i].psz_name ); + free( p_meta->record[i].p_data ); } - if( p_meta->record ) free( p_meta->record ); + free( p_meta->record ); } static int ASF_ReadObject_metadata( stream_t *s, asf_object_t *p_obj ) diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c index d991dcd999..dfd8947828 100644 --- a/modules/demux/avi/libavi.c +++ b/modules/demux/avi/libavi.c @@ -444,7 +444,7 @@ static int AVI_ChunkRead_strd( stream_t *s, avi_chunk_t *p_chk ) static void AVI_ChunkFree_strd( avi_chunk_t *p_chk ) { - if( p_chk->strd.p_data ) free( p_chk->strd.p_data ); + free( p_chk->strd.p_data ); } static int AVI_ChunkRead_idx1( stream_t *s, avi_chunk_t *p_chk ) diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp index 710aa6a04b..ce52ecd1e6 100644 --- a/modules/demux/live555.cpp +++ b/modules/demux/live555.cpp @@ -400,9 +400,9 @@ error: vlc_object_detach( p_sys->p_timeout ); vlc_object_release( p_sys->p_timeout ); } - if( p_sys->scheduler ) delete p_sys->scheduler; - if( p_sys->p_sdp ) free( p_sys->p_sdp ); - if( p_sys->psz_path ) free( p_sys->psz_path ); + delete p_sys->scheduler; + free( p_sys->p_sdp ); + free( p_sys->psz_path ); vlc_UrlClean( &p_sys->url ); @@ -441,9 +441,9 @@ static void Close( vlc_object_t *p_this ) vlc_object_detach( p_sys->p_timeout ); vlc_object_release( p_sys->p_timeout ); } - if( p_sys->scheduler ) delete p_sys->scheduler; - if( p_sys->p_sdp ) free( p_sys->p_sdp ); - if( p_sys->psz_path ) free( p_sys->psz_path ); + delete p_sys->scheduler; + free( p_sys->p_sdp ); + free( p_sys->psz_path ); vlc_UrlClean( &p_sys->url ); @@ -563,8 +563,8 @@ describe: int i_result; msg_Dbg( p_demux, "authentication failed" ); - if( psz_user ) free( psz_user ); - if( psz_pwd ) free( psz_pwd ); + free( psz_user ); + free( psz_pwd ); psz_user = psz_pwd = NULL; i_result = intf_UserLoginPassword( p_demux, _("RTSP authentication"), @@ -599,11 +599,11 @@ describe: } /* malloc-ated copy */ - if( psz_url ) free( psz_url ); - if( psz_user ) free( psz_user ); - if( psz_pwd ) free( psz_pwd ); + free( psz_url ); + free( psz_user ); + free( psz_pwd ); - if( p_sys->p_sdp ) free( p_sys->p_sdp ); + free( p_sys->p_sdp ); p_sys->p_sdp = NULL; if( p_sdp ) p_sys->p_sdp = strdup( (char*)p_sdp ); delete[] p_sdp; @@ -1882,7 +1882,7 @@ static unsigned char* parseH264ConfigStr( char const* configStr, psz += strlen(psz)+1; } - if( dup ) free( dup ); + free( dup ); return cfg; } diff --git a/modules/demux/mkv.cpp b/modules/demux/mkv.cpp index e0ea9a7a3f..32073d2199 100644 --- a/modules/demux/mkv.cpp +++ b/modules/demux/mkv.cpp @@ -1048,35 +1048,17 @@ public: delete tracks[i_track]->p_compression_data; } es_format_Clean( &tracks[i_track]->fmt ); - if( tracks[i_track]->p_extra_data ) - free( tracks[i_track]->p_extra_data ); - if( tracks[i_track]->psz_codec ) - free( tracks[i_track]->psz_codec ); + free( tracks[i_track]->p_extra_data ); + free( tracks[i_track]->psz_codec ); delete tracks[i_track]; } - if( psz_writing_application ) - { - free( psz_writing_application ); - } - if( psz_muxing_application ) - { - free( psz_muxing_application ); - } - if( psz_segment_filename ) - { - free( psz_segment_filename ); - } - if( psz_title ) - { - free( psz_title ); - } - if( psz_date_utc ) - { - free( psz_date_utc ); - } - if ( p_indexes ) - free( p_indexes ); + free( psz_writing_application ); + free( psz_muxing_application ); + free( psz_segment_filename ); + free( psz_title ); + free( psz_date_utc ); + free( p_indexes ); delete ep; delete segment; @@ -1313,7 +1295,7 @@ public: {} virtual ~attachment_c() { - if( p_data ) free( p_data ); + free( p_data ); } std::string psz_file_name; diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c index 4ee33e7d5c..ee0659462e 100644 --- a/modules/demux/mp4/mp4.c +++ b/modules/demux/mp4/mp4.c @@ -439,7 +439,7 @@ static int Open( vlc_object_t * p_this ) msg_Err( p_demux, "unknown ref type=%4.4s FIXME (send a bug report)", (char*)&p_rdrf->data.p_rdrf->i_ref_type ); } - if( psz_ref ) free( psz_ref ); + free( psz_ref ); } if( b_play && p_item_in_category && p_item_in_category->i_children > 0 ) diff --git a/modules/demux/nsc.c b/modules/demux/nsc.c index e1a25799b1..d6561d3547 100644 --- a/modules/demux/nsc.c +++ b/modules/demux/nsc.c @@ -341,7 +341,7 @@ static int ParseLine ( demux_t *p_demux, char *psz_line ) if( psz_out ) { msg_Dbg( p_demux, "%s = %s", psz_bol, psz_out ); - if( psz_out) free( psz_out ); + free( psz_out ); } } return VLC_SUCCESS; @@ -359,7 +359,7 @@ static int Demux ( demux_t *p_demux ) while( ( psz_line = stream_ReadLine( p_demux->s ) ) ) { ParseLine( p_demux, psz_line ); - if( psz_line ) free( psz_line ); + free( psz_line ); } return VLC_SUCCESS; } diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c index 6c9c15f973..ab3c081bd8 100644 --- a/modules/demux/ogg.c +++ b/modules/demux/ogg.c @@ -1191,8 +1191,7 @@ static void Ogg_EndOfStream( demux_t *p_demux ) p_ogg->i_bitrate -= p_stream->fmt.i_bitrate; ogg_stream_clear( &p_ogg->pp_stream[i_stream]->os ); - if( p_ogg->pp_stream[i_stream]->p_headers) - free( p_ogg->pp_stream[i_stream]->p_headers ); + free( p_ogg->pp_stream[i_stream]->p_headers ); es_format_Clean( &p_stream->fmt ); @@ -1201,7 +1200,7 @@ static void Ogg_EndOfStream( demux_t *p_demux ) #undef p_stream /* Reinit p_ogg */ - if( p_ogg->pp_stream ) free( p_ogg->pp_stream ); + free( p_ogg->pp_stream ); p_ogg->pp_stream = NULL; p_ogg->i_streams = 0; } diff --git a/modules/demux/playlist/asx.c b/modules/demux/playlist/asx.c index b24c91772b..de4a968ddb 100644 --- a/modules/demux/playlist/asx.c +++ b/modules/demux/playlist/asx.c @@ -61,7 +61,7 @@ static int StoreString( demux_t *p_demux, char **ppsz_string, demux_sys_t *p_sys = p_demux->p_sys; unsigned len = psz_source_end - psz_source_start; - if( *ppsz_string ) free( *ppsz_string ); + free( *ppsz_string ); char *buf = *ppsz_string = malloc ((len * (1 + !p_sys->b_utf8)) + 1); if (buf == NULL) @@ -221,8 +221,8 @@ void E_(Close_ASX)( 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_prefix ) free( p_sys->psz_prefix ); - if( p_sys->psz_data ) free( p_sys->psz_data ); + free( p_sys->psz_prefix ); + free( p_sys->psz_data ); free( p_sys ); } diff --git a/modules/demux/playlist/b4s.c b/modules/demux/playlist/b4s.c index 0d0ce0e7cf..a4c21d0cba 100644 --- a/modules/demux/playlist/b4s.c +++ b/modules/demux/playlist/b4s.c @@ -72,7 +72,7 @@ void E_(Close_B4S)( 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_prefix ) free( p_sys->psz_prefix ); + free( p_sys->psz_prefix ); if( p_sys->p_xml_reader ) xml_ReaderDelete( p_sys->p_xml, p_sys->p_xml_reader ); if( p_sys->p_xml ) xml_Delete( p_sys->p_xml ); free( p_sys ); @@ -97,7 +97,7 @@ static int Demux( demux_t *p_demux ) if( !p_xml ) return -1; psz_elname = stream_ReadLine( p_demux->s ); - if( psz_elname ) free( psz_elname ); + free( psz_elname ); psz_elname = 0; p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s ); @@ -119,7 +119,7 @@ static int Demux( demux_t *p_demux ) { msg_Err( p_demux, "invalid root node %i, %s", xml_ReaderNodeType( p_xml_reader ), psz_elname ); - if( psz_elname ) free( psz_elname ); + free( psz_elname ); vlc_object_release( p_playlist ); return -1; } @@ -141,7 +141,7 @@ static int Demux( demux_t *p_demux ) strcmp( psz_elname, "playlist" ) ) { msg_Err( p_demux, "invalid child node %s", psz_elname ); - if( psz_elname ) free( psz_elname ); + free( psz_elname ); return -1; } free( psz_elname ); psz_elname = 0; @@ -183,7 +183,7 @@ static int Demux( demux_t *p_demux ) case XML_READER_STARTELEM: { // Read the element name - if( psz_elname ) free( psz_elname ); + free( psz_elname ); psz_elname = xml_ReaderName( p_xml_reader ); if( !psz_elname ) return -1; diff --git a/modules/demux/playlist/dvb.c b/modules/demux/playlist/dvb.c index 1b51dd088e..1dd1461d59 100644 --- a/modules/demux/playlist/dvb.c +++ b/modules/demux/playlist/dvb.c @@ -126,7 +126,7 @@ static int Demux( demux_t *p_demux ) input_ItemAddSubItem( p_current_input, p_input ); vlc_gc_decref( p_input ); while( i_options-- ) free( ppsz_options[i_options] ); - if( ppsz_options ) free( ppsz_options ); + free( ppsz_options ); free( psz_line ); } @@ -280,7 +280,7 @@ static int ParseLine( char *psz_line, char **ppsz_name, { /* This isn't a valid channels file, cleanup everything */ while( (*pi_options)-- ) free( (*pppsz_options)[*pi_options] ); - if( *pppsz_options ) free( *pppsz_options ); + free( *pppsz_options ); *pppsz_options = 0; *pi_options = 0; } diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c index 90f8adafcf..263f97d002 100644 --- a/modules/demux/playlist/m3u.c +++ b/modules/demux/playlist/m3u.c @@ -212,11 +212,11 @@ static int Demux( demux_t *p_demux ) { /* Cleanup state */ while( i_options-- ) free( (char*)ppsz_options[i_options] ); - if( ppsz_options ) free( ppsz_options ); + free( ppsz_options ); ppsz_options = NULL; i_options = 0; - if( psz_name ) free( psz_name ); + free( psz_name ); psz_name = NULL; - if ( psz_artist ) free( psz_artist ); + free( psz_artist ); psz_artist = NULL; i_parsed_duration = 0; i_duration = -1; diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c index acc5d9261e..11db8c4cbf 100644 --- a/modules/demux/playlist/podcast.c +++ b/modules/demux/playlist/podcast.c @@ -75,7 +75,7 @@ void E_(Close_podcast)( 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_prefix ) free( p_sys->psz_prefix ); + free( p_sys->psz_prefix ); if( p_sys->p_playlist ) vlc_object_release( p_sys->p_playlist ); if( p_sys->p_xml_reader ) xml_ReaderDelete( p_sys->p_xml, p_sys->p_xml_reader ); if( p_sys->p_xml ) xml_Delete( p_sys->p_xml ); @@ -134,7 +134,7 @@ static int Demux( demux_t *p_demux ) { msg_Err( p_demux, "invalid root node %i, %s", xml_ReaderNodeType( p_xml_reader ), psz_elname ); - if( psz_elname ) free( psz_elname ); + free( psz_elname ); return -1; } free( psz_elname ); psz_elname = NULL; @@ -153,7 +153,7 @@ static int Demux( demux_t *p_demux ) case XML_READER_STARTELEM: { // Read the element name - if( psz_elname ) free( psz_elname ); + free( psz_elname ); psz_elname = xml_ReaderName( p_xml_reader ); if( !psz_elname ) return -1; diff --git a/modules/demux/playlist/sgimb.c b/modules/demux/playlist/sgimb.c index 92e9ca946e..ba7a1cd0aa 100644 --- a/modules/demux/playlist/sgimb.c +++ b/modules/demux/playlist/sgimb.c @@ -183,20 +183,13 @@ void E_(Close_SGIMB)( 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_uri ) - free( p_sys->psz_uri ); - if( p_sys->psz_server ) - free( p_sys->psz_server ); - if( p_sys->psz_location ) - free( p_sys->psz_location ); - if( p_sys->psz_name ) - free( p_sys->psz_name ); - if( p_sys->psz_user ) - free( p_sys->psz_user ); - if( p_sys->psz_password ) - free( p_sys->psz_password ); - if( p_sys->psz_mcast_ip ) - free( p_sys->psz_mcast_ip ); + free( p_sys->psz_uri ); + free( p_sys->psz_server ); + free( p_sys->psz_location ); + free( p_sys->psz_name ); + free( p_sys->psz_user ); + free( p_sys->psz_password ); + free( p_sys->psz_mcast_ip ); free( p_demux->p_sys ); return; } @@ -325,7 +318,7 @@ static int Demux ( demux_t *p_demux ) while( ( psz_line = stream_ReadLine( p_demux->s ) ) ) { ParseLine( p_demux, psz_line ); - if( psz_line ) free( psz_line ); + free( psz_line ); } if( p_sys->psz_mcast_ip ) @@ -335,7 +328,7 @@ static int Demux ( demux_t *p_demux ) char *temp; asprintf( &temp, "udp://@" "%s:%i", p_sys->psz_mcast_ip, p_sys->i_mcast_port ); - if( p_sys->psz_uri ) free( p_sys->psz_uri ); + free( p_sys->psz_uri ); p_sys->psz_uri = strdup( temp ); free( temp ); } diff --git a/modules/demux/playlist/shoutcast.c b/modules/demux/playlist/shoutcast.c index 98ce107b99..00a3abf2ad 100644 --- a/modules/demux/playlist/shoutcast.c +++ b/modules/demux/playlist/shoutcast.c @@ -132,7 +132,7 @@ static int Demux( demux_t *p_demux ) { msg_Err( p_demux, "invalid root node %i, %s", xml_ReaderNodeType( p_xml_reader ), psz_eltname ); - if( psz_eltname ) free( psz_eltname ); + free( psz_eltname ); return -1; } diff --git a/modules/demux/ps.h b/modules/demux/ps.h index 651c7e0ec8..accca9e35f 100644 --- a/modules/demux/ps.h +++ b/modules/demux/ps.h @@ -497,11 +497,10 @@ static inline void ps_psm_destroy( ps_psm_t *p_psm ) { while( p_psm->i_es-- ) { - if( p_psm->es[p_psm->i_es]->i_descriptor ) - free( p_psm->es[p_psm->i_es]->p_descriptor ); + free( p_psm->es[p_psm->i_es]->p_descriptor ); free( p_psm->es[p_psm->i_es] ); } - if( p_psm->es ) free( p_psm->es ); + free( p_psm->es ); p_psm->es = 0; p_psm->i_es = 0; diff --git a/modules/demux/real.c b/modules/demux/real.c index 1e814ce157..8f38287305 100644 --- a/modules/demux/real.c +++ b/modules/demux/real.c @@ -216,10 +216,10 @@ static void Close( vlc_object_t *p_this ) free( tk ); } - if( p_sys->psz_title ) free( p_sys->psz_title ); - if( p_sys->psz_artist ) free( p_sys->psz_artist ); - if( p_sys->psz_copyright ) free( p_sys->psz_copyright ); - if( p_sys->psz_description ) free( p_sys->psz_description ); + free( p_sys->psz_title ); + free( p_sys->psz_artist ); + free( p_sys->psz_copyright ); + free( p_sys->psz_description ); if( p_sys->i_track > 0 ) free( p_sys->track ); free( p_sys ); diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c index cee5a82447..09b2eecf40 100644 --- a/modules/demux/subtitle.c +++ b/modules/demux/subtitle.c @@ -323,7 +323,7 @@ static int Open ( vlc_object_t *p_this ) s = NULL; } - if( s ) free( s ); + free( s ); /* It will nearly always work even for non seekable stream thanks the * caching system, and if it fails we lose just a few sub */ @@ -365,8 +365,7 @@ static int Open ( vlc_object_t *p_this ) sizeof(subtitle_t) * i_max ) ) ) { msg_Err( p_demux, "out of memory"); - if( p_sys->subtitle != NULL ) - free( p_sys->subtitle ); + free( p_sys->subtitle ); TextUnload( &p_sys->txt ); free( p_sys ); return VLC_ENOMEM; @@ -426,12 +425,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 dd3549e268..103972b18b 100644 --- a/modules/demux/ts.c +++ b/modules/demux/ts.c @@ -692,10 +692,7 @@ static int Open( vlc_object_t *p_this ) p_sys->buffer = malloc( p_sys->i_packet_size * p_sys->i_ts_read ); } } - if( val.psz_string ) - { - free( val.psz_string ); - } + free( val.psz_string ); /* We handle description of an extra PMT */ var_Create( p_demux, "ts-extra-pmt", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); @@ -773,10 +770,7 @@ static int Open( vlc_object_t *p_this ) } } } - if( val.psz_string ) - { - free( val.psz_string ); - } + free( val.psz_string ); var_Create( p_demux, "ts-csa-ck", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Get( p_demux, "ts-csa-ck", &val ); @@ -830,10 +824,7 @@ static int Open( vlc_object_t *p_this ) } } } - if( val.psz_string ) - { - free( val.psz_string ); - } + free( val.psz_string ); var_Create( p_demux, "ts-silent", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Get( p_demux, "ts-silent", &val ); @@ -1494,7 +1485,7 @@ static void PIDClean( es_out_t *out, ts_pid_t *pid ) dvbpsi_DetachPMT( pid->psi->prg[i]->handle ); free( pid->psi->prg[i] ); } - if( pid->psi->prg ) free( pid->psi->prg ); + free( pid->psi->prg ); free( pid->psi ); } else @@ -2835,10 +2826,8 @@ static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit ) strcat( psz_extra, psz_itm ); strcat( psz_extra, ")" ); } - if( psz_dsc ) - free( psz_dsc ); - if( psz_itm ) - free( psz_itm ); + free( psz_dsc ); + free( psz_itm ); } } } @@ -2856,10 +2845,8 @@ static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit ) if( p_evt->i_running_status == 0x04 && i_start > 0 ) vlc_epg_SetCurrent( p_epg, i_start ); - if( psz_name ) - free( psz_name ); - if( psz_text ) - free( psz_text ); + free( psz_name ); + free( psz_text ); free( psz_extra ); } @@ -3878,7 +3865,7 @@ static void PATCallBack( demux_t *p_demux, dvbpsi_pat_t *p_pat ) TAB_REMOVE( p_sys->i_pmt, p_sys->pmt, pmt_rm[i] ); } - if( pmt_rm ) free( pmt_rm ); + free( pmt_rm ); } /* now create programs */ diff --git a/modules/demux/vobsub.c b/modules/demux/vobsub.c index b6d88c593d..b285c81d78 100644 --- a/modules/demux/vobsub.c +++ b/modules/demux/vobsub.c @@ -211,10 +211,9 @@ static void Close( vlc_object_t *p_this ) /* Clean all subs from all tracks */ for( i = 0; i < p_sys->i_tracks; i++ ) - { - if( p_sys->track[i].p_subtitles ) free( p_sys->track[i].p_subtitles ); - } - if( p_sys->track ) free( p_sys->track ); + free( p_sys->track[i].p_subtitles ); + + free( p_sys->track ); if( p_sys->p_vobsub_stream ) stream_Delete( p_sys->p_vobsub_stream ); @@ -435,7 +434,7 @@ static int TextLoad( text_t *txt, stream_t *s ) if( txt->i_line_count <= 0 ) { - if( txt->line ) free( txt->line ); + free( txt->line ); return VLC_EGENERIC; } @@ -446,10 +445,9 @@ static void TextUnload( text_t *txt ) int i; for( i = 0; i < txt->i_line_count; i++ ) - { - if( txt->line[i] ) free( txt->line[i] ); - } - if( txt->line ) free( txt->line ); + free( txt->line[i] ); + + free( txt->line ); txt->i_line = 0; txt->i_line_count = 0; }