Commit 41403505 authored by Edward Hervey's avatar Edward Hervey 🤘

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.
parent bfef4a70
......@@ -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;
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment