From dfc2996565842dbf644557debc80cb7cc8c2b4f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Duraffort?= Date: Wed, 12 Mar 2008 00:15:36 +0100 Subject: [PATCH] Remove useless test before freeing something. --- src/config/core.c | 2 +- src/input/es_out.c | 39 ++++++++++++------------------- src/input/input.c | 9 ++++--- src/input/stream.c | 6 ++--- src/input/var.c | 4 ++-- src/input/vlm.c | 17 ++++++-------- src/misc/image.c | 18 +++++++++----- src/misc/messages.c | 22 +++++++---------- src/misc/objects.c | 2 +- src/misc/stats.c | 2 +- src/misc/variables.c | 23 +++++++----------- src/playlist/services_discovery.c | 2 +- 12 files changed, 64 insertions(+), 82 deletions(-) diff --git a/src/config/core.c b/src/config/core.c index 0241713a88..3b8d91c33c 100644 --- a/src/config/core.c +++ b/src/config/core.c @@ -303,7 +303,7 @@ void __config_PutPsz( vlc_object_t *p_this, } /* free old string */ - if( oldval.psz_string ) free( oldval.psz_string ); + free( oldval.psz_string ); } /***************************************************************************** diff --git a/src/input/es_out.c b/src/input/es_out.c index c58d949393..768b66aebb 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -226,7 +226,7 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate ) msg_Dbg( p_input, "selected audio language[%d] %s", i, p_sys->ppsz_audio_language[i] ); } - if( val.psz_string ) free( val.psz_string ); + free( val.psz_string ); var_Get( p_input, "sub-language", &val ); p_sys->ppsz_sub_language = LanguageSplit(val.psz_string); @@ -236,7 +236,7 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate ) msg_Dbg( p_input, "selected subtitle language[%d] %s", i, p_sys->ppsz_sub_language[i] ); } - if( val.psz_string ) free( val.psz_string ); + free( val.psz_string ); } else { @@ -276,10 +276,8 @@ void input_EsOutDelete( es_out_t *out ) { input_DecoderDelete( p_sys->es[i]->p_dec ); } - if( p_sys->es[i]->psz_language ) - free( p_sys->es[i]->psz_language ); - if( p_sys->es[i]->psz_language_code ) - free( p_sys->es[i]->psz_language_code ); + free( p_sys->es[i]->psz_language ); + free( p_sys->es[i]->psz_language_code ); es_format_Clean( &p_sys->es[i]->fmt ); free( p_sys->es[i] ); @@ -297,19 +295,15 @@ void input_EsOutDelete( es_out_t *out ) free( p_sys->ppsz_sub_language ); } - if( p_sys->es ) - free( p_sys->es ); + free( p_sys->es ); /* FIXME duplicate work EsOutProgramDel (but we cannot use it) add a EsOutProgramClean ? */ for( i = 0; i < p_sys->i_pgrm; i++ ) { es_out_pgrm_t *p_pgrm = p_sys->pgrm[i]; - if( p_pgrm->psz_now_playing ) - free( p_pgrm->psz_now_playing ); - if( p_pgrm->psz_publisher ) - free( p_pgrm->psz_publisher ); - if( p_pgrm->psz_name ) - free( p_pgrm->psz_name ); + free( p_pgrm->psz_now_playing ); + free( p_pgrm->psz_publisher ); + free( p_pgrm->psz_name ); if( p_pgrm->p_epg ) vlc_epg_Delete( p_pgrm->p_epg ); @@ -640,9 +634,9 @@ static int EsOutProgramDel( es_out_t *out, int i_group ) /* If program is selected we need to unselect it */ if( p_sys->p_pgrm == p_pgrm ) p_sys->p_pgrm = NULL; - if( p_pgrm->psz_name ) free( p_pgrm->psz_name ); - if( p_pgrm->psz_now_playing ) free( p_pgrm->psz_now_playing ); - if( p_pgrm->psz_publisher ) free( p_pgrm->psz_publisher ); + free( p_pgrm->psz_name ); + free( p_pgrm->psz_now_playing ); + free( p_pgrm->psz_publisher ); if( p_pgrm->p_epg ) vlc_epg_Delete( p_pgrm->p_epg ); free( p_pgrm ); @@ -719,7 +713,7 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta ) /* TODO update epg name */ free( psz_cat ); } - if( p_pgrm->psz_name ) free( p_pgrm->psz_name ); + free( p_pgrm->psz_name ); p_pgrm->psz_name = strdup( psz_title ); /* ugly but it works */ @@ -860,8 +854,7 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg ) free( psz_epg ); #endif /* Update now playing */ - if( p_pgrm->psz_now_playing ) - free( p_pgrm->psz_now_playing ); + free( p_pgrm->psz_now_playing ); p_pgrm->psz_now_playing = NULL; if( p_epg->p_current && p_epg->p_current->psz_name && *p_epg->p_current->psz_name ) p_pgrm->psz_now_playing = strdup( p_epg->p_current->psz_name ); @@ -1541,10 +1534,8 @@ static void EsOutDel( es_out_t *out, es_out_id_t *es ) EsOutSelect( out, p_sys->es[i], VLC_FALSE ); } - if( es->psz_language ) - free( es->psz_language ); - if( es->psz_language_code ) - free( es->psz_language_code ); + free( es->psz_language ); + free( es->psz_language_code ); es_format_Clean( &es->fmt ); diff --git a/src/input/input.c b/src/input/input.c index 9725ed8dbb..4edba5df77 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -1053,8 +1053,8 @@ static int Init( input_thread_t * p_input ) } free( subs[i] ); } - if( subs ) free( subs ); - if( psz_autopath ) free( psz_autopath ); + free( subs ); + free( psz_autopath ); } free( psz_subtitle ); @@ -1292,7 +1292,7 @@ static void End( input_thread_t * p_input ) InputSourceClean( p_input->p->slave[i] ); free( p_input->p->slave[i] ); } - if( p_input->p->slave ) free( p_input->p->slave ); + free( p_input->p->slave ); /* Unload all modules */ if( p_input->p->p_es_out ) @@ -2698,8 +2698,7 @@ static void AppendAttachment( int *pi_attachment, input_attachment_t ***ppp_atta sizeof(input_attachment_t**) * ( i_attachment + i_new ) ); for( i = 0; i < i_new; i++ ) attachment[i_attachment++] = pp_new[i]; - if( pp_new ) - free( pp_new ); + free( pp_new ); /* */ *pi_attachment = i_attachment; diff --git a/src/input/stream.c b/src/input/stream.c index de02047197..16ec887718 100644 --- a/src/input/stream.c +++ b/src/input/stream.c @@ -439,7 +439,7 @@ static void AStreamDestroy( stream_t *s ) if( p_sys->b_block ) block_ChainRelease( p_sys->block.p_first ); else free( p_sys->stream.p_buffer ); - if( p_sys->p_peek ) free( p_sys->p_peek ); + free( p_sys->p_peek ); if( p_sys->p_list_access && p_sys->p_list_access != p_sys->p_access ) access2_Delete( p_sys->p_list_access ); @@ -448,7 +448,7 @@ static void AStreamDestroy( stream_t *s ) { free( p_sys->list[p_sys->i_list]->psz_path ); free( p_sys->list[p_sys->i_list] ); - if( !p_sys->i_list ) free( p_sys->list ); + free( p_sys->list ); } free( s->p_sys ); @@ -1644,7 +1644,7 @@ char * stream_ReadLine( stream_t *s ) msg_Err( s, "iconv failed" ); msg_Dbg( s, "original: %d, in %d, out %d", i_line, (int)i_in, (int)i_out ); } - if( p_line ) free( p_line ); + free( p_line ); p_line = psz_new_line; i_line = (size_t)i_line - i_out; /* does not include \0 */ } diff --git a/src/input/var.c b/src/input/var.c index d807b26bf9..05ec7cc6f6 100644 --- a/src/input/var.c +++ b/src/input/var.c @@ -328,7 +328,7 @@ void input_ControlVarNavigation( input_thread_t *p_input ) var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE, &val2, &text2 ); - if( text2.psz_string ) free( text2.psz_string ); + free( text2.psz_string ); } } @@ -386,7 +386,7 @@ void input_ControlVarTitle( input_thread_t *p_input, int i_title ) } var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, &text ); - if( text.psz_string ) free( text.psz_string ); + free( text.psz_string ); } } diff --git a/src/input/vlm.c b/src/input/vlm.c index 6a3caffded..7f08bc23fc 100644 --- a/src/input/vlm.c +++ b/src/input/vlm.c @@ -862,8 +862,7 @@ static int ExecuteMediaProperty( vlm_t *p_vlm, int64_t id, vlc_bool_t b_new, { MISSING( "output" ); - if( p_cfg->psz_output != NULL ) - free( p_cfg->psz_output ); + free( p_cfg->psz_output ); p_cfg->psz_output = *psz_value ? strdup( psz_value ) : NULL; i++; } @@ -892,8 +891,7 @@ static int ExecuteMediaProperty( vlm_t *p_vlm, int64_t id, vlc_bool_t b_new, if( !p_cfg->b_vod ) ERROR( "invalid mux option for broadcast" ); - if( p_cfg->vod.psz_mux ) - free( p_cfg->vod.psz_mux ); + free( p_cfg->vod.psz_mux ); p_cfg->vod.psz_mux = *psz_value ? strdup( psz_value ) : NULL; i++; } @@ -1147,7 +1145,7 @@ static void vlm_ScheduleDelete( vlm_t *vlm, vlm_schedule_sys_t *sched ) TAB_REMOVE( vlm->i_schedule, vlm->schedule, sched ); - if( vlm->i_schedule == 0 && vlm->schedule ) free( vlm->schedule ); + if( vlm->i_schedule == 0 ) free( vlm->schedule ); free( sched->psz_name ); while( sched->i_command ) { @@ -1401,11 +1399,11 @@ vlm_message_t *vlm_MessageNew( const char *psz_name, void vlm_MessageDelete( vlm_message_t *p_message ) { - if( p_message->psz_name ) free( p_message->psz_name ); - if( p_message->psz_value ) free( p_message->psz_value ); + free( p_message->psz_name ); + free( p_message->psz_value ); while( p_message->i_child-- ) vlm_MessageDelete( p_message->child[p_message->i_child] ); - if( p_message->child ) free( p_message->child ); + free( p_message->child ); free( p_message ); } @@ -2530,8 +2528,7 @@ static void vlm_MediaInstanceDelete( vlm_media_instance_sys_t *p_instance ) sout_DeleteInstance( p_instance->p_sout ); input_ItemClean( &p_instance->item ); - if( p_instance->psz_name ) - free( p_instance->psz_name ); + free( p_instance->psz_name ); free( p_instance ); } diff --git a/src/misc/image.c b/src/misc/image.c index 8670dd12b3..3ea118a698 100644 --- a/src/misc/image.c +++ b/src/misc/image.c @@ -577,9 +577,12 @@ static const char *Fourcc2Ext( vlc_fourcc_t i_codec ) static void video_release_buffer( picture_t *p_pic ) { - if( p_pic && p_pic->p_data_orig ) free( p_pic->p_data_orig ); - if( p_pic && p_pic->p_sys ) free( p_pic->p_sys ); - if( p_pic ) free( p_pic ); + if( p_pic ) + { + free( p_pic->p_data_orig ); + free( p_pic->p_sys ); + free( p_pic ); + } } static picture_t *video_new_buffer( decoder_t *p_dec ) @@ -609,9 +612,12 @@ static picture_t *video_new_buffer( decoder_t *p_dec ) static void video_del_buffer( decoder_t *p_dec, picture_t *p_pic ) { (void)p_dec; - if( p_pic && p_pic->p_data_orig ) free( p_pic->p_data_orig ); - if( p_pic && p_pic->p_sys ) free( p_pic->p_sys ); - if( p_pic ) free( p_pic ); + if( p_pic ) + { + free( p_pic->p_data_orig ); + free( p_pic->p_sys ); + free( p_pic ); + } } static void video_link_picture( decoder_t *p_dec, picture_t *p_pic ) diff --git a/src/misc/messages.c b/src/misc/messages.c index 30a2b03ef1..3fc0f03c3d 100644 --- a/src/misc/messages.c +++ b/src/misc/messages.c @@ -189,7 +189,7 @@ void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub ) if( QUEUE(i).pp_sub[j] == p_sub ) { REMOVE_ELEM( QUEUE(i).pp_sub, QUEUE(i).i_sub, j ); - if( p_sub ) free( p_sub ); + free( p_sub ); } } vlc_mutex_unlock( & QUEUE(i).lock ); @@ -431,7 +431,7 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type, p_obj->psz_header ); } } - if( psz_old ) free( psz_old ); + free( psz_old ); p_obj = p_obj->p_parent; } @@ -511,12 +511,9 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type, if( p_queue->b_overflow ) { - if( p_item->psz_module ) - free( p_item->psz_module ); - if( p_item->psz_msg ) - free( p_item->psz_msg ); - if( p_item->psz_header ) - free( p_item->psz_header ); + free( p_item->psz_module ); + free( p_item->psz_msg ); + free( p_item->psz_header ); } vlc_mutex_unlock ( &p_queue->lock ); @@ -559,12 +556,9 @@ static void FlushMsg ( msg_queue_t *p_queue ) i_index != i_stop; i_index = (i_index+1) % VLC_MSG_QSIZE ) { - if( p_queue->msg[i_index].psz_msg ) - free( p_queue->msg[i_index].psz_msg ); - if( p_queue->msg[i_index].psz_module ) - free( p_queue->msg[i_index].psz_module ); - if( p_queue->msg[i_index].psz_header ) - free( p_queue->msg[i_index].psz_header ); + free( p_queue->msg[i_index].psz_msg ); + free( p_queue->msg[i_index].psz_module ); + free( p_queue->msg[i_index].psz_header ); } /* Update the new start value */ diff --git a/src/misc/objects.c b/src/misc/objects.c index e48bd2caf5..3c15a33d30 100644 --- a/src/misc/objects.c +++ b/src/misc/objects.c @@ -406,7 +406,7 @@ static void vlc_object_destroy( vlc_object_t *p_this ) free( p_priv->p_vars ); vlc_mutex_destroy( &p_priv->var_lock ); - if( p_this->psz_header ) free( p_this->psz_header ); + free( p_this->psz_header ); if( p_this->i_object_type == VLC_OBJECT_GLOBAL ) { diff --git a/src/misc/stats.c b/src/misc/stats.c index 42e9a9adff..a922fe893c 100644 --- a/src/misc/stats.c +++ b/src/misc/stats.c @@ -409,7 +409,7 @@ void stats_CounterClean( counter_t *p_c ) free( p_s ); i--; } - if( p_c->psz_name ) free( p_c->psz_name ); + free( p_c->psz_name ); free( p_c ); } } diff --git a/src/misc/variables.c b/src/misc/variables.c index 15d29c186c..a9bbd1f12c 100644 --- a/src/misc/variables.c +++ b/src/misc/variables.c @@ -352,8 +352,7 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name ) for( i = 0 ; i < p_var->choices.i_count ; i++ ) { p_var->pf_free( &p_var->choices.p_values[i] ); - if( p_var->choices_text.p_values[i].psz_string ) - free( p_var->choices_text.p_values[i].psz_string ); + free( p_var->choices_text.p_values[i].psz_string ); } free( p_var->choices.p_values ); free( p_var->choices_text.p_values ); @@ -366,7 +365,7 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name ) } free( p_var->psz_name ); - if( p_var->psz_text ) free( p_var->psz_text ); + free( p_var->psz_text ); memmove( p_priv->p_vars + i_var, p_priv->p_vars + i_var + 1, @@ -520,8 +519,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, } p_var->pf_free( &p_var->choices.p_values[i] ); - if( p_var->choices_text.p_values[i].psz_string ) - free( p_var->choices_text.p_values[i].psz_string ); + free( p_var->choices_text.p_values[i].psz_string ); REMOVE_ELEM( p_var->choices.p_values, p_var->choices.i_count, i ); REMOVE_ELEM( p_var->choices_text.p_values, p_var->choices_text.i_count, i ); @@ -537,10 +535,8 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, p_var->pf_free( &p_var->choices.p_values[i] ); } for( i = 0 ; i < p_var->choices_text.i_count ; i++ ) - { - if( p_var->choices_text.p_values[i].psz_string ) - free( p_var->choices_text.p_values[i].psz_string ); - } + free( p_var->choices_text.p_values[i].psz_string ); + if( p_var->choices.i_count ) free( p_var->choices.p_values ); if( p_var->choices_text.i_count ) free( p_var->choices_text.p_values ); @@ -620,8 +616,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, if( p_val2 && p_val2->p_list ) { for( i = 0; i < p_val2->p_list->i_count; i++ ) - if( p_val2->p_list->p_values[i].psz_string ) - free( p_val2->p_list->p_values[i].psz_string ); + free( p_val2->p_list->p_values[i].psz_string ); if( p_val2->p_list->i_count ) { free( p_val2->p_list->p_values ); @@ -631,7 +626,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, } break; case VLC_VAR_SETTEXT: - if( p_var->psz_text ) free( p_var->psz_text ); + free( p_var->psz_text ); if( p_val && p_val->psz_string ) p_var->psz_text = strdup( p_val->psz_string ); break; @@ -1176,7 +1171,7 @@ void var_OptionParse( vlc_object_t *p_obj, const char *psz_option ) INSERT_ELEM( p_list->pi_types, p_list->i_count, p_list->i_count, VLC_VAR_INTEGER ); } - if( psz_orig ) free( psz_orig ); + free( psz_orig ); break; } @@ -1532,7 +1527,7 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name, INSERT_ELEM( p_list->pi_types, p_list->i_count, p_list->i_count, VLC_VAR_INTEGER ); } - if( psz_orig ) free( psz_orig ); + free( psz_orig ); break; } default: diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c index cf6777fb6f..c7bc7eb06e 100644 --- a/src/playlist/services_discovery.c +++ b/src/playlist/services_discovery.c @@ -143,7 +143,7 @@ services_discovery_GetLocalizedName ( services_discovery_t * p_sd ) void services_discovery_SetLocalizedName ( services_discovery_t * p_sd, const char *psz ) { - if(p_sd->psz_localized_name) free( p_sd->psz_localized_name ); + free( p_sd->psz_localized_name ); p_sd->psz_localized_name = strdup(psz); } -- 2.39.2