[vlc-devel] commit: Useless test before a free() ( Rémi Duraffort )

git version control git at videolan.org
Fri Mar 14 00:28:19 CET 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Mar 14 00:21:34 2008 +0100| [5cb4066e102b6c6e89ab890439c5bf9c74703262]

Useless test before a free()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5cb4066e102b6c6e89ab890439c5bf9c74703262
---

 modules/access/mms/buffer.c      |   10 ++--------
 modules/access/mms/mmsh.c        |    6 ++----
 modules/access/mms/mmstu.c       |    5 +----
 modules/access/pvr.c             |    9 +++------
 modules/access/rtsp/real_asmrp.c |    4 ++--
 modules/audio_output/jack.c      |   15 +++------------
 modules/codec/cc.c               |    6 ++----
 modules/codec/cmml/xtag.c        |   10 +++++-----
 modules/codec/faad.c             |    2 +-
 modules/codec/fake.c             |    4 ++--
 10 files changed, 23 insertions(+), 48 deletions(-)

diff --git a/modules/access/mms/buffer.c b/modules/access/mms/buffer.c
index 726ba54..5cc2c50 100644
--- a/modules/access/mms/buffer.c
+++ b/modules/access/mms/buffer.c
@@ -54,10 +54,7 @@ int var_buffer_reinitwrite( var_buffer_t *p_buf, int i_default_size )
     if( p_buf->i_size < i_default_size )
     {
         p_buf->i_size = i_default_size;
-        if( p_buf->p_data )
-        {
-            free( p_buf->p_data );
-        }
+        free( p_buf->p_data );
         p_buf->p_data = malloc( p_buf->i_size );
     }
     if( !p_buf->p_data )
@@ -151,10 +148,7 @@ void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str )
 
 void var_buffer_free( var_buffer_t *p_buf )
 {
-    if( p_buf->p_data )
-    {
-        free( p_buf->p_data );
-    }
+    free( p_buf->p_data );
     p_buf->i_data = 0;
     p_buf->i_size = 0;
 }
diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c
index c2a2c24..cc22555 100644
--- a/modules/access/mms/mmsh.c
+++ b/modules/access/mms/mmsh.c
@@ -226,8 +226,7 @@ void E_( MMSHClose )( access_t *p_access )
 
     Stop( p_access );
 
-    if( p_sys->p_header )
-        free( p_sys->p_header  );
+    free( p_sys->p_header  );
 
     vlc_UrlClean( &p_sys->proxy );
     vlc_UrlClean( &p_sys->url );
@@ -732,8 +731,7 @@ static void GetHeader( access_t *p_access )
 
     /* Read the asf header */
     p_sys->i_header = 0;
-    if( p_sys->p_header )
-        free( p_sys->p_header  );
+    free( p_sys->p_header  );
     p_sys->p_header = NULL;
     for( ;; )
     {
diff --git a/modules/access/mms/mmstu.c b/modules/access/mms/mmstu.c
index 5f5534e..3779a06 100644
--- a/modules/access/mms/mmstu.c
+++ b/modules/access/mms/mmstu.c
@@ -1099,10 +1099,7 @@ static int  mms_ParseCommand( access_t *p_access,
     int         i_length;
     uint32_t    i_id;
 
-    if( p_sys->p_cmd )
-    {
-        free( p_sys->p_cmd );
-    }
+    free( p_sys->p_cmd );
     p_sys->i_cmd = i_data;
     p_sys->p_cmd = malloc( i_data );
     memcpy( p_sys->p_cmd, p_data, i_data );
diff --git a/modules/access/pvr.c b/modules/access/pvr.c
index 94f4fcb..848276b 100644
--- a/modules/access/pvr.c
+++ b/modules/access/pvr.c
@@ -826,8 +826,7 @@ static int Open( vlc_object_t * p_this )
 
     if( psz_device )
     {
-        if( p_sys->psz_videodev )
-            free( p_sys->psz_videodev );
+        free( p_sys->psz_videodev );
         p_sys->psz_videodev = psz_device;
     }
 
@@ -1061,10 +1060,8 @@ static void Close( vlc_object_t * p_this )
         close( p_sys->i_fd );
     if ( p_sys->i_radio_fd != -1 )
         close( p_sys->i_radio_fd );
-    if ( p_sys->psz_videodev )
-        free( p_sys->psz_videodev );
-    if ( p_sys->psz_radiodev )
-        free( p_sys->psz_radiodev );
+    free( p_sys->psz_videodev );
+    free( p_sys->psz_radiodev );
     free( p_sys );
 }
 
diff --git a/modules/access/rtsp/real_asmrp.c b/modules/access/rtsp/real_asmrp.c
index c909310..c37363f 100644
--- a/modules/access/rtsp/real_asmrp.c
+++ b/modules/access/rtsp/real_asmrp.c
@@ -106,8 +106,8 @@ static void asmrp_dispose (asmrp_t *p) {
   for (i=0; i<p->sym_tab_num; i++)
     free (p->sym_tab[i].id);
 
-  if (p->buf) free (p->buf);
-  free (p);
+  free( p->buf );
+  free( p );
 }
 
 static void asmrp_getch (asmrp_t *p) {
diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c
index 681338d..696aa9a 100644
--- a/modules/audio_output/jack.c
+++ b/modules/audio_output/jack.c
@@ -214,10 +214,7 @@ static int Open( vlc_object_t *p_this )
                          psz_out, psz_in );
             }
         }
-        if( pp_in_ports )
-        {
-            free( pp_in_ports );
-        }
+        free( pp_in_ports );
     }
 
     msg_Dbg( p_aout, "JACK audio output initialized (%d channels, buffer "
@@ -233,14 +230,8 @@ error_out:
             jack_deactivate( p_sys->p_jack_client );
             jack_client_close( p_sys->p_jack_client );
         }
-        if( p_sys->p_jack_ports )
-        {
-            free( p_sys->p_jack_ports );
-        }
-        if( p_sys->p_jack_buffers )
-        {
-            free( p_sys->p_jack_buffers );
-        }
+        free( p_sys->p_jack_ports );
+        free( p_sys->p_jack_buffers );
         free( p_sys );
     }
     return status;
diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 0e62866..aca7a30 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -334,8 +334,7 @@ static subpicture_t *Subtitle( decoder_t *p_dec, char *psz_subtitle, char *psz_h
     {
         msg_Warn( p_dec, "can't get spu buffer" );
         free( psz_subtitle );
-        if( psz_html )
-            free( psz_html );
+        free( psz_html );
         return NULL;
     }
 
@@ -352,8 +351,7 @@ static subpicture_t *Subtitle( decoder_t *p_dec, char *psz_subtitle, char *psz_h
     {
         msg_Err( p_dec, "cannot allocate SPU region" );
         free( psz_subtitle );
-        if( psz_html )
-            free( psz_html );
+        free( psz_html );
         p_dec->pf_spu_buffer_del( p_dec, p_spu );
         return NULL;
     }
diff --git a/modules/codec/cmml/xtag.c b/modules/codec/cmml/xtag.c
index 024e1e9..812e280 100644
--- a/modules/codec/cmml/xtag.c
+++ b/modules/codec/cmml/xtag.c
@@ -421,14 +421,14 @@ xtag_free (XTag * xtag)
 
   if (xtag == NULL) return NULL;
 
-  if (xtag->name) free (xtag->name);
-  if (xtag->pcdata) free (xtag->pcdata);
+  free( xtag->name );
+  free( xtag->pcdata );
 
   for (l = xtag->attributes; l; l = l->next) {
     if ((attr = (XAttribute *)l->data) != NULL) {
-      if (attr->name) free (attr->name);
-      if (attr->value) free (attr->value);
-      free (attr);
+      free( attr->name );
+      free( attr->value );
+      free( attr );
     }
   }
   xlist_free (xtag->attributes);
diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 054e1df..69100cc 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -434,7 +434,7 @@ static void Close( vlc_object_t *p_this )
     decoder_sys_t *p_sys = p_dec->p_sys;
 
     faacDecClose( p_sys->hfaad );
-    if( p_sys->p_buffer ) free( p_sys->p_buffer );
+    free( p_sys->p_buffer );
     free( p_sys );
 }
 
diff --git a/modules/codec/fake.c b/modules/codec/fake.c
index 3aa7a62..3861c51 100644
--- a/modules/codec/fake.c
+++ b/modules/codec/fake.c
@@ -225,7 +225,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     }
     msg_Dbg( p_dec, "file %s loaded successfully", psz_file );
 
-    if ( psz_file ) free( psz_file );
+    free( psz_file );
 
     if ( b_keep_ar )
     {
@@ -304,7 +304,7 @@ static int OpenDecoder( vlc_object_t *p_this )
         p_handler = image_HandlerCreate( p_dec );
         p_image = image_Filter( p_handler, p_old, &fmt_out, val.psz_string );
         image_HandlerDelete( p_handler );
-        if ( val.psz_string != NULL ) free( val.psz_string );
+        free( val.psz_string );
 
         if ( p_image == NULL )
         {




More information about the vlc-devel mailing list