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

shans at svn.annodex.net shans at svn.annodex.net
Thu Jun 21 03:15:23 PDT 2007


Author: shans
Date: 2007-06-21 03:15:23 -0700 (Thu, 21 Jun 2007)
New Revision: 3017

Modified:
   liboggplay/trunk/src/liboggplay/oggplay_data.c
   liboggplay/trunk/src/liboggplay/oggplay_data.h
Log:
Factored out list freeing function and exposed it in oggplay_data.h



Modified: liboggplay/trunk/src/liboggplay/oggplay_data.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_data.c	2007-06-21 10:14:41 UTC (rev 3016)
+++ liboggplay/trunk/src/liboggplay/oggplay_data.c	2007-06-21 10:15:23 UTC (rev 3017)
@@ -131,19 +131,9 @@
      *
      * First store any old data.
      */
-    OggPlayDataHeader *temp_list          = decode->data_list;
-    OggPlayDataHeader *end_of_temp_list   = decode->end_of_data_list;
     ogg_int64_t presentation_time         = data->presentation_time;
     next_in_list                          = data;
 
-    /*
-     * we need to insert in reverse order, so set the data list to NULL
-     * otherwise adding to the front will be bad.
-     */
-    if (temp_list != NULL) {
-      decode->data_list = NULL;
-    }
-    
     while (decode->untimed_data_list != NULL) {
       OggPlayDataHeader *untimed = decode->untimed_data_list;
 
@@ -162,14 +152,6 @@
 
     }
 
-    /* 
-     * re-prepend any old data 
-     */
-    if (temp_list != NULL) {
-      end_of_temp_list->next = decode->data_list;
-      decode->data_list = temp_list;
-    }
-  
     oggplay_data_add_to_list_end(decode, data);
 
     /*
@@ -189,21 +171,24 @@
 
 }
 
+void
+oggplay_data_free_list(OggPlayDataHeader *list) {
+  OggPlayDataHeader *p;
 
+  while (list != NULL) {
+    p = list;
+    list = list->next;
+    free(p);
+  }
+}
 
 void
 oggplay_data_shutdown_list (OggPlayDecode *decode) {
 
-  OggPlayDataHeader * current = decode->data_list;
-  OggPlayDataHeader * free_me;
+  oggplay_data_free_list(decode->data_list);
+  oggplay_data_free_list(decode->untimed_data_list);
 
-  while (current != NULL) {
-    free_me = current;
-    current = current->next;
-    free(free_me);
-  }
-  
-}
+}  
 
 /*
  * this function removes any displayed, unlocked frames from the list.

Modified: liboggplay/trunk/src/liboggplay/oggplay_data.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_data.h	2007-06-21 10:14:41 UTC (rev 3016)
+++ liboggplay/trunk/src/liboggplay/oggplay_data.h	2007-06-21 10:15:23 UTC (rev 3017)
@@ -57,5 +57,8 @@
 oggplay_data_clean_list (OggPlayDecode *decode);
 
 void
+oggplay_data_free_list(OggPlayDataHeader *list);
+
+void
 oggplay_data_shutdown_list (OggPlayDecode *decode);
 #endif



More information about the commits mailing list