changeset 540:26a477a5ebda libavformat

move free() of AVStream priv data to av_write_trailer()
author michael
date Fri, 01 Oct 2004 16:30:15 +0000
parents 78a8cbdad269
children 23a5448ade32
files ffm.c mpeg.c utils.c
diffstat 3 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ffm.c	Fri Oct 01 16:00:00 2004 +0000
+++ b/ffm.c	Fri Oct 01 16:30:15 2004 +0000
@@ -278,8 +278,6 @@
         put_flush_packet(pb);
     }
 
-    for(i=0;i<s->nb_streams;i++)
-        av_freep(&s->streams[i]->priv_data);
     return 0;
 }
 #endif //CONFIG_ENCODERS
--- a/mpeg.c	Fri Oct 01 16:00:00 2004 +0000
+++ b/mpeg.c	Fri Oct 01 16:30:15 2004 +0000
@@ -1012,9 +1012,6 @@
     //put_be32(&ctx->pb, ISO_11172_END_CODE);
     //put_flush_packet(&ctx->pb);
 
-    for(i=0;i<ctx->nb_streams;i++)
-        av_freep(&ctx->streams[i]->priv_data);
-
     return 0;
 }
 #endif //CONFIG_ENCODERS
--- a/utils.c	Fri Oct 01 16:00:00 2004 +0000
+++ b/utils.c	Fri Oct 01 16:30:15 2004 +0000
@@ -2094,13 +2094,13 @@
  * @return 0 if OK. AVERROR_xxx if error.  */
 int av_write_trailer(AVFormatContext *s)
 {
-    int ret;
+    int ret, i;
     
     for(;;){
         AVPacket pkt;
         ret= av_interleave_packet(s, &pkt, NULL, 1);
         if(ret<0) //FIXME cleanup needed for ret<0 ?
-            return ret;
+            goto fail;
         if(!ret)
             break;
         
@@ -2110,10 +2110,13 @@
         av_free_packet(&pkt);
         
         if(ret<0)
-            return ret; 
+            goto fail;
     }
 
     ret = s->oformat->write_trailer(s);
+fail:
+    for(i=0;i<s->nb_streams;i++)
+        av_freep(&s->streams[i]->priv_data);
     av_freep(&s->priv_data);
     return ret;
 }