summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2009-11-12 09:07:03 +0100
committerEdward Hervey <bilboed@bilboed.com>2009-12-07 09:49:06 +0100
commit41403505944068cf39f6d254401a75a64533b289 (patch)
treea11cabd47d872f82c991cca4f89e31596fe05929
parentbfef4a70bf68d052b3430277ec62af21adf1816b (diff)
gstobject: Avoid double strdup when setting NULL names.
Instead of chaining up to gst_object_set_name (which does typechecking and strdup's the name again), just use the already allocated new name.
-rw-r--r--gst/gstobject.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/gst/gstobject.c b/gst/gstobject.c
index 52b3fb1c0f..996353b3d0 100644
--- a/gst/gstobject.c
+++ b/gst/gstobject.c
@@ -595,7 +595,6 @@ gst_object_set_name_default (GstObject * object)
const gchar *type_name;
gint count;
gchar *name, *tmp;
- gboolean result;
GQuark q;
/* to ensure guaranteed uniqueness across threads, only one thread
@@ -620,10 +619,22 @@ gst_object_set_name_default (GstObject * object)
name = g_ascii_strdown (tmp, -1);
g_free (tmp);
- result = gst_object_set_name (object, name);
- g_free (name);
+ GST_OBJECT_LOCK (object);
+ if (G_UNLIKELY (object->parent != NULL))
+ goto had_parent;
+ g_free (object->name);
+ object->name = name;
- return result;
+ GST_OBJECT_UNLOCK (object);
+
+ return TRUE;
+
+had_parent:
+ {
+ GST_WARNING ("parented objects can't be renamed");
+ GST_OBJECT_UNLOCK (object);
+ return FALSE;
+ }
}
/**