[MPlayer-cvslog] CVS: main/libmpdemux muxer.c,1.15,1.16

Nico Sabbi CVS syncmail at mplayerhq.hu
Sun Mar 12 23:14:02 CET 2006


CVS change done by Nico Sabbi CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv21617

Modified Files:
	muxer.c 
Log Message:
unified failure case in muxer_new_muxer()

Index: muxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- muxer.c	12 Mar 2006 18:13:11 -0000	1.15
+++ muxer.c	12 Mar 2006 22:14:00 -0000	1.16
@@ -19,51 +19,39 @@
 #include "stheader.h"
 
 muxer_t *muxer_new_muxer(int type,FILE *f){
-    muxer_t* muxer=malloc(sizeof(muxer_t));
-    memset(muxer,0,sizeof(muxer_t));
+    muxer_t* muxer=calloc(1,sizeof(muxer_t));
     if(!muxer)
         return NULL;
     muxer->file = f;
     switch (type) {
       case MUXER_TYPE_MPEG:
 	if(! muxer_init_muxer_mpeg(muxer))
-        {
-          free(muxer);
-          return NULL;
-        }
+	  goto fail;
 	break;
       case MUXER_TYPE_RAWVIDEO:
         if(! muxer_init_muxer_rawvideo(muxer))
-        {
-	  free(muxer);
-	  return NULL;
-        }
+	  goto fail;
 	break;
       case MUXER_TYPE_RAWAUDIO:
         if(! muxer_init_muxer_rawaudio(muxer))
-        {
-          free(muxer);
-          return NULL;
-        }
+	  goto fail;
         break;
 #if defined(USE_LIBAVFORMAT) || defined(USE_LIBAVFORMAT_SO)
       case MUXER_TYPE_LAVF:
         if(! muxer_init_muxer_lavf(muxer))
-        {
-          free(muxer);
-          return NULL;
-        }
+	  goto fail;
         break;
 #endif
       case MUXER_TYPE_AVI:
       default:
 	if(! muxer_init_muxer_avi(muxer))
-        {
-          free(muxer);
-          return NULL;
-        }
+	  goto fail;
     }
     return muxer;
+
+fail:
+    free(muxer);
+    return NULL;
 }
 
 /* buffer frames until we either:




More information about the MPlayer-cvslog mailing list