Commit dfc29965 authored by Rémi Duraffort's avatar Rémi Duraffort

Remove useless test before freeing something.

parent 0c55d564
......@@ -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 );
}
/*****************************************************************************
......
......@@ -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,9 +276,7 @@ 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 );
es_format_Clean( &p_sys->es[i]->fmt );
......@@ -297,18 +295,14 @@ void input_EsOutDelete( es_out_t *out )
free( p_sys->ppsz_sub_language );
}
if( 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 );
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,7 +854,6 @@ 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 );
p_pgrm->psz_now_playing = NULL;
if( p_epg->p_current && p_epg->p_current->psz_name && *p_epg->p_current->psz_name )
......@@ -1541,9 +1534,7 @@ 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 );
es_format_Clean( &es->fmt );
......
......@@ -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,7 +2698,6 @@ 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 );
/* */
......
......@@ -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 */
}
......
......@@ -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 );
}
}
......
......@@ -862,7 +862,6 @@ 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 );
p_cfg->psz_output = *psz_value ? strdup( psz_value ) : NULL;
i++;
......@@ -892,7 +891,6 @@ 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 );
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,7 +2528,6 @@ 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 );
}
......
......@@ -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 )
......
......@@ -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,11 +511,8 @@ 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 );
}
......@@ -559,11 +556,8 @@ 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 );
}
......
......@@ -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 )
{
......
......@@ -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 );
}
}
......
......@@ -352,7 +352,6 @@ 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.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,7 +519,6 @@ 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 );
REMOVE_ELEM( p_var->choices.p_values, p_var->choices.i_count, i );
REMOVE_ELEM( p_var->choices_text.p_values,
......@@ -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 );
}
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,7 +616,6 @@ 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 );
if( p_val2->p_list->i_count )
{
......@@ -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:
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment