Revert gst_plugin_feature_get_name to const string return
authorRené Stadler <rene.stadler@collabora.co.uk>
Wed, 19 Oct 2011 21:07:46 +0000 (23:07 +0200)
committerRené Stadler <rene.stadler@collabora.co.uk>
Wed, 19 Oct 2011 21:40:10 +0000 (23:40 +0200)
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.

gst/gstpluginfeature.h
gst/gstregistry.c
tests/check/generic/states.c
tests/check/gst/gstregistry.c

index b8db0f4..ca463c7 100644 (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:
index 2ee0c9e..e92c1b3 100644 (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);
index 97b8191..4ab3442 100644 (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);
   }
index 6d13cce..2487f95 100644 (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);
 }