ogg: use memory slices where appropriate

While there, avoid zeroing newly allocated memory where unnecessary

https://bugzilla.gnome.org/show_bug.cgi?id=656775
This commit is contained in:
Vincent Penquerc'h 2011-08-18 10:05:17 +01:00 committed by Sebastian Dröge
parent e9a5d4f8fd
commit 53c8656248
2 changed files with 8 additions and 8 deletions

View File

@ -60,7 +60,7 @@ GST_DEBUG_CATEGORY (gst_ogg_demux_setup_debug);
static ogg_packet * static ogg_packet *
_ogg_packet_copy (const ogg_packet * packet) _ogg_packet_copy (const ogg_packet * packet)
{ {
ogg_packet *ret = g_new0 (ogg_packet, 1); ogg_packet *ret = g_slice_new (ogg_packet);
*ret = *packet; *ret = *packet;
ret->packet = g_memdup (packet->packet, packet->bytes); ret->packet = g_memdup (packet->packet, packet->bytes);
@ -72,13 +72,13 @@ static void
_ogg_packet_free (ogg_packet * packet) _ogg_packet_free (ogg_packet * packet)
{ {
g_free (packet->packet); g_free (packet->packet);
g_free (packet); g_slice_free (ogg_packet, packet);
} }
static ogg_page * static ogg_page *
gst_ogg_page_copy (ogg_page * page) gst_ogg_page_copy (ogg_page * page)
{ {
ogg_page *p = g_new0 (ogg_page, 1); ogg_page *p = g_slice_new (ogg_page);
/* make a copy of the page */ /* make a copy of the page */
p->header = g_memdup (page->header, page->header_len); p->header = g_memdup (page->header, page->header_len);
@ -94,7 +94,7 @@ gst_ogg_page_free (ogg_page * page)
{ {
g_free (page->header); g_free (page->header);
g_free (page->body); g_free (page->body);
g_free (page); g_slice_free (ogg_page, page);
} }
static gboolean gst_ogg_demux_collect_chain_info (GstOggDemux * ogg, static gboolean gst_ogg_demux_collect_chain_info (GstOggDemux * ogg,
@ -1094,7 +1094,7 @@ choked:
static GstOggChain * static GstOggChain *
gst_ogg_chain_new (GstOggDemux * ogg) gst_ogg_chain_new (GstOggDemux * ogg)
{ {
GstOggChain *chain = g_new0 (GstOggChain, 1); GstOggChain *chain = g_slice_new0 (GstOggChain);
GST_DEBUG_OBJECT (ogg, "creating new chain %p", chain); GST_DEBUG_OBJECT (ogg, "creating new chain %p", chain);
chain->ogg = ogg; chain->ogg = ogg;
@ -1121,7 +1121,7 @@ gst_ogg_chain_free (GstOggChain * chain)
gst_object_unref (pad); gst_object_unref (pad);
} }
g_array_free (chain->streams, TRUE); g_array_free (chain->streams, TRUE);
g_free (chain); g_slice_free (GstOggChain, chain);
} }
static void static void

View File

@ -117,7 +117,7 @@ free_stream (GstOggStream * stream)
g_list_foreach (stream->unknown_pages, (GFunc) gst_mini_object_unref, NULL); g_list_foreach (stream->unknown_pages, (GFunc) gst_mini_object_unref, NULL);
g_list_foreach (stream->stored_buffers, (GFunc) gst_mini_object_unref, NULL); g_list_foreach (stream->stored_buffers, (GFunc) gst_mini_object_unref, NULL);
g_free (stream); g_slice_free (GstOggStream, stream);
} }
static void static void
@ -140,7 +140,7 @@ gst_ogg_parse_new_stream (GstOggParse * parser, ogg_page * page)
GST_DEBUG_OBJECT (parser, "creating new stream %08x", serialno); GST_DEBUG_OBJECT (parser, "creating new stream %08x", serialno);
stream = g_new0 (GstOggStream, 1); stream = g_slice_new0 (GstOggStream);
stream->serialno = serialno; stream->serialno = serialno;
stream->in_headers = 1; stream->in_headers = 1;