[FFmpeg-cvslog] r16457 - in trunk: ffmpeg.c libavformat/avformat.h libavformat/metadata.c libavformat/utils.c

aurel subversion
Tue Jan 6 23:11:04 CET 2009


Author: aurel
Date: Tue Jan  6 23:11:04 2009
New Revision: 16457

Log:
free all allocated metadata structures

Modified:
   trunk/ffmpeg.c
   trunk/libavformat/avformat.h
   trunk/libavformat/metadata.c
   trunk/libavformat/utils.c

Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c	Tue Jan  6 23:01:57 2009	(r16456)
+++ trunk/ffmpeg.c	Tue Jan  6 23:11:04 2009	(r16457)
@@ -396,9 +396,17 @@ static int av_exit(int ret)
         if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
             url_fclose(s->pb);
         for(j=0;j<s->nb_streams;j++) {
+            av_metadata_free(&s->streams[j]->metadata);
             av_free(s->streams[j]->codec);
             av_free(s->streams[j]);
         }
+        for(j=0;j<s->nb_programs;j++) {
+            av_metadata_free(&s->programs[j]->metadata);
+        }
+        for(j=0;j<s->nb_chapters;j++) {
+            av_metadata_free(&s->chapters[j]->metadata);
+        }
+        av_metadata_free(&s->metadata);
         av_free(s);
     }
     for(i=0;i<nb_input_files;i++)

Modified: trunk/libavformat/avformat.h
==============================================================================
--- trunk/libavformat/avformat.h	Tue Jan  6 23:01:57 2009	(r16456)
+++ trunk/libavformat/avformat.h	Tue Jan  6 23:11:04 2009	(r16457)
@@ -93,6 +93,11 @@ av_metadata_get(AVMetadata *m, const cha
  */
 int av_metadata_set(AVMetadata **m, AVMetadataTag tag);
 
+/**
+ * Free all the memory allocated for an AVMetadata struct.
+ */
+void av_metadata_free(AVMetadata **m);
+
 
 /* packet functions */
 

Modified: trunk/libavformat/metadata.c
==============================================================================
--- trunk/libavformat/metadata.c	Tue Jan  6 23:01:57 2009	(r16456)
+++ trunk/libavformat/metadata.c	Tue Jan  6 23:11:04 2009	(r16457)
@@ -74,6 +74,20 @@ int av_metadata_set(AVMetadata **pm, AVM
     return 0;
 }
 
+void av_metadata_free(AVMetadata **pm)
+{
+    AVMetadata *m= *pm;
+
+    if(m){
+        while(m->count--){
+            av_free(m->elems[m->count].key);
+            av_free(m->elems[m->count].value);
+        }
+        av_free(m->elems);
+    }
+    av_freep(pm);
+}
+
 #if LIBAVFORMAT_VERSION_MAJOR < 53
 #define FILL_METADATA(s, key, value) {                                        \
     if (value && *value &&                                                    \

Modified: trunk/libavformat/utils.c
==============================================================================
--- trunk/libavformat/utils.c	Tue Jan  6 23:01:57 2009	(r16456)
+++ trunk/libavformat/utils.c	Tue Jan  6 23:11:04 2009	(r16457)
@@ -2285,6 +2285,7 @@ void av_close_input_stream(AVFormatConte
         if (st->parser) {
             av_parser_close(st->parser);
         }
+        av_metadata_free(&st->metadata);
         av_free(st->index_entries);
         av_free(st->codec->extradata);
         av_free(st->codec);
@@ -2295,6 +2296,7 @@ void av_close_input_stream(AVFormatConte
     for(i=s->nb_programs-1; i>=0; i--) {
         av_freep(&s->programs[i]->provider_name);
         av_freep(&s->programs[i]->name);
+        av_metadata_free(&s->programs[i]->metadata);
         av_freep(&s->programs[i]->stream_index);
         av_freep(&s->programs[i]);
     }
@@ -2303,17 +2305,11 @@ void av_close_input_stream(AVFormatConte
     av_freep(&s->priv_data);
     while(s->nb_chapters--) {
         av_free(s->chapters[s->nb_chapters]->title);
+        av_metadata_free(&s->chapters[s->nb_chapters]->metadata);
         av_free(s->chapters[s->nb_chapters]);
     }
     av_freep(&s->chapters);
-    if(s->metadata){
-        while(s->metadata->count--){
-            av_freep(&s->metadata->elems[s->metadata->count].key);
-            av_freep(&s->metadata->elems[s->metadata->count].value);
-        }
-        av_freep(&s->metadata->elems);
-    }
-    av_freep(&s->metadata);
+    av_metadata_free(&s->metadata);
     av_free(s);
 }
 




More information about the ffmpeg-cvslog mailing list