[xiph-commits] r3034 - liboggplay/trunk/src/liboggplay

shans at svn.annodex.net shans at svn.annodex.net
Sun Jun 24 18:19:27 PDT 2007


Author: shans
Date: 2007-06-24 18:19:27 -0700 (Sun, 24 Jun 2007)
New Revision: 3034

Modified:
   liboggplay/trunk/src/liboggplay/oggplay_private.h
   liboggplay/trunk/src/liboggplay/oggplay_seek.c
Log:
Added linked list of trashes to fix remaining memory leaks (hopefully)



Modified: liboggplay/trunk/src/liboggplay/oggplay_private.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_private.h	2007-06-25 01:08:38 UTC (rev 3033)
+++ liboggplay/trunk/src/liboggplay/oggplay_private.h	2007-06-25 01:19:27 UTC (rev 3034)
@@ -167,9 +167,12 @@
   ogg_int64_t     base_time;
 } OggPlaySkeletonDecode;
 
-typedef struct {
-  OggPlayDataHeader   * old_data;
-  OggPlayBuffer       * old_buffer;
+struct OggPlaySeekTrash;
+
+typedef struct OggPlaySeekTrash {
+  OggPlayDataHeader       * old_data;
+  OggPlayBuffer           * old_buffer;
+  struct OggPlaySeekTrash * next;
 } OggPlaySeekTrash;
 
 struct _OggPlay {

Modified: liboggplay/trunk/src/liboggplay/oggplay_seek.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_seek.c	2007-06-25 01:08:38 UTC (rev 3033)
+++ liboggplay/trunk/src/liboggplay/oggplay_seek.c	2007-06-25 01:19:27 UTC (rev 3034)
@@ -42,6 +42,7 @@
 oggplay_seek(OggPlay *me, ogg_int64_t milliseconds) {
 
   OggPlaySeekTrash    * trash;
+  OggPlaySeekTrash   ** p;
   OggPlayDataHeader  ** end_of_list_p;
   int                   i;
   
@@ -103,9 +104,16 @@
   me->presentation_time /= me->callback_period;
   me->presentation_time *= me->callback_period;
   me->target = me->presentation_time + me->callback_period;
- 
-  me->trash = trash;
 
+  trash->next = NULL;
+
+  p = &(me->trash);
+  while (*p != NULL) {
+    p = &((*p)->next);
+  }
+  
+  *p = trash;
+
   return E_OGGPLAY_OK;
   
 }
@@ -113,8 +121,19 @@
 void
 oggplay_take_out_trash(OggPlay *me, OggPlaySeekTrash *trash) {
 
-  oggplay_buffer_shutdown(me, trash->old_buffer);
-  oggplay_data_free_list(trash->old_data);
-  free(trash);
+  OggPlaySeekTrash *p = NULL;
 
+  for (; trash != NULL; trash = trash->next) {
+
+    oggplay_buffer_shutdown(me, trash->old_buffer);
+    oggplay_data_free_list(trash->old_data);
+    if (p != NULL) {
+      free(p);
+    }
+    p = trash;
+  }
+
+  if (p != NULL) {
+    free(p);
+  }
 }



More information about the commits mailing list