[PATCH] libmpcodecs/libmpdemux: Remove bunch of if NULL before free

Clément Bœsch ubitux at gmail.com
Thu Nov 4 22:52:20 CET 2010


---
 libmpcodecs/ad_mpc.c         |    3 +--
 libmpcodecs/ad_speex.c       |    3 +--
 libmpcodecs/dec_teletext.c   |    9 +++------
 libmpcodecs/vd_ffmpeg.c      |    3 +--
 libmpcodecs/vd_libmpeg2.c    |    2 +-
 libmpcodecs/vd_realvid.c     |    5 ++---
 libmpcodecs/vd_xanim.c       |    3 +--
 libmpcodecs/ve_nuv.c         |    9 +++------
 libmpcodecs/ve_xvid4.c       |   16 +++++-----------
 libmpcodecs/vf_ass.c         |    9 +++------
 libmpcodecs/vf_blackframe.c  |    2 +-
 libmpcodecs/vf_denoise3d.c   |    2 +-
 libmpcodecs/vf_eq.c          |    2 +-
 libmpcodecs/vf_fspp.c        |    4 ++--
 libmpcodecs/vf_hqdn3d.c      |    8 ++++----
 libmpcodecs/vf_hue.c         |    4 ++--
 libmpcodecs/vf_lavc.c        |    2 +-
 libmpcodecs/vf_mcdeint.c     |    4 ++--
 libmpcodecs/vf_perspective.c |    2 +-
 libmpcodecs/vf_pp7.c         |    2 +-
 libmpcodecs/vf_sab.c         |    4 ++--
 libmpcodecs/vf_scale.c       |    8 +++-----
 libmpcodecs/vf_screenshot.c  |    2 +-
 libmpcodecs/vf_spp.c         |    8 ++++----
 libmpcodecs/vf_uspp.c        |    4 ++--
 libmpdemux/asfheader.c       |    4 ++--
 libmpdemux/demux_aac.c       |    3 +--
 libmpdemux/demux_asf.c       |    8 ++------
 libmpdemux/demux_audio.c     |    2 --
 libmpdemux/demux_film.c      |    3 +--
 libmpdemux/demux_fli.c       |    7 ++-----
 libmpdemux/demux_mf.c        |    2 --
 libmpdemux/demux_mng.c       |    3 +--
 libmpdemux/demux_mpc.c       |    2 --
 libmpdemux/demux_mpg.c       |    2 +-
 libmpdemux/demux_nsv.c       |    2 --
 libmpdemux/demux_ogg.c       |   13 +++++--------
 libmpdemux/demux_pva.c       |    7 ++-----
 libmpdemux/demux_real.c      |   12 ++++--------
 libmpdemux/demux_realaud.c   |    5 ++---
 libmpdemux/demux_roq.c       |    2 --
 libmpdemux/demux_ts.c        |   12 ++++--------
 libmpdemux/demux_viv.c       |   21 +++++++--------------
 libmpdemux/muxer_mpeg.c      |    9 +++------
 44 files changed, 86 insertions(+), 153 deletions(-)

diff --git a/libmpcodecs/ad_mpc.c b/libmpcodecs/ad_mpc.c
index 31463ab..979dce6 100644
--- a/libmpcodecs/ad_mpc.c
+++ b/libmpcodecs/ad_mpc.c
@@ -121,8 +121,7 @@ static int preinit(sh_audio_t *sh) {
 }
 
 static void uninit(sh_audio_t *sh) {
-  if (sh->context)
-    free(sh->context);
+  free(sh->context);
   sh->context = NULL;
 }
 
diff --git a/libmpcodecs/ad_speex.c b/libmpcodecs/ad_speex.c
index a93a245..f80b4d6 100644
--- a/libmpcodecs/ad_speex.c
+++ b/libmpcodecs/ad_speex.c
@@ -126,8 +126,7 @@ static void uninit(sh_audio_t *sh) {
   if (ctx) {
     speex_bits_destroy(&ctx->bits);
     speex_decoder_destroy(ctx->dec_context);
-    if (ctx->hdr)
-      free(ctx->hdr);
+    free(ctx->hdr);
     free(ctx);
   }
   ctx = NULL;
diff --git a/libmpcodecs/dec_teletext.c b/libmpcodecs/dec_teletext.c
index 645c595..ee07ab8 100644
--- a/libmpcodecs/dec_teletext.c
+++ b/libmpcodecs/dec_teletext.c
@@ -1101,8 +1101,7 @@ static int decode_pkt0(priv_vbi_t* priv,unsigned char* data,int magAddr)
         if(d[i]&0x80){
             pll_add(priv,2,4);
 
-            if(priv->mag[magAddr].pt)
-                  free(priv->mag[magAddr].pt);
+            free(priv->mag[magAddr].pt);
             priv->mag[magAddr].pt=NULL;
             priv->mag[magAddr].order=0;
             return 0;
@@ -1754,10 +1753,8 @@ int teletext_control(void* p, int cmd, void *arg)
     }
     case TV_VBI_CONTROL_STOP:
     {
-        if(priv->mag)
-            free(priv->mag);
-        if(priv->ptsp)
-            free(priv->ptsp);
+        free(priv->mag);
+        free(priv->ptsp);
         destroy_cache(priv);
         priv->page_changed=1;
         pthread_mutex_destroy(&priv->buffer_mutex);
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 3e3dfb9..d3add17 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -480,8 +480,7 @@ static void uninit(sh_video_t *sh){
 
     av_freep(&avctx);
     av_freep(&ctx->pic);
-    if (ctx)
-        free(ctx);
+    free(ctx);
 }
 
 static void draw_slice(struct AVCodecContext *s,
diff --git a/libmpcodecs/vd_libmpeg2.c b/libmpcodecs/vd_libmpeg2.c
index 2968afa..a138882 100644
--- a/libmpcodecs/vd_libmpeg2.c
+++ b/libmpcodecs/vd_libmpeg2.c
@@ -125,7 +125,7 @@ static void uninit(sh_video_t *sh){
     int i;
     vd_libmpeg2_ctx_t *context = sh->context;
     mpeg2dec_t * mpeg2dec = context->mpeg2dec;
-    if (context->pending_buffer) free(context->pending_buffer);
+    free(context->pending_buffer);
     mpeg2dec->decoder.convert=NULL;
     mpeg2dec->decoder.convert_id=NULL;
     mpeg2_close (mpeg2dec);
diff --git a/libmpcodecs/vd_realvid.c b/libmpcodecs/vd_realvid.c
index eae526f..b7e166b 100644
--- a/libmpcodecs/vd_realvid.c
+++ b/libmpcodecs/vd_realvid.c
@@ -356,8 +356,7 @@ static void uninit(sh_video_t *sh){
 #endif
 	rv_handle=NULL;
 	initialized = 0;
-	if (buffer)
-	    free(buffer);
+	free(buffer);
 	buffer = NULL;
 	bufsz = 0;
 }
@@ -387,7 +386,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
 	if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop
 
 	if (bufsz < sh->disp_w*sh->disp_h*3/2) {
-	    if (buffer) free(buffer);
+	    free(buffer);
 	    bufsz = sh->disp_w*sh->disp_h*3/2;
 	    buffer=malloc(bufsz);
 	    if (!buffer) return 0;
diff --git a/libmpcodecs/vd_xanim.c b/libmpcodecs/vd_xanim.c
index d8a3a74..7341088 100644
--- a/libmpcodecs/vd_xanim.c
+++ b/libmpcodecs/vd_xanim.c
@@ -771,8 +771,7 @@ static void uninit(sh_video_t *sh)
 	    close_func();
 	}
     dlclose(priv->file_handler);
-    if (priv->decinfo != NULL)
-	free(priv->decinfo);
+    free(priv->decinfo);
     free(priv);
 }
 
diff --git a/libmpcodecs/ve_nuv.c b/libmpcodecs/ve_nuv.c
index bf9e694..4652a02 100644
--- a/libmpcodecs/ve_nuv.c
+++ b/libmpcodecs/ve_nuv.c
@@ -203,12 +203,9 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
 
 static void uninit(struct vf_instance *vf) {
 
-  if(vf->priv->buffer)
-    free(vf->priv->buffer);
-  if(vf->priv->zbuffer)
-    free(vf->priv->zbuffer);
-  if(vf->priv->zmem)
-    free(vf->priv->zmem);
+  free(vf->priv->buffer);
+  free(vf->priv->zbuffer);
+  free(vf->priv->zmem);
 
 }
 
diff --git a/libmpcodecs/ve_xvid4.c b/libmpcodecs/ve_xvid4.c
index 7608c6c..4fd180c 100644
--- a/libmpcodecs/ve_xvid4.c
+++ b/libmpcodecs/ve_xvid4.c
@@ -461,15 +461,9 @@ uninit(struct vf_instance *vf)
 	}
 
         /* Free allocated memory */
-	if(mod->frame.quant_intra_matrix)
-	    free(mod->frame.quant_intra_matrix);
-
-	if(mod->frame.quant_inter_matrix)
-	    free(mod->frame.quant_inter_matrix);
-
-	if(mod->mux->bih)
-	    free(mod->mux->bih);
-
+	free(mod->frame.quant_intra_matrix);
+	free(mod->frame.quant_inter_matrix);
+	free(mod->mux->bih);
 	free(vf->priv);
 	vf->priv=NULL;
 
@@ -822,7 +816,7 @@ static int dispatch_settings(xvid_mplayer_module_t *mod)
 		frame->quant_intra_matrix = (unsigned char*)read_matrix(xvidenc_intra_matrix_file);
 		if(frame->quant_intra_matrix != NULL) {
 			mp_msg(MSGT_MENCODER, MSGL_INFO, "xvid: Loaded Intra matrix (switching to mpeg quantization type)\n");
-			if(xvidenc_quant_method) free(xvidenc_quant_method);
+			free(xvidenc_quant_method);
 			xvidenc_quant_method = strdup("mpeg");
 		}
 	}
@@ -830,7 +824,7 @@ static int dispatch_settings(xvid_mplayer_module_t *mod)
 		frame->quant_inter_matrix = read_matrix(xvidenc_inter_matrix_file);
 		if(frame->quant_inter_matrix) {
 			mp_msg(MSGT_MENCODER, MSGL_INFO, "\nxvid: Loaded Inter matrix (switching to mpeg quantization type)\n");
-			if(xvidenc_quant_method) free(xvidenc_quant_method);
+			free(xvidenc_quant_method);
 			xvidenc_quant_method = strdup("mpeg");
 		}
 	}
diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c
index 8c3a954..f2e4885 100644
--- a/libmpcodecs/vf_ass.c
+++ b/libmpcodecs/vf_ass.c
@@ -383,12 +383,9 @@ static int control(vf_instance_t *vf, int request, void *data)
 
 static void uninit(struct vf_instance *vf)
 {
-    if (vf->priv->planes[1])
-        free(vf->priv->planes[1]);
-    if (vf->priv->planes[2])
-        free(vf->priv->planes[2]);
-    if (vf->priv->dirty_rows)
-        free(vf->priv->dirty_rows);
+    free(vf->priv->planes[1]);
+    free(vf->priv->planes[2]);
+    free(vf->priv->dirty_rows);
 }
 
 static const unsigned int fmt_list[] = {
diff --git a/libmpcodecs/vf_blackframe.c b/libmpcodecs/vf_blackframe.c
index 1b00e99..244da01 100644
--- a/libmpcodecs/vf_blackframe.c
+++ b/libmpcodecs/vf_blackframe.c
@@ -115,7 +115,7 @@ static int control(struct vf_instance *vf, int request, void* data){
 }
 
 static void uninit(struct vf_instance *vf) {
-    if (vf->priv) free(vf->priv);
+    free(vf->priv);
 }
 
 static int vf_open(vf_instance_t *vf, char *args){
diff --git a/libmpcodecs/vf_denoise3d.c b/libmpcodecs/vf_denoise3d.c
index d18b8cb..4d1f16c 100644
--- a/libmpcodecs/vf_denoise3d.c
+++ b/libmpcodecs/vf_denoise3d.c
@@ -49,7 +49,7 @@ static int config(struct vf_instance *vf,
         int width, int height, int d_width, int d_height,
 	unsigned int flags, unsigned int outfmt){
 
-	if(vf->priv->Line) free(vf->priv->Line);
+	free(vf->priv->Line);
         vf->priv->Line = malloc(width);
 	vf->priv->pmpi=NULL;
 //        vf->default_caps &= !VFCAP_ACCEPT_STRIDE;
diff --git a/libmpcodecs/vf_eq.c b/libmpcodecs/vf_eq.c
index 1cbffb2..5925c86 100644
--- a/libmpcodecs/vf_eq.c
+++ b/libmpcodecs/vf_eq.c
@@ -215,7 +215,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
 
 static void uninit(struct vf_instance *vf)
 {
-	if (vf->priv->buf) free(vf->priv->buf);
+	free(vf->priv->buf);
 	free(vf->priv);
 }
 
diff --git a/libmpcodecs/vf_fspp.c b/libmpcodecs/vf_fspp.c
index 1819ac6..e17be58 100644
--- a/libmpcodecs/vf_fspp.c
+++ b/libmpcodecs/vf_fspp.c
@@ -580,9 +580,9 @@ static void uninit(struct vf_instance *vf)
     vf->priv->temp= NULL;
     if(vf->priv->src)  av_free(vf->priv->src);
     vf->priv->src= NULL;
-    //if(vf->priv->avctx) free(vf->priv->avctx);
+    //free(vf->priv->avctx);
     //vf->priv->avctx= NULL;
-    if(vf->priv->non_b_qp) free(vf->priv->non_b_qp);
+    free(vf->priv->non_b_qp);
     vf->priv->non_b_qp= NULL;
 
     av_free(vf->priv);
diff --git a/libmpcodecs/vf_hqdn3d.c b/libmpcodecs/vf_hqdn3d.c
index 4e5e170..ea4d4cd 100644
--- a/libmpcodecs/vf_hqdn3d.c
+++ b/libmpcodecs/vf_hqdn3d.c
@@ -45,10 +45,10 @@ struct vf_priv_s {
 /***************************************************************************/
 
 static void uninit(struct vf_instance *vf){
-	if(vf->priv->Line){free(vf->priv->Line);vf->priv->Line=NULL;}
-	if(vf->priv->Frame[0]){free(vf->priv->Frame[0]);vf->priv->Frame[0]=NULL;}
-	if(vf->priv->Frame[1]){free(vf->priv->Frame[1]);vf->priv->Frame[1]=NULL;}
-	if(vf->priv->Frame[2]){free(vf->priv->Frame[2]);vf->priv->Frame[2]=NULL;}
+	free(vf->priv->Line);vf->priv->Line=NULL;
+	free(vf->priv->Frame[0]);vf->priv->Frame[0]=NULL;
+	free(vf->priv->Frame[1]);vf->priv->Frame[1]=NULL;
+	free(vf->priv->Frame[2]);vf->priv->Frame[2]=NULL;
 }
 
 static int config(struct vf_instance *vf,
diff --git a/libmpcodecs/vf_hue.c b/libmpcodecs/vf_hue.c
index 221bee8..47fe19a 100644
--- a/libmpcodecs/vf_hue.c
+++ b/libmpcodecs/vf_hue.c
@@ -158,8 +158,8 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
 
 static void uninit(struct vf_instance *vf)
 {
-	if (vf->priv->buf[0]) free(vf->priv->buf[0]);
-	if (vf->priv->buf[1]) free(vf->priv->buf[1]);
+	free(vf->priv->buf[0]);
+	free(vf->priv->buf[1]);
 	free(vf->priv);
 }
 
diff --git a/libmpcodecs/vf_lavc.c b/libmpcodecs/vf_lavc.c
index 6c9c74f..f400678 100644
--- a/libmpcodecs/vf_lavc.c
+++ b/libmpcodecs/vf_lavc.c
@@ -69,7 +69,7 @@ static int config(struct vf_instance *vf,
 	}
     }
 
-    if(vf->priv->outbuf) free(vf->priv->outbuf);
+    free(vf->priv->outbuf);
 
     vf->priv->outbuf_size=10000+width*height;  // must be enough!
     vf->priv->outbuf = malloc(vf->priv->outbuf_size);
diff --git a/libmpcodecs/vf_mcdeint.c b/libmpcodecs/vf_mcdeint.c
index 2373ae6..3e6745f 100644
--- a/libmpcodecs/vf_mcdeint.c
+++ b/libmpcodecs/vf_mcdeint.c
@@ -278,9 +278,9 @@ static void uninit(struct vf_instance *vf){
 
 #if 0
     for(i=0; i<3; i++){
-        if(vf->priv->temp[i]) free(vf->priv->temp[i]);
+        free(vf->priv->temp[i]);
         vf->priv->temp[i]= NULL;
-        if(vf->priv->src[i]) free(vf->priv->src[i]);
+        free(vf->priv->src[i]);
         vf->priv->src[i]= NULL;
     }
 #endif
diff --git a/libmpcodecs/vf_perspective.c b/libmpcodecs/vf_perspective.c
index 21689d1..8c6caca 100644
--- a/libmpcodecs/vf_perspective.c
+++ b/libmpcodecs/vf_perspective.c
@@ -132,7 +132,7 @@ static int config(struct vf_instance *vf,
 static void uninit(struct vf_instance *vf){
 	if(!vf->priv) return;
 
-	if(vf->priv->pv) free(vf->priv->pv);
+	free(vf->priv->pv);
 	vf->priv->pv= NULL;
 
 	free(vf->priv);
diff --git a/libmpcodecs/vf_pp7.c b/libmpcodecs/vf_pp7.c
index 932c3f5..32e9a58 100644
--- a/libmpcodecs/vf_pp7.c
+++ b/libmpcodecs/vf_pp7.c
@@ -410,7 +410,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
 static void uninit(struct vf_instance *vf){
     if(!vf->priv) return;
 
-    if(vf->priv->src) free(vf->priv->src);
+    free(vf->priv->src);
     vf->priv->src= NULL;
 
     free(vf->priv);
diff --git a/libmpcodecs/vf_sab.c b/libmpcodecs/vf_sab.c
index 0cb4fd9..7dccd21 100644
--- a/libmpcodecs/vf_sab.c
+++ b/libmpcodecs/vf_sab.c
@@ -153,10 +153,10 @@ static void freeBuffers(FilterParam *f){
 	if(f->preFilterContext) sws_freeContext(f->preFilterContext);
 	f->preFilterContext=NULL;
 
-	if(f->preFilterBuf) free(f->preFilterBuf);
+	free(f->preFilterBuf);
 	f->preFilterBuf=NULL;
 
-	if(f->distCoeff) free(f->distCoeff);
+	free(f->distCoeff);
 	f->distCoeff=NULL;
 }
 
diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c
index 8c2a40d..940f7d2 100644
--- a/libmpcodecs/vf_scale.c
+++ b/libmpcodecs/vf_scale.c
@@ -302,10 +302,8 @@ static int config(struct vf_instance *vf,
     }
     vf->priv->fmt=best;
 
-    if(vf->priv->palette){
-	free(vf->priv->palette);
-	vf->priv->palette=NULL;
-    }
+    free(vf->priv->palette);
+    vf->priv->palette=NULL;
     switch(best){
     case IMGFMT_RGB8: {
       /* set 332 palette for 8 bpp */
@@ -524,7 +522,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){
 static void uninit(struct vf_instance *vf){
     if(vf->priv->ctx) sws_freeContext(vf->priv->ctx);
     if(vf->priv->ctx2) sws_freeContext(vf->priv->ctx2);
-    if(vf->priv->palette) free(vf->priv->palette);
+    free(vf->priv->palette);
     free(vf->priv);
 }
 
diff --git a/libmpcodecs/vf_screenshot.c b/libmpcodecs/vf_screenshot.c
index 3ebcc17..5bd6069 100644
--- a/libmpcodecs/vf_screenshot.c
+++ b/libmpcodecs/vf_screenshot.c
@@ -75,7 +75,7 @@ static int config(struct vf_instance *vf,
     vf->priv->dh = d_height;
     vf->priv->stride = (3*vf->priv->dw+15)&~15;
 
-    if (vf->priv->buffer) free(vf->priv->buffer); // probably reconfigured
+    free(vf->priv->buffer); // probably reconfigured
     vf->priv->buffer = NULL;
 
     return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
diff --git a/libmpcodecs/vf_spp.c b/libmpcodecs/vf_spp.c
index ef725b1..9a995c5 100644
--- a/libmpcodecs/vf_spp.c
+++ b/libmpcodecs/vf_spp.c
@@ -520,13 +520,13 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
 static void uninit(struct vf_instance *vf){
 	if(!vf->priv) return;
 
-	if(vf->priv->temp) free(vf->priv->temp);
+	free(vf->priv->temp);
 	vf->priv->temp= NULL;
-	if(vf->priv->src) free(vf->priv->src);
+	free(vf->priv->src);
 	vf->priv->src= NULL;
-        if(vf->priv->avctx) free(vf->priv->avctx);
+        free(vf->priv->avctx);
         vf->priv->avctx= NULL;
-        if(vf->priv->non_b_qp) free(vf->priv->non_b_qp);
+        free(vf->priv->non_b_qp);
         vf->priv->non_b_qp= NULL;
 
 	free(vf->priv);
diff --git a/libmpcodecs/vf_uspp.c b/libmpcodecs/vf_uspp.c
index 2e1e055..6feb8eb 100644
--- a/libmpcodecs/vf_uspp.c
+++ b/libmpcodecs/vf_uspp.c
@@ -303,9 +303,9 @@ static void uninit(struct vf_instance *vf){
     if(!vf->priv) return;
 
     for(i=0; i<3; i++){
-        if(vf->priv->temp[i]) free(vf->priv->temp[i]);
+        free(vf->priv->temp[i]);
         vf->priv->temp[i]= NULL;
-        if(vf->priv->src[i]) free(vf->priv->src[i]);
+        free(vf->priv->src[i]);
         vf->priv->src[i]= NULL;
     }
     for(i=0; i<BLOCK*BLOCK; i++){
diff --git a/libmpdemux/asfheader.c b/libmpdemux/asfheader.c
index 7f8c73b..9dd5f5f 100644
--- a/libmpdemux/asfheader.c
+++ b/libmpdemux/asfheader.c
@@ -710,7 +710,7 @@ return 1;
 len_err_out:
   mp_msg(MSGT_HEADER, MSGL_FATAL, MSGTR_MPDEMUX_ASFHDR_InvalidLengthInASFHeader);
 err_out:
-  if (hdr) free(hdr);
-  if (streams) free(streams);
+  free(hdr);
+  free(streams);
   return 0;
 }
diff --git a/libmpdemux/demux_aac.c b/libmpdemux/demux_aac.c
index 621b58d..192d620 100644
--- a/libmpdemux/demux_aac.c
+++ b/libmpdemux/demux_aac.c
@@ -65,8 +65,7 @@ static void demux_close_aac(demuxer_t *demuxer)
 	if(!priv)
 		return;
 
-	if(priv->buf)
-		free(priv->buf);
+	free(priv->buf);
 
 	free(demuxer->priv);
 
diff --git a/libmpdemux/demux_asf.c b/libmpdemux/demux_asf.c
index 32a2c5b..9e56d59 100644
--- a/libmpdemux/demux_asf.c
+++ b/libmpdemux/demux_asf.c
@@ -672,12 +672,8 @@ static void demux_close_asf(demuxer_t *demuxer) {
 
     if (!asf) return;
 
-    if (asf->aud_repdata_sizes)
-      free(asf->aud_repdata_sizes);
-
-    if (asf->vid_repdata_sizes)
-      free(asf->vid_repdata_sizes);
-
+    free(asf->aud_repdata_sizes);
+    free(asf->vid_repdata_sizes);
     free(asf);
 }
 
diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c
index 39529e8..ca6b51d 100644
--- a/libmpdemux/demux_audio.c
+++ b/libmpdemux/demux_audio.c
@@ -671,8 +671,6 @@ static void demux_audio_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_
 static void demux_close_audio(demuxer_t* demuxer) {
   da_priv_t* priv = demuxer->priv;
 
-  if(!priv)
-    return;
   free(priv);
 }
 
diff --git a/libmpdemux/demux_film.c b/libmpdemux/demux_film.c
index 8f8db9f..84e4ab3 100644
--- a/libmpdemux/demux_film.c
+++ b/libmpdemux/demux_film.c
@@ -458,8 +458,7 @@ static void demux_close_film(demuxer_t* demuxer) {
 
   if(!film_data)
     return;
-  if(film_data->chunks)
-    free(film_data->chunks);
+  free(film_data->chunks);
   free(film_data);
 
 }
diff --git a/libmpdemux/demux_fli.c b/libmpdemux/demux_fli.c
index 4dd134d..9a9d5eb 100644
--- a/libmpdemux/demux_fli.c
+++ b/libmpdemux/demux_fli.c
@@ -191,11 +191,8 @@ static void demux_close_fli(demuxer_t* demuxer) {
   if(!frames)
     return;
 
-  if(frames->filepos)
-    free(frames->filepos);
-  if(frames->frame_size)
-    free(frames->frame_size);
-
+  free(frames->filepos);
+  free(frames->frame_size);
   free(frames);
 
 }
diff --git a/libmpdemux/demux_mf.c b/libmpdemux/demux_mf.c
index ba603e2..ac63f48 100644
--- a/libmpdemux/demux_mf.c
+++ b/libmpdemux/demux_mf.c
@@ -180,8 +180,6 @@ static demuxer_t* demux_open_mf(demuxer_t* demuxer){
 static void demux_close_mf(demuxer_t* demuxer) {
   mf_t *mf = demuxer->priv;
 
-  if(!mf)
-    return;
   free(mf);
 }
 
diff --git a/libmpdemux/demux_mng.c b/libmpdemux/demux_mng.c
index 0eb9944..07da436 100644
--- a/libmpdemux/demux_mng.c
+++ b/libmpdemux/demux_mng.c
@@ -476,8 +476,7 @@ static void demux_mng_close(demuxer_t* demuxer)
             mng_cleanup(&mng_priv->h_mng);
 
         // free private data
-        if (mng_priv->canvas)
-            free(mng_priv->canvas);
+        free(mng_priv->canvas);
 
         free(mng_priv);
     }
diff --git a/libmpdemux/demux_mpc.c b/libmpdemux/demux_mpc.c
index e9bde98..d17e6bd 100644
--- a/libmpdemux/demux_mpc.c
+++ b/libmpdemux/demux_mpc.c
@@ -199,8 +199,6 @@ static void demux_mpc_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_de
 static void demux_close_mpc(demuxer_t* demuxer) {
   da_priv_t* priv = demuxer->priv;
 
-  if(!priv)
-    return;
   free(priv);
 }
 
diff --git a/libmpdemux/demux_mpg.c b/libmpdemux/demux_mpg.c
index 849ee09..cb5d263 100644
--- a/libmpdemux/demux_mpg.c
+++ b/libmpdemux/demux_mpg.c
@@ -248,7 +248,7 @@ static demuxer_t* demux_mpg_open(demuxer_t* demuxer) {
 
 static void demux_close_mpg(demuxer_t* demuxer) {
   mpg_demuxer_t* mpg_d = demuxer->priv;
-  if (mpg_d) free(mpg_d);
+  free(mpg_d);
 }
 
 
diff --git a/libmpdemux/demux_nsv.c b/libmpdemux/demux_nsv.c
index 4997dae..11be4cb 100644
--- a/libmpdemux/demux_nsv.c
+++ b/libmpdemux/demux_nsv.c
@@ -323,8 +323,6 @@ static int nsv_check_file ( demuxer_t* demuxer )
 static void demux_close_nsv(demuxer_t* demuxer) {
     nsv_priv_t* priv = demuxer->priv;
 
-    if(!priv)
-        return;
     free(priv);
 
 }
diff --git a/libmpdemux/demux_ogg.c b/libmpdemux/demux_ogg.c
index 34ba0dd..561ed85 100644
--- a/libmpdemux/demux_ogg.c
+++ b/libmpdemux/demux_ogg.c
@@ -437,11 +437,10 @@ static void demux_ogg_check_comments(demuxer_t *d, ogg_stream_t *os,
                 sh_sub_t *sh;
 
                 // in case of malicious files with more than one lang per track:
-                if (ogg_d->text_langs[index])
-                    free(ogg_d->text_langs[index]);
+                free(ogg_d->text_langs[index]);
                 ogg_d->text_langs[index] = strdup(val);
                 sh = d->s_streams[index];
-                if (sh && sh->lang)
+                if (sh)
                     free(sh->lang);
                 if (sh)
                     sh->lang = strdup(val);
@@ -1605,13 +1604,11 @@ static void demux_close_ogg(demuxer_t *demuxer)
         }
         free(ogg_d->subs);
     }
-    if (ogg_d->syncpoints)
-        free(ogg_d->syncpoints);
-    if (ogg_d->text_ids)
-        free(ogg_d->text_ids);
+    free(ogg_d->syncpoints);
+    free(ogg_d->text_ids);
     if (ogg_d->text_langs) {
         for (i = 0; i < ogg_d->n_text; i++)
-            if (ogg_d->text_langs[i]) free(ogg_d->text_langs[i]);
+            free(ogg_d->text_langs[i]);
         free(ogg_d->text_langs);
     }
     free(ogg_d);
diff --git a/libmpdemux/demux_pva.c b/libmpdemux/demux_pva.c
index 2b5b757..b5267fc 100644
--- a/libmpdemux/demux_pva.c
+++ b/libmpdemux/demux_pva.c
@@ -516,11 +516,8 @@ static void demux_seek_pva(demuxer_t * demuxer,float rel_seek_secs,float audio_d
 
 static void demux_close_pva(demuxer_t * demuxer)
 {
-	if(demuxer->priv)
-	{
-		free(demuxer->priv);
-		demuxer->priv=NULL;
-	}
+	free(demuxer->priv);
+	demuxer->priv=NULL;
 }
 
 
diff --git a/libmpdemux/demux_real.c b/libmpdemux/demux_real.c
index 1b57789..92abead 100644
--- a/libmpdemux/demux_real.c
+++ b/libmpdemux/demux_real.c
@@ -1626,8 +1626,7 @@ skip_this_chunk:
 #else
 		stream_skip(demuxer->stream, codec_data_size - tmp);
 #endif
-		if (mimet)
-		    free (mimet);
+		free (mimet);
 		break;
 //	    }
 	    }
@@ -1764,12 +1763,9 @@ static void demux_close_real(demuxer_t *demuxer)
 
     if (priv){
     	for(i=0; i<MAX_STREAMS; i++)
-	    if(priv->index_table[i])
-	        free(priv->index_table[i]);
-    if (priv->audio_buf)
-        free(priv->audio_buf);
-    if (priv->audio_timestamp)
-        free(priv->audio_timestamp);
+	    free(priv->index_table[i]);
+	free(priv->audio_buf);
+	free(priv->audio_timestamp);
 	free(priv);
     }
 
diff --git a/libmpdemux/demux_realaud.c b/libmpdemux/demux_realaud.c
index a157075..3bfc031 100644
--- a/libmpdemux/demux_realaud.c
+++ b/libmpdemux/demux_realaud.c
@@ -337,9 +337,8 @@ static void demux_close_ra(demuxer_t *demuxer)
 	ra_priv_t* ra_priv = demuxer->priv;
 
     if (ra_priv) {
-	    if (ra_priv->audio_buf)
-	        free (ra_priv->audio_buf);
-		free(ra_priv);
+	free(ra_priv->audio_buf);
+	free(ra_priv);
     }
 	return;
 }
diff --git a/libmpdemux/demux_roq.c b/libmpdemux/demux_roq.c
index 3831f57..821fc81 100644
--- a/libmpdemux/demux_roq.c
+++ b/libmpdemux/demux_roq.c
@@ -260,8 +260,6 @@ static demuxer_t* demux_open_roq(demuxer_t* demuxer)
 static void demux_close_roq(demuxer_t* demuxer) {
   roq_data_t *roq_data = demuxer->priv;
 
-  if(!roq_data)
-    return;
   free(roq_data);
 }
 
diff --git a/libmpdemux/demux_ts.c b/libmpdemux/demux_ts.c
index 8bef16f..5aed347 100644
--- a/libmpdemux/demux_ts.c
+++ b/libmpdemux/demux_ts.c
@@ -1100,19 +1100,15 @@ static void demux_close_ts(demuxer_t * demuxer)
 
 	if(priv)
 	{
-		if(priv->pat.section.buffer)
-			free(priv->pat.section.buffer);
-		if(priv->pat.progs)
-			free(priv->pat.progs);
+		free(priv->pat.section.buffer);
+		free(priv->pat.progs);
 
 		if(priv->pmt)
 		{
 			for(i = 0; i < priv->pmt_cnt; i++)
 			{
-				if(priv->pmt[i].section.buffer)
-					free(priv->pmt[i].section.buffer);
-				if(priv->pmt[i].es)
-					free(priv->pmt[i].es);
+				free(priv->pmt[i].section.buffer);
+				free(priv->pmt[i].es);
 			}
 			free(priv->pmt);
 		}
diff --git a/libmpdemux/demux_viv.c b/libmpdemux/demux_viv.c
index 5e98916..2091e77 100644
--- a/libmpdemux/demux_viv.c
+++ b/libmpdemux/demux_viv.c
@@ -232,12 +232,9 @@ static void vivo_parse_text_header(demuxer_t *demux, int header_len)
 	token = strtok(NULL, (char *)&("\x0d\x0a"));
     }
 
-    if (buf)
-	free(buf);
-    if (opt)
-	free(opt);
-    if (param)
-	free(param);
+    free(buf);
+    free(opt);
+    free(param);
 }
 
 static int vivo_check_file(demuxer_t* demuxer){
@@ -745,14 +742,10 @@ static void demux_close_vivo(demuxer_t *demuxer)
     vivo_priv_t* priv=demuxer->priv;
 
     if (priv) {
-	if (priv->title)
-	    free(priv->title);
-        if (priv->author)
-	    free(priv->author);
-	if (priv->copyright)
-	    free(priv->copyright);
-	if (priv->producer)
-	   free(priv->producer);
+	free(priv->title);
+	free(priv->author);
+	free(priv->copyright);
+	free(priv->producer);
 	free(priv);
     }
     return;
diff --git a/libmpdemux/muxer_mpeg.c b/libmpdemux/muxer_mpeg.c
index b12cea7..733c297 100644
--- a/libmpdemux/muxer_mpeg.c
+++ b/libmpdemux/muxer_mpeg.c
@@ -496,14 +496,11 @@ init_fail:
     if(s->priv)
     {
       spriv = s->priv;
-      if(spriv->pack)
-        free(spriv->pack);
-      if(spriv->buffer_track)
-        free(spriv->buffer_track);
+      free(spriv->pack);
+      free(spriv->buffer_track);
       free(s->priv);
     }
-    if(s->b_buffer)
-      free(s->b_buffer);
+    free(s->b_buffer);
     free(s);
   }
   return NULL;
-- 
1.7.3.2


--8GpibOaaTibBMecb--


More information about the MPlayer-dev-eng mailing list