Commit cab550a1 authored by conrad's avatar conrad

liboggz: use oggz_malloc()/oggz_free() consistently throughout


git-svn-id: http://svn.annodex.net/liboggz/trunk@3817 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent ec53bd29
......@@ -366,7 +366,7 @@ auto_dirac (OGGZ * oggz, long serialno, unsigned char * data, long length, void
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 @@ auto_dirac (OGGZ * oggz, long serialno, unsigned char * data, long length, void
oggz_stream_set_numheaders (oggz, serialno, 0);
free(info);
oggz_free(info);
return 1;
}
......@@ -457,7 +457,7 @@ auto_calc_speex(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) {
= (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 (ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) {
= (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 @@ auto_calc_theora(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) {
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 @@ auto_calc_vorbis(ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op) {
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 (ogg_int64_t now, oggz_stream_t *stream, ogg_packet *op)
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;
......
......@@ -733,11 +733,11 @@ oggz_comment_generate(OGGZ * oggz, long serialno,
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 @@ oggz_comment_generate(OGGZ * oggz, long serialno,
c_packet->bytes -= 1;
}
} else {
free(c_packet);
oggz_free(c_packet);
c_packet = 0;
}
......@@ -790,9 +790,9 @@ void oggz_packet_destroy(ogg_packet *packet) {
if(packet) {
if(packet->packet)
{
free(packet->packet);
oggz_free(packet->packet);
}
free(packet);
oggz_free(packet);
}
return;
}
......@@ -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 @@ oggz_dlist_new (void) {
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 @@ oggz_dlist_delete(OggzDList *dlist) {
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 @@ oggz_dlist_append(OggzDList *dlist, void *elem) {
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 @@ oggz_dlist_prepend(OggzDList *dlist, void *elem) {
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 @@ oggz_dlist_deliter(OggzDList *dlist, OggzDListIterFunc func) {
p->prev->next = p->next;
p->next->prev = p->prev;
free(p);
oggz_free(p);
}
}
......@@ -195,7 +196,7 @@ oggz_dlist_reverse_deliter(OggzDList *dlist, OggzDListIterFunc func) {
p->prev->next = p->next;
p->next->prev = p->prev;
free(p);
oggz_free(p);
}
}
......@@ -226,11 +226,11 @@ oggz_read_new_pbuffer_entry(OGGZ *oggz, ogg_packet *packet,
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 @@ oggz_read_new_pbuffer_entry(OGGZ *oggz, ogg_packet *packet,
void
oggz_read_free_pbuffer_entry(OggzBufferedPacket *p) {
free(p->packet.packet);
free(p);
oggz_free(p->packet.packet);
oggz_free(p);
}
......
......@@ -316,7 +316,7 @@ oggz_write_feed (OGGZ * oggz, ogg_packet * op, long serialno, int flush,
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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment