changeset 2871:b2f261fccb0b libavformat

move internal queue freeing code in its own function
author aurel
date Sat, 29 Dec 2007 18:32:47 +0000
parents d2c5c911280d
children a9bb4614c0f8
files matroskadec.c
diffstat 1 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/matroskadec.c	Sat Dec 29 18:30:27 2007 +0000
+++ b/matroskadec.c	Sat Dec 29 18:32:47 2007 +0000
@@ -846,6 +846,23 @@
     matroska->num_packets++;
 }
 
+/*
+ * Free all packets in our internal queue.
+ */
+static void
+matroska_clear_queue (MatroskaDemuxContext *matroska)
+{
+    if (matroska->packets) {
+        int n;
+        for (n = 0; n < matroska->num_packets; n++) {
+            av_free_packet(matroska->packets[n]);
+            av_free(matroska->packets[n]);
+        }
+        av_free(matroska->packets);
+        matroska->packets = NULL;
+    }
+}
+
 
 /*
  * Autodetecting...
@@ -2690,13 +2707,7 @@
     av_free(matroska->muxing_app);
     av_free(matroska->index);
 
-    if (matroska->packets != NULL) {
-        for (n = 0; n < matroska->num_packets; n++) {
-            av_free_packet(matroska->packets[n]);
-            av_free(matroska->packets[n]);
-        }
-        av_free(matroska->packets);
-    }
+    matroska_clear_queue(matroska);
 
     for (n = 0; n < matroska->num_tracks; n++) {
         MatroskaTrack *track = matroska->tracks[n];