From: Vincent Penquerc'h Date: Thu, 18 Aug 2011 09:05:17 +0000 (+0100) Subject: ogg: use memory slices where appropriate X-Git-Tag: 1.19.3~511^2~6555^2~610 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=53c865624827f428247ea80f62db1c0ff12a6dd2;p=platform%2Fupstream%2Fgstreamer.git ogg: use memory slices where appropriate While there, avoid zeroing newly allocated memory where unnecessary https://bugzilla.gnome.org/show_bug.cgi?id=656775 --- diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 56d23c4..a1f845a 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -60,7 +60,7 @@ GST_DEBUG_CATEGORY (gst_ogg_demux_setup_debug); static ogg_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 = g_memdup (packet->packet, packet->bytes); @@ -72,13 +72,13 @@ static void _ogg_packet_free (ogg_packet * packet) { g_free (packet->packet); - g_free (packet); + g_slice_free (ogg_packet, packet); } static ogg_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 */ 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->body); - g_free (page); + g_slice_free (ogg_page, page); } static gboolean gst_ogg_demux_collect_chain_info (GstOggDemux * ogg, @@ -1094,7 +1094,7 @@ choked: static GstOggChain * 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); chain->ogg = ogg; @@ -1121,7 +1121,7 @@ gst_ogg_chain_free (GstOggChain * chain) gst_object_unref (pad); } g_array_free (chain->streams, TRUE); - g_free (chain); + g_slice_free (GstOggChain, chain); } static void diff --git a/ext/ogg/gstoggparse.c b/ext/ogg/gstoggparse.c index 4d9c771..104a0e5 100644 --- a/ext/ogg/gstoggparse.c +++ b/ext/ogg/gstoggparse.c @@ -117,7 +117,7 @@ free_stream (GstOggStream * stream) 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_free (stream); + g_slice_free (GstOggStream, stream); } 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); - stream = g_new0 (GstOggStream, 1); + stream = g_slice_new0 (GstOggStream); stream->serialno = serialno; stream->in_headers = 1;