From b9b6c6890a11fd08ab12f9b947766a1b6d9f6d17 Mon Sep 17 00:00:00 2001 From: Christian Schaller Date: Sun, 8 Sep 2002 18:27:36 +0000 Subject: [PATCH] committing many nice little memleaks fixes from Iain, great work dude Original commit message from CVS: committing many nice little memleaks fixes from Iain, great work dude --- docs/random/wtay/registry | 5 +++-- examples/pingpong/pingpong.c | 10 ++++++++-- gst/autoplug/gstspideridentity.c | 6 +++++- gst/autoplug/gststaticautoplug.c | 14 ++++++++++++-- gst/elements/gstaggregator.c | 2 ++ gst/elements/gstfakesink.c | 2 ++ gst/elements/gstidentity.c | 7 +++++++ gst/gstelement.c | 17 ++++++++++------- gst/gstpad.c | 11 +++++++---- plugins/elements/gstaggregator.c | 2 ++ plugins/elements/gstfakesink.c | 2 ++ plugins/elements/gstidentity.c | 7 +++++++ tests/old/examples/pingpong/pingpong.c | 10 ++++++++-- 13 files changed, 75 insertions(+), 20 deletions(-) diff --git a/docs/random/wtay/registry b/docs/random/wtay/registry index 2693d2aaa6..49b820081e 100644 --- a/docs/random/wtay/registry +++ b/docs/random/wtay/registry @@ -17,8 +17,9 @@ Requirements user/system registry -------------------- - -first query the user registry, then fall back to system registry. +There are two be two registries on the system. One system registry and one user registry. +The user registry should be queried first, then if that doesn't exist or don't contain any +plugins able to handle the mediatype it should fall back to system registry. model: ------ diff --git a/examples/pingpong/pingpong.c b/examples/pingpong/pingpong.c index 28e5cc6d31..9dbbc2f1d5 100644 --- a/examples/pingpong/pingpong.c +++ b/examples/pingpong/pingpong.c @@ -24,9 +24,15 @@ make_bin (gint count) { GstElement *bin; GstElement *src; + char *name; - bin = gst_bin_new (g_strdup_printf ("bin%d", count)); - src = gst_element_factory_make ("fakesrc", g_strdup_printf ("fakesrc%d", count)); + name = g_strdup_printf ("bin%d", count); + bin = gst_bin_new (name); + g_free (name); + + name = g_strdup_printf ("fakesrc%d", count); + src = gst_element_factory_make ("fakesrc", name); + g_free (name); gst_bin_add (GST_BIN (bin), src); diff --git a/gst/autoplug/gstspideridentity.c b/gst/autoplug/gstspideridentity.c index 80e52cb841..950a01aef7 100644 --- a/gst/autoplug/gstspideridentity.c +++ b/gst/autoplug/gstspideridentity.c @@ -362,6 +362,7 @@ static void gst_spider_identity_start_type_finding (GstSpiderIdentity *ident) { GstElement* typefind; + gchar *name; gboolean restart = FALSE; GST_DEBUG (GST_CAT_AUTOPLUG, "element %s starts typefinding", GST_ELEMENT_NAME(ident)); @@ -372,7 +373,10 @@ gst_spider_identity_start_type_finding (GstSpiderIdentity *ident) } /* create and connect typefind object */ - typefind = gst_element_factory_make ("typefind", g_strdup_printf("%s%s", "typefind", GST_ELEMENT_NAME(ident))); + name = g_strdup_printf ("%s%s", "typefind", GST_ELEMENT_NAME(ident)); + typefind = gst_element_factory_make ("typefind", name); + g_free (name); + g_signal_connect (G_OBJECT (typefind), "have_type", G_CALLBACK (callback_type_find_have_type), ident); gst_bin_add (GST_BIN (GST_ELEMENT_PARENT (ident)), typefind); diff --git a/gst/autoplug/gststaticautoplug.c b/gst/autoplug/gststaticautoplug.c index 9fb3d3c87f..f6911531cb 100644 --- a/gst/autoplug/gststaticautoplug.c +++ b/gst/autoplug/gststaticautoplug.c @@ -201,7 +201,12 @@ autoplug_dynamic_pad (GstElement *element, GstPad *pad, gpointer data) pads = g_list_next (pads); if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (templ), info->endcap)) { - gst_element_add_ghost_pad (info->result, pad, g_strdup_printf("src_%02d", info->i)); + gchar *name; + + name = g_strdup_printf ("src_%02d", info->i); + gst_element_add_ghost_pad (info->result, pad, name); + g_free (name); + GST_DEBUG (0,"gstpipeline: new dynamic pad %s", GST_PAD_NAME (pad)); break; } @@ -460,7 +465,12 @@ differ: pads = g_list_next (pads); if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (templ), endcap)) { - gst_element_add_ghost_pad (result, pad, g_strdup_printf("src_%02d", i)); + gchar *name; + + name = g_strdup_printf ("src_%02d", i); + gst_element_add_ghost_pad (result, pad, name); + g_free (name); + have_pad = TRUE; break; } diff --git a/gst/elements/gstaggregator.c b/gst/elements/gstaggregator.c index 07aaafb86e..a9dbe8732e 100644 --- a/gst/elements/gstaggregator.c +++ b/gst/elements/gstaggregator.c @@ -174,6 +174,8 @@ gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *templ, cons name = g_strdup_printf ("sink%d",aggregator->numsinkpads); sinkpad = gst_pad_new_from_template (templ, name); + g_free (name); + gst_pad_set_chain_function (sinkpad, gst_aggregator_chain); gst_element_add_pad (GST_ELEMENT (aggregator), sinkpad); diff --git a/gst/elements/gstfakesink.c b/gst/elements/gstfakesink.c index a97c6a3f87..44329a0593 100644 --- a/gst/elements/gstfakesink.c +++ b/gst/elements/gstfakesink.c @@ -182,6 +182,8 @@ gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const name = g_strdup_printf ("sink%d", GST_ELEMENT (fakesink)->numsinkpads); sinkpad = gst_pad_new_from_template (templ, name); + g_free (name); + gst_element_add_pad (GST_ELEMENT (fakesink), sinkpad); return sinkpad; diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index 24426faf3f..be94816e16 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -193,6 +193,7 @@ gst_identity_init (GstIdentity *identity) identity->drop_probability = 0.0; identity->silent = FALSE; identity->dump = FALSE; + identity->last_message = NULL; } static void @@ -218,6 +219,9 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) if (identity->drop_probability > 0.0) { if ((gfloat)(1.0*rand()/(RAND_MAX)) < identity->drop_probability) { + if (identity->last_message != NULL) { + g_free (identity->last_message); + } identity->last_message = g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %llu)", GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (identity), "last-message"); @@ -231,6 +235,9 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) for (i = identity->duplicate; i; i--) { if (!identity->silent) + if (identity->last_message != NULL) { + g_free (identity->last_message); + } identity->last_message = g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %llu)", GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (identity), "last-message"); diff --git a/gst/gstelement.c b/gst/gstelement.c index ca4aaebe30..bae0ebc780 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -2339,6 +2339,7 @@ gst_element_save_thyself (GstObject *object, spec = specs[i]; if (spec->flags & G_PARAM_READABLE) { xmlNodePtr param; + char *contents; g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (spec)); @@ -2347,15 +2348,16 @@ gst_element_save_thyself (GstObject *object, xmlNewChild (param, NULL, "name", spec->name); if (G_IS_PARAM_SPEC_STRING (spec)) - xmlNewChild (param, NULL, "value", g_value_dup_string (&value)); + contents = g_value_dup_string (&value); else if (G_IS_PARAM_SPEC_ENUM (spec)) - xmlNewChild (param, NULL, "value", - g_strdup_printf ("%d", g_value_get_enum (&value))); + contents = g_strdup_printf ("%d", g_value_get_enum (&value)); else if (G_IS_PARAM_SPEC_INT64 (spec)) - xmlNewChild (param, NULL, "value", - g_strdup_printf ("%lld", g_value_get_int64 (&value))); + contents = g_strdup_printf ("%lld", g_value_get_int64 (&value)); else - xmlNewChild (param, NULL, "value", g_strdup_value_contents (&value)); + contents = g_strdup_value_contents (&value); + + xmlNewChild (param, NULL, "value", contents); + g_free (contents); g_value_unset(&value); } @@ -2556,7 +2558,8 @@ gst_element_state_get_name (GstElementState state) case GST_STATE_READY: return "\033[01;31mREADY\033[00m";break; case GST_STATE_PLAYING: return "\033[01;32mPLAYING\033[00m";break; case GST_STATE_PAUSED: return "\033[01;33mPAUSED\033[00m";break; - default: + default: + /* This is a memory leak */ return g_strdup_printf ("\033[01;37;41mUNKNOWN!\033[00m(%d)", state); #else case GST_STATE_VOID_PENDING: return "NONE_PENDING";break; diff --git a/gst/gstpad.c b/gst/gstpad.c index 7c14a107fa..bc770d063f 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2001,13 +2001,16 @@ gst_pad_save_thyself (GstObject *object, xmlNodePtr parent) xmlNewChild (parent, NULL, "name", GST_PAD_NAME (realpad)); if (GST_RPAD_PEER (realpad) != NULL) { + gchar *content; + peer = GST_PAD (GST_RPAD_PEER (realpad)); /* first check to see if the peer's parent's parent is the same */ /* we just save it off */ - xmlNewChild (parent, NULL, "peer", - g_strdup_printf ("%s.%s", - GST_OBJECT_NAME (GST_PAD_PARENT (peer)), - GST_PAD_NAME (peer))); + content = g_strdup_printf ("%s.%s", + GST_OBJECT_NAME (GST_PAD_PARENT (peer)), + GST_PAD_NAME (peer)); + xmlNewChild (parent, NULL, "peer", content); + g_free (content); } else xmlNewChild (parent, NULL, "peer", ""); diff --git a/plugins/elements/gstaggregator.c b/plugins/elements/gstaggregator.c index 07aaafb86e..a9dbe8732e 100644 --- a/plugins/elements/gstaggregator.c +++ b/plugins/elements/gstaggregator.c @@ -174,6 +174,8 @@ gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *templ, cons name = g_strdup_printf ("sink%d",aggregator->numsinkpads); sinkpad = gst_pad_new_from_template (templ, name); + g_free (name); + gst_pad_set_chain_function (sinkpad, gst_aggregator_chain); gst_element_add_pad (GST_ELEMENT (aggregator), sinkpad); diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c index a97c6a3f87..44329a0593 100644 --- a/plugins/elements/gstfakesink.c +++ b/plugins/elements/gstfakesink.c @@ -182,6 +182,8 @@ gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const name = g_strdup_printf ("sink%d", GST_ELEMENT (fakesink)->numsinkpads); sinkpad = gst_pad_new_from_template (templ, name); + g_free (name); + gst_element_add_pad (GST_ELEMENT (fakesink), sinkpad); return sinkpad; diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index 24426faf3f..be94816e16 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -193,6 +193,7 @@ gst_identity_init (GstIdentity *identity) identity->drop_probability = 0.0; identity->silent = FALSE; identity->dump = FALSE; + identity->last_message = NULL; } static void @@ -218,6 +219,9 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) if (identity->drop_probability > 0.0) { if ((gfloat)(1.0*rand()/(RAND_MAX)) < identity->drop_probability) { + if (identity->last_message != NULL) { + g_free (identity->last_message); + } identity->last_message = g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %llu)", GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (identity), "last-message"); @@ -231,6 +235,9 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf) for (i = identity->duplicate; i; i--) { if (!identity->silent) + if (identity->last_message != NULL) { + g_free (identity->last_message); + } identity->last_message = g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %llu)", GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (identity), "last-message"); diff --git a/tests/old/examples/pingpong/pingpong.c b/tests/old/examples/pingpong/pingpong.c index 28e5cc6d31..9dbbc2f1d5 100644 --- a/tests/old/examples/pingpong/pingpong.c +++ b/tests/old/examples/pingpong/pingpong.c @@ -24,9 +24,15 @@ make_bin (gint count) { GstElement *bin; GstElement *src; + char *name; - bin = gst_bin_new (g_strdup_printf ("bin%d", count)); - src = gst_element_factory_make ("fakesrc", g_strdup_printf ("fakesrc%d", count)); + name = g_strdup_printf ("bin%d", count); + bin = gst_bin_new (name); + g_free (name); + + name = g_strdup_printf ("fakesrc%d", count); + src = gst_element_factory_make ("fakesrc", name); + g_free (name); gst_bin_add (GST_BIN (bin), src);