]> git.sesse.net Git - vlc/commitdiff
Remove useless test before freeing something.
authorRémi Duraffort <ivoire@videolan.org>
Tue, 11 Mar 2008 23:15:36 +0000 (00:15 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Wed, 12 Mar 2008 11:07:41 +0000 (12:07 +0100)
12 files changed:
src/config/core.c
src/input/es_out.c
src/input/input.c
src/input/stream.c
src/input/var.c
src/input/vlm.c
src/misc/image.c
src/misc/messages.c
src/misc/objects.c
src/misc/stats.c
src/misc/variables.c
src/playlist/services_discovery.c

index 0241713a881251449da6aaa02d1a864b83fb067c..3b8d91c33c4a7cf21444a14b1c9e5080216d7bda 100644 (file)
@@ -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 );
 }
 
 /*****************************************************************************
index c58d949393a1821e8f66a6db044ad61ed7246a13..768b66aebb5ff8a4e09108392bf1821e2ef3fca2 100644 (file)
@@ -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 );
 
index 9725ed8dbbf151863ba3767a3f96e24ef0e9c242..4edba5df776476ec3b57886ff60a533c7511e184 100644 (file)
@@ -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;
index de02047197bc3911e7c4ba03a9395262746b1cd1..16ec8877185a094ddc5dfe8514f572deba177747 100644 (file)
@@ -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 */
         }
index d807b26bf9d2f87515e63dc626f9e655e5aa6d39..05ec7cc6f66e4b4aec1d8e8cc9b05f4eb9500ee0 100644 (file)
@@ -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 );
     }
 }
 
index 6a3caffdedff7375ce7684dcdf61d2e39005d668..7f08bc23fc7e35cc1d58e440fa10ea11d6776a11 100644 (file)
@@ -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 );
 }
 
index 8670dd12b382ffc646631b9b5cb337cc2570b7e4..3ea118a6982ec961622171a44634e3e77498ed9c 100644 (file)
@@ -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 )
index 30a2b03ef11cec5a6f7bb39f28d6c51d7fd7e621..3fc0f03c3d0aa43821629c2a47fa9e4fb4034c51 100644 (file)
@@ -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 */
index e48bd2caf5775bb491b7165e7ee7a8fb1d9281e1..3c15a33d30b8daddd389814ae5d3bbcf0f83e762 100644 (file)
@@ -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 )
     {
index 42e9a9adff1f3eeeba79acc19efff8649391a137..a922fe893c397dfbad2397a829e9b534485d5161 100644 (file)
@@ -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 );
     }
 }
index 15d29c186cc3381b9f245537df38e376b92ee62d..a9bbd1f12c7026bfff94007a626d770868600f28 100644 (file)
@@ -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:
index cf6777fb6f07b5d4787f9d1cc3102196774a9142..c7bc7eb06e0a495d06753b7b79e3d4665358d256 100644 (file)
@@ -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);
 }