From 2e051cf412ded99108b59bfae38c910c15cedbf5 Mon Sep 17 00:00:00 2001 From: Stefan Ringel Date: Thu, 27 Mar 2014 13:56:26 +0100 Subject: [PATCH] mpegts: use glib alloc and free Signed-off-by: Stefan Ringel https://bugzilla.gnome.org/show_bug.cgi?id=727159 --- gst-libs/gst/mpegts/gst-dvb-descriptor.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/mpegts/gst-dvb-descriptor.c b/gst-libs/gst/mpegts/gst-dvb-descriptor.c index 58b13e1..2560c42 100644 --- a/gst-libs/gst/mpegts/gst-dvb-descriptor.c +++ b/gst-libs/gst/mpegts/gst-dvb-descriptor.c @@ -558,6 +558,13 @@ gst_mpegts_descriptor_from_dvb_subtitling (const gchar * lang, } /* GST_MTS_DESC_DVB_EXTENDED_EVENT (0x4E) */ + +static void +_gst_mpegts_extended_event_item_free (GstMpegTsExtendedEventItem * item) +{ + g_slice_free (GstMpegTsExtendedEventItem, item); +} + /** * gst_mpegts_descriptor_parse_dvb_extended_event: * @descriptor: a %GST_MTS_DESC_DVB_EXTENDED_EVENT #GstMpegTsDescriptor @@ -596,11 +603,12 @@ gst_mpegts_descriptor_parse_dvb_extended_event (const GstMpegTsDescriptor data += 1; res->nb_items = 0; - res->items = g_ptr_array_new (); + res->items = g_ptr_array_new_with_free_func ((GDestroyNotify) + _gst_mpegts_extended_event_item_free); for (guint i = 0; i < len_item;) { desc_data = data; - item = malloc (sizeof (GstMpegTsExtendedEventItem)); + item = g_slice_new0 (GstMpegTsExtendedEventItem); item->item_description = get_encoding_and_convert ((const gchar *) desc_data + 1, *desc_data); @@ -666,6 +674,12 @@ gst_mpegts_descriptor_parse_dvb_component (const GstMpegTsDescriptor } /* GST_MTS_DESC_DVB_CONTENT (0x54) */ +static void +_gst_mpegts_content_free (GstMpegTsContent * content) +{ + g_slice_free (GstMpegTsContent, content); +} + /** * gst_mpegts_descriptor_parse_dvb_content: * @descriptor: a %GST_MTS_DESC_DVB_CONTENT #GstMpegTsDescriptor @@ -688,9 +702,10 @@ gst_mpegts_descriptor_parse_dvb_content (const GstMpegTsDescriptor data = (guint8 *) descriptor->data + 2; len = descriptor->length; - *content = g_ptr_array_new (); + *content = g_ptr_array_new_with_free_func ((GDestroyNotify) + _gst_mpegts_content_free); for (guint8 i = 0; i < len;) { - GstMpegTsContent *cont = malloc (sizeof (GstMpegTsContent)); + GstMpegTsContent *cont = g_slice_new0 (GstMpegTsContent); tmp = *data; cont->content_nibble_1 = (tmp & 0xf0) >> 4; cont->content_nibble_2 = tmp & 0x0f; -- 2.7.4