[xiph-commits] r3817 - liboggz/trunk/src/liboggz

conrad at svn.annodex.net conrad at svn.annodex.net
Sun Dec 7 04:35:17 PST 2008


Author: conrad
Date: 2008-12-07 04:35:17 -0800 (Sun, 07 Dec 2008)
New Revision: 3817

Modified:
   liboggz/trunk/src/liboggz/oggz_auto.c
   liboggz/trunk/src/liboggz/oggz_comments.c
   liboggz/trunk/src/liboggz/oggz_dlist.c
   liboggz/trunk/src/liboggz/oggz_read.c
   liboggz/trunk/src/liboggz/oggz_write.c
Log:
liboggz: use oggz_malloc()/oggz_free() consistently throughout


Modified: liboggz/trunk/src/liboggz/oggz_auto.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_auto.c	2008-12-07 12:35:03 UTC (rev 3816)
+++ liboggz/trunk/src/liboggz/oggz_auto.c	2008-12-07 12:35:17 UTC (rev 3817)
@@ -366,7 +366,7 @@
   int granule_shift = 22; /* not a typo */
   dirac_info *info;
 
-  info = malloc(sizeof(dirac_info));
+  info = oggz_malloc(sizeof(dirac_info));
 
   dirac_parse_info(info, data, length);
 
@@ -383,7 +383,7 @@
 
   oggz_stream_set_numheaders (oggz, serialno, 0);
 
-  free(info);
+  oggz_free(info);
   return 1;
 }
 
@@ -457,7 +457,7 @@
           = (auto_calc_speex_info_t *)stream->calculate_data;
 
   if (stream->calculate_data == NULL) {
-    stream->calculate_data = malloc(sizeof(auto_calc_speex_info_t));
+    stream->calculate_data = oggz_malloc(sizeof(auto_calc_speex_info_t));
     if (stream->calculate_data == NULL) return -1;
     info = stream->calculate_data;
     info->encountered_first_data_packet = 0;
@@ -511,7 +511,7 @@
           = (auto_calc_celt_info_t *)stream->calculate_data;
 
   if (stream->calculate_data == NULL) {
-    stream->calculate_data = malloc(sizeof(auto_calc_celt_info_t));
+    stream->calculate_data = oggz_malloc(sizeof(auto_calc_celt_info_t));
     if (stream->calculate_data == NULL) return -1;
 
     info = stream->calculate_data;
@@ -578,7 +578,7 @@
   if (first_byte & 0x80)
   {
     if (info == NULL) {
-      stream->calculate_data = malloc(sizeof(auto_calc_theora_info_t));
+      stream->calculate_data = oggz_malloc(sizeof(auto_calc_theora_info_t));
       if (stream->calculate_data == NULL) return -1;
       info = stream->calculate_data;
     }
@@ -702,7 +702,7 @@
     long_size = 1 << (op->packet[28] >> 4);
     short_size = 1 << (op->packet[28] & 0xF);
 
-    stream->calculate_data = malloc(sizeof(auto_calc_vorbis_info_t));
+    stream->calculate_data = oggz_malloc(sizeof(auto_calc_vorbis_info_t));
     if (stream->calculate_data == NULL) return -1;
 
     info = (auto_calc_vorbis_info_t *)stream->calculate_data;
@@ -976,7 +976,7 @@
   auto_calc_flac_info_t *info;
 
   if (stream->calculate_data == NULL) {
-    stream->calculate_data = malloc(sizeof(auto_calc_flac_info_t));
+    stream->calculate_data = oggz_malloc(sizeof(auto_calc_flac_info_t));
     if (stream->calculate_data == NULL) return -1;
 
     info = (auto_calc_flac_info_t *)stream->calculate_data;

Modified: liboggz/trunk/src/liboggz/oggz_comments.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_comments.c	2008-12-07 12:35:03 UTC (rev 3816)
+++ liboggz/trunk/src/liboggz/oggz_comments.c	2008-12-07 12:35:17 UTC (rev 3817)
@@ -733,11 +733,11 @@
     return NULL;
   }
 
-  c_packet = malloc(sizeof *c_packet);
+  c_packet = oggz_malloc(sizeof *c_packet);
   if(c_packet) {
     memset(c_packet, 0, sizeof *c_packet);
     c_packet->packetno = 1;
-    c_packet->packet = malloc(buf_size);
+    c_packet->packet = oggz_malloc(buf_size);
   }
 
   if(c_packet && c_packet->packet) {
@@ -765,7 +765,7 @@
 	c_packet->bytes -= 1;
       }
   } else {
-    free(c_packet);
+    oggz_free(c_packet);
     c_packet = 0;
   }
 
@@ -790,9 +790,9 @@
   if(packet) {
     if(packet->packet)
       {
-	free(packet->packet);
+	oggz_free(packet->packet);
       }
-    free(packet);
+    oggz_free(packet);
   }
   return;
 }

Modified: liboggz/trunk/src/liboggz/oggz_dlist.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_dlist.c	2008-12-07 12:35:03 UTC (rev 3816)
+++ liboggz/trunk/src/liboggz/oggz_dlist.c	2008-12-07 12:35:17 UTC (rev 3817)
@@ -34,6 +34,7 @@
 #include <stdlib.h>
 
 #include "oggz_dlist.h"
+#include "oggz_macros.h"
 
 typedef struct OggzDListElem {
   struct OggzDListElem  * next;
@@ -52,19 +53,19 @@
   OggzDList *dlist;
   OggzDListElem *dummy_front, *dummy_back;
   
-  dlist = malloc(sizeof(OggzDList));
+  dlist = oggz_malloc(sizeof(OggzDList));
   if (dlist == NULL) return NULL;
 
-  dummy_front = malloc(sizeof(OggzDListElem));
+  dummy_front = oggz_malloc(sizeof(OggzDListElem));
   if (dummy_front == NULL) {
-    free (dlist);
+    oggz_free (dlist);
     return NULL;
   }
 
-  dummy_back = malloc(sizeof(OggzDListElem));
+  dummy_back = oggz_malloc(sizeof(OggzDListElem));
   if (dummy_back == NULL) {
-    free (dummy_front);
-    free (dlist);
+    oggz_free (dummy_front);
+    oggz_free (dlist);
     return NULL;
   }
 
@@ -86,11 +87,11 @@
   OggzDListElem *p;
 
   for (p = dlist->head->next; p != NULL; p = p->next) {
-    free(p->prev);
+    oggz_free(p->prev);
   }
 
-  free(dlist->tail);
-  free(dlist);
+  oggz_free(dlist->tail);
+  oggz_free(dlist);
 
 }
 
@@ -106,7 +107,7 @@
 
   if (dlist == NULL) return -1;
 
-  new_elem = malloc(sizeof(OggzDListElem));
+  new_elem = oggz_malloc(sizeof(OggzDListElem));
   if (new_elem == NULL) return -1;
 
   new_elem->data = elem;
@@ -125,7 +126,7 @@
 
   if (dlist == NULL) return -1;
 
-  new_elem = malloc(sizeof(OggzDListElem));
+  new_elem = oggz_malloc(sizeof(OggzDListElem));
   if (new_elem == NULL) return -1;
 
   new_elem->data = elem;
@@ -176,7 +177,7 @@
     p->prev->next = p->next;
     p->next->prev = p->prev;
 
-    free(p);
+    oggz_free(p);
   }
 
 }
@@ -195,7 +196,7 @@
     p->prev->next = p->next;
     p->next->prev = p->prev;
 
-    free(p);
+    oggz_free(p);
   }
 
 }

Modified: liboggz/trunk/src/liboggz/oggz_read.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_read.c	2008-12-07 12:35:03 UTC (rev 3816)
+++ liboggz/trunk/src/liboggz/oggz_read.c	2008-12-07 12:35:17 UTC (rev 3817)
@@ -226,11 +226,11 @@
             ogg_int64_t granulepos, long serialno, oggz_stream_t * stream, 
             OggzReader *reader) {
 
-  OggzBufferedPacket *p = malloc(sizeof(OggzBufferedPacket));
+  OggzBufferedPacket *p = oggz_malloc(sizeof(OggzBufferedPacket));
   if (p == NULL) return NULL;
 
   memcpy(&(p->packet), packet, sizeof(ogg_packet));
-  p->packet.packet = malloc(packet->bytes);
+  p->packet.packet = oggz_malloc(packet->bytes);
   memcpy(p->packet.packet, packet->packet, packet->bytes);
 
   p->calced_granulepos = granulepos;
@@ -245,8 +245,8 @@
 void
 oggz_read_free_pbuffer_entry(OggzBufferedPacket *p) {
   
-  free(p->packet.packet);
-  free(p);
+  oggz_free(p->packet.packet);
+  oggz_free(p);
 
 }
 

Modified: liboggz/trunk/src/liboggz/oggz_write.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_write.c	2008-12-07 12:35:03 UTC (rev 3816)
+++ liboggz/trunk/src/liboggz/oggz_write.c	2008-12-07 12:35:17 UTC (rev 3817)
@@ -316,7 +316,7 @@
 
   packet = oggz_malloc (sizeof (oggz_writer_packet_t));
   if (packet == NULL) {
-    if (guard == NULL && new_buf != NULL) free (new_buf);
+    if (guard == NULL && new_buf != NULL) oggz_free (new_buf);
     return OGGZ_ERR_OUT_OF_MEMORY;
   }
 



More information about the commits mailing list