From a842daf05e4d3d5c240ce259707cd695c0dc72a6 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 29 Jan 2004 01:44:08 +0000 Subject: [PATCH] docs/random/ds/element-checklist: Notes about gst_caps_to_string() Original commit message from CVS: * docs/random/ds/element-checklist: Notes about gst_caps_to_string() * gst/registries/gstxmlregistry.c: (gst_xml_registry_save_caps): Fix memory leakage of gst_caps_to_string(). Use GST_PTR_FORMAT instead of gst_caps_to_string(): * gst/autoplug/gstsearchfuncs.c: (gst_autoplug_sp): * gst/autoplug/gstspideridentity.c: (spider_find_suggest), (gst_spider_identity_sink_loop_type_finding): * gst/elements/gsttypefind.c: (gst_type_find_element_have_type), (find_suggest): * gst/gstpad.c: (gst_pad_try_relink_filtered), (gst_pad_set_explicit_caps): * gst/parse/grammar.y: --- ChangeLog | 16 ++++++++++++++++ docs/random/ds/element-checklist | 8 ++++++++ gst/autoplug/gstsearchfuncs.c | 4 ++-- gst/autoplug/gstspideridentity.c | 11 ++--------- gst/elements/gsttypefind.c | 13 +++---------- gst/gstpad.c | 11 ++++------- gst/parse/grammar.y | 4 ++-- gst/registries/gstxmlregistry.c | 1 + plugins/elements/gsttypefind.c | 13 +++---------- 9 files changed, 41 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 876e54f0b7..99a001194e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2004-01-28 David Schleef + + * docs/random/ds/element-checklist: Notes about gst_caps_to_string() + * gst/registries/gstxmlregistry.c: (gst_xml_registry_save_caps): + Fix memory leakage of gst_caps_to_string(). + + Use GST_PTR_FORMAT instead of gst_caps_to_string(): + * gst/autoplug/gstsearchfuncs.c: (gst_autoplug_sp): + * gst/autoplug/gstspideridentity.c: (spider_find_suggest), + (gst_spider_identity_sink_loop_type_finding): + * gst/elements/gsttypefind.c: (gst_type_find_element_have_type), + (find_suggest): + * gst/gstpad.c: (gst_pad_try_relink_filtered), + (gst_pad_set_explicit_caps): + * gst/parse/grammar.y: + 2004-01-28 David Schleef * configure.ac: Add detection for HAVE_PRINTF_EXTENSION and diff --git a/docs/random/ds/element-checklist b/docs/random/ds/element-checklist index 3c74cefef6..c15bb8fd17 100644 --- a/docs/random/ds/element-checklist +++ b/docs/random/ds/element-checklist @@ -25,3 +25,11 @@ config.h. + + +other ideas: + +- plugins should avoid using gst_caps_to_string() in debug statement. + They should use %"GST_PTR_FORMAT" instead. Check all usage for leaks. + + diff --git a/gst/autoplug/gstsearchfuncs.c b/gst/autoplug/gstsearchfuncs.c index 832cb3462f..10da7d56bb 100644 --- a/gst/autoplug/gstsearchfuncs.c +++ b/gst/autoplug/gstsearchfuncs.c @@ -336,8 +336,8 @@ gst_autoplug_sp (const GstCaps *srccaps, const GstCaps *sinkcaps, GList *factori g_return_val_if_fail (srccaps != NULL, NULL); g_return_val_if_fail (sinkcaps != NULL, NULL); - GST_INFO ("attempting to autoplug via shortest path from %s to %s", - gst_caps_to_string(srccaps), gst_caps_to_string(sinkcaps)); + GST_INFO ("attempting to autoplug via shortest path from %" + GST_PTR_FORMAT " to %" GST_PTR_FORMAT, srccaps, sinkcaps); /* wrap all factories as GstAutoplugNode * initialize the cost */ diff --git a/gst/autoplug/gstspideridentity.c b/gst/autoplug/gstspideridentity.c index ea23791fa4..981807bcfb 100644 --- a/gst/autoplug/gstspideridentity.c +++ b/gst/autoplug/gstspideridentity.c @@ -446,11 +446,8 @@ static void spider_find_suggest (gpointer data, guint probability, const GstCaps *caps) { SpiderTypeFind *find = (SpiderTypeFind *) data; - G_GNUC_UNUSED gchar *caps_str; - caps_str = gst_caps_to_string (caps); - GST_INFO ("suggest %u, %s", probability, caps_str); - g_free (caps_str); + GST_INFO ("suggest %u, %" GST_PTR_FORMAT, probability, caps); if (probability > find->best_probability) { gst_caps_replace (&find->caps, gst_caps_copy (caps)); find->best_probability = probability; @@ -525,11 +522,7 @@ plug: g_critical("could not set caps on spideridentity src pad\n"); } } - { - gchar *str = gst_caps_to_string (find.caps); - GST_LOG_OBJECT (ident, "spider starting caps: %s", str); - g_free (str); - } + GST_LOG_OBJECT (ident, "spider starting caps: %" GST_PTR_FORMAT, find.caps); if (type_list) g_list_free (type_list); diff --git a/gst/elements/gsttypefind.c b/gst/elements/gsttypefind.c index 0dcce58eef..5c94666e1c 100644 --- a/gst/elements/gsttypefind.c +++ b/gst/elements/gsttypefind.c @@ -119,14 +119,10 @@ static guint gst_type_find_element_signals[LAST_SIGNAL] = { 0 }; static void gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps) { - gchar *caps_str; - g_assert (typefind->caps == NULL); g_assert (caps != NULL); - caps_str = gst_caps_to_string (caps); - GST_INFO_OBJECT (typefind, "found caps %s", caps_str); - g_free (caps_str); + GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT, caps); typefind->caps = gst_caps_copy (caps); gst_pad_set_explicit_caps (typefind->src, gst_caps_copy(caps)); } @@ -441,13 +437,10 @@ find_peek (gpointer data, gint64 offset, guint size) static void find_suggest (gpointer data, guint probability, const GstCaps *caps) { - gchar *str; TypeFindEntry *entry = (TypeFindEntry *) data; - str = gst_caps_to_string (caps); - GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %s)", - GST_PLUGIN_FEATURE_NAME (entry->factory), probability, str); - g_free (str); + GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")", + GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps); if (((gint) probability) > entry->probability) { entry->probability = probability; gst_caps_replace (&entry->caps, gst_caps_copy (caps)); diff --git a/gst/gstpad.c b/gst/gstpad.c index a3d4fe4def..e287621d53 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2010,16 +2010,13 @@ gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad, { GstRealPad *realsrc, *realsink; GstPadLink *link; - gchar *str; /* generic checks */ g_return_val_if_fail (GST_IS_PAD (srcpad), FALSE); g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE); - str = filtercaps ? gst_caps_to_string (filtercaps) : g_strdup (""); - GST_CAT_INFO (GST_CAT_PADS, "trying to relink %s:%s and %s:%s with filtercaps %s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad), str); - g_free (str); + GST_CAT_INFO (GST_CAT_PADS, "trying to relink %s:%s and %s:%s with filtercaps %" GST_PTR_FORMAT, + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad), filtercaps); /* now we need to deal with the real/ghost stuff */ realsrc = GST_PAD_REALIZE (srcpad); @@ -2239,8 +2236,8 @@ gst_pad_set_explicit_caps (GstPad *pad, const GstCaps *caps) g_return_val_if_fail (GST_IS_PAD (pad), FALSE); - GST_CAT_DEBUG (GST_CAT_PADS, "setting explicit caps to %s", - gst_caps_to_string (caps)); + GST_CAT_DEBUG (GST_CAT_PADS, "setting explicit caps to %" GST_PTR_FORMAT, + caps); if (caps == NULL) { GST_CAT_DEBUG (GST_CAT_PADS, "caps is NULL"); diff --git a/gst/parse/grammar.y b/gst/parse/grammar.y index a7cb76d1e5..29c9696ab6 100644 --- a/gst/parse/grammar.y +++ b/gst/parse/grammar.y @@ -458,10 +458,10 @@ gst_parse_perform_link (link_t *link, graph_t *graph) g_assert (GST_IS_ELEMENT (src)); g_assert (GST_IS_ELEMENT (sink)); - GST_CAT_INFO (GST_CAT_PIPELINE, "linking %s(%s):%u to %s(%s):%u with caps \"%s\"", + GST_CAT_INFO (GST_CAT_PIPELINE, "linking %s(%s):%u to %s(%s):%u with caps \"%" GST_PTR_FORMAT "\"", GST_ELEMENT_NAME (src), link->src_name ? link->src_name : "---", g_slist_length (srcs), GST_ELEMENT_NAME (sink), link->sink_name ? link->sink_name : "---", g_slist_length (sinks), - link->caps ? gst_caps_to_string (link->caps) : "-"); + link->caps); if (!srcs || !sinks) { if (gst_element_link_pads_filtered (src, srcs ? (const gchar *) srcs->data : NULL, diff --git a/gst/registries/gstxmlregistry.c b/gst/registries/gstxmlregistry.c index f368410168..277a5c76ed 100644 --- a/gst/registries/gstxmlregistry.c +++ b/gst/registries/gstxmlregistry.c @@ -1103,6 +1103,7 @@ gst_xml_registry_save_caps (GstXMLRegistry *xmlregistry, const GstCaps *caps) { char *s = gst_caps_to_string (caps); PUT_ESCAPED ("caps", s); + g_free (s); return TRUE; } diff --git a/plugins/elements/gsttypefind.c b/plugins/elements/gsttypefind.c index 0dcce58eef..5c94666e1c 100644 --- a/plugins/elements/gsttypefind.c +++ b/plugins/elements/gsttypefind.c @@ -119,14 +119,10 @@ static guint gst_type_find_element_signals[LAST_SIGNAL] = { 0 }; static void gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps) { - gchar *caps_str; - g_assert (typefind->caps == NULL); g_assert (caps != NULL); - caps_str = gst_caps_to_string (caps); - GST_INFO_OBJECT (typefind, "found caps %s", caps_str); - g_free (caps_str); + GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT, caps); typefind->caps = gst_caps_copy (caps); gst_pad_set_explicit_caps (typefind->src, gst_caps_copy(caps)); } @@ -441,13 +437,10 @@ find_peek (gpointer data, gint64 offset, guint size) static void find_suggest (gpointer data, guint probability, const GstCaps *caps) { - gchar *str; TypeFindEntry *entry = (TypeFindEntry *) data; - str = gst_caps_to_string (caps); - GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %s)", - GST_PLUGIN_FEATURE_NAME (entry->factory), probability, str); - g_free (str); + GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")", + GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps); if (((gint) probability) > entry->probability) { entry->probability = probability; gst_caps_replace (&entry->caps, gst_caps_copy (caps));