changeset 15780:490dff9ee43f

fix memleak when playing mov files
author reimar
date Mon, 20 Jun 2005 14:16:59 +0000
parents a4421e69eb6d
children 051bd310f04c
files libmpdemux/demux_mov.c libmpdemux/demuxer.c
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mov.c	Mon Jun 20 11:39:21 2005 +0000
+++ b/libmpdemux/demux_mov.c	Mon Jun 20 14:16:59 2005 +0000
@@ -500,6 +500,30 @@
     return 0;
 }
 
+void demux_close_mov(demuxer_t *demuxer) {
+  mov_priv_t* priv = demuxer->priv;
+  int i;
+  if (!priv)
+    return;
+  for (i = 0; i < MOV_MAX_TRACKS; i++) {
+    mov_track_t *track = priv->tracks[i];
+    if (track) {
+      free(track->tkdata);
+      free(track->stdata);
+      free(track->stream_header);
+      free(track->samples);
+      free(track->chunks);
+      free(track->chunkmap);
+      free(track->durmap);
+      free(track->keyframes);
+      free(track->editlist);
+      free(track->desc);
+      free(track);
+    }
+  }
+  free(priv);
+}
+
 static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak){
     mov_priv_t* priv=demuxer->priv;
 //    printf("lschunks (level=%d,endpos=%x)\n", level, endpos);
--- a/libmpdemux/demuxer.c	Mon Jun 20 11:39:21 2005 +0000
+++ b/libmpdemux/demuxer.c	Mon Jun 20 14:16:59 2005 +0000
@@ -161,6 +161,7 @@
 #ifdef USE_WIN32DLL
 extern void demux_close_avs(demuxer_t* demuxer);
 #endif
+extern void demux_close_mov(demuxer_t* demuxer);
 
 
 #ifdef USE_TV
@@ -258,6 +259,8 @@
     case DEMUXER_TYPE_AVS:
       demux_close_avs(demuxer); break;
 #endif
+    case DEMUXER_TYPE_MOV:
+      demux_close_mov(demuxer); break;
     }
     // free streams:
     for(i = 0; i < MAX_A_STREAMS; i++)