Revert gst_plugin_feature_get_name to const string return

Returning a newly allocated string makes no sense. It's unexpected for a
getter, and also this behaves differently in 0.10, so it would make future
merges harder.

Except for these two places here in core which were updated for the new
semantic, the return value is getting leaked all over the place.
This commit is contained in:
René Stadler 2011-10-19 23:07:46 +02:00
parent 7460061645
commit 5800757369
4 changed files with 12 additions and 21 deletions

View file

@ -67,15 +67,13 @@ typedef enum {
* gst_plugin_feature_get_name:
* @feature: a #GstPluginFeature to get the name of @feature.
*
* Returns a copy of the name of @feature.
* Caller should g_free() the return value after usage.
* For a nameless plugin feature, this returns NULL, which you can safely g_free()
* as well.
* Returns the name of @feature.
* For a nameless plugin feature, this returns NULL.
*
* Returns: (transfer full): the name of @feature. g_free() after usage. MT safe.
* Returns: (transfer none): the name of @feature. MT safe.
*
*/
#define gst_plugin_feature_get_name(feature) gst_object_get_name(GST_OBJECT_CAST(feature))
#define gst_plugin_feature_get_name(feature) GST_OBJECT_NAME(feature)
/**
* gst_plugin_feature_set_name:

View file

@ -277,11 +277,8 @@ gst_registry_finalize (GObject * object)
GstPluginFeature *feature = f->data;
if (feature) {
#ifndef GST_DISABLE_GST_DEBUG
gchar *name = gst_plugin_feature_get_name (feature);
GST_LOG_OBJECT (registry, "removing feature %p (%s)", feature, name);
g_free (name);
#endif
GST_LOG_OBJECT (registry, "removing feature %p (%s)", feature,
GST_OBJECT_NAME (feature));
gst_object_unparent (GST_OBJECT_CAST (feature));
}
f = g_list_next (f);

View file

@ -59,13 +59,13 @@ setup (void)
for (f = features; f; f = f->next) {
GstPluginFeature *feature = f->data;
gchar *name;
const gchar *name;
gboolean ignore = FALSE;
if (!GST_IS_ELEMENT_FACTORY (feature))
continue;
name = gst_plugin_feature_get_name (feature);
name = GST_OBJECT_NAME (feature);
if (ignorelist) {
gchar **s;
@ -76,14 +76,12 @@ setup (void)
ignore = TRUE;
}
}
if (ignore) {
g_free (name);
if (ignore)
continue;
}
}
GST_DEBUG ("adding element %s", name);
elements = g_list_prepend (elements, name);
elements = g_list_prepend (elements, g_strdup (name));
}
gst_plugin_feature_list_free (features);
}

View file

@ -55,13 +55,11 @@ print_plugin (const gchar * marker, GstRegistry * registry, GstPlugin * plugin)
features = gst_registry_get_feature_list_by_plugin (registry, name);
for (f = features; f != NULL; f = f->next) {
GstPluginFeature *feature;
gchar *featurename;
feature = GST_PLUGIN_FEATURE (f->data);
featurename = gst_plugin_feature_get_name (feature);
GST_LOG ("%s: feature: %p %s", marker, feature, featurename);
g_free (featurename);
GST_LOG ("%s: feature: %p %s", marker, feature,
GST_OBJECT_NAME (feature));
}
gst_plugin_feature_list_free (features);
}