[gst-cvs] gstreamer: gstpluginfeature: API : new gst_plugin_feature_list_copy() method
Edward Hervey
bilboed at kemper.freedesktop.org
Sat Oct 24 01:49:01 PDT 2009
Module: gstreamer
Branch: master
Commit: ebee2588062645afa75f5a800350bb5b14e53ecf
URL: http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=ebee2588062645afa75f5a800350bb5b14e53ecf
Author: Edward Hervey <bilboed at bilboed.com>
Date: Wed Oct 21 09:40:49 2009 +0200
gstpluginfeature: API : new gst_plugin_feature_list_copy() method
This allows copying AND incrementing the refcount at the same time,
avoiding a double iteratio of the GList
---
docs/gst/gstreamer-sections.txt | 1 +
gst/gstpluginfeature.c | 35 +++++++++++++++++++++++++++++++++++
gst/gstpluginfeature.h | 1 +
win32/common/libgstreamer.def | 1 +
4 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
index 59a3de2..8dec231 100644
--- a/docs/gst/gstreamer-sections.txt
+++ b/docs/gst/gstreamer-sections.txt
@@ -1787,6 +1787,7 @@ gst_plugin_feature_set_name
gst_plugin_feature_get_rank
gst_plugin_feature_get_name
gst_plugin_feature_load
+gst_plugin_feature_list_copy
gst_plugin_feature_list_free
gst_plugin_feature_check_version
<SUBSECTION Standard>
diff --git a/gst/gstpluginfeature.c b/gst/gstpluginfeature.c
index 4b193ca..ebce972 100644
--- a/gst/gstpluginfeature.c
+++ b/gst/gstpluginfeature.c
@@ -260,6 +260,41 @@ gst_plugin_feature_list_free (GList * list)
}
/**
+ * gst_plugin_feature_list_copy:
+ * @list: list of #GstPluginFeature
+ *
+ * Copies the list of features. Caller should call @gst_plugin_feature_list_free
+ * when done with the list.
+ *
+ * Returns: a copy of @list, with each feature's reference count incremented.
+ */
+GList *
+gst_plugin_feature_list_copy (GList * list)
+{
+ GList *new_list = NULL;
+
+ if (G_LIKELY (list)) {
+ GList *last;
+
+ new_list = g_list_alloc ();
+ new_list->data = g_object_ref ((GObject *) list->data);
+ new_list->prev = NULL;
+ last = new_list;
+ list = list->next;
+ while (list) {
+ last->next = g_list_alloc ();
+ last->next->prev = last;
+ last = last->next;
+ last->data = g_object_ref ((GObject *) list->data);
+ list = list->next;
+ }
+ last->next = NULL;
+ }
+
+ return new_list;
+}
+
+/**
* gst_plugin_feature_check_version:
* @feature: a feature
* @min_major: minimum required major version
diff --git a/gst/gstpluginfeature.h b/gst/gstpluginfeature.h
index a0a732d..ee1a6ce 100644
--- a/gst/gstpluginfeature.h
+++ b/gst/gstpluginfeature.h
@@ -137,6 +137,7 @@ guint gst_plugin_feature_get_rank (GstPluginFeature *featu
G_CONST_RETURN gchar *gst_plugin_feature_get_name (GstPluginFeature *feature);
void gst_plugin_feature_list_free (GList *list);
+GList *gst_plugin_feature_list_copy (GList *list);
gboolean gst_plugin_feature_check_version (GstPluginFeature *feature,
guint min_major,
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index bc3ad3e..fc88756 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -711,6 +711,7 @@ EXPORTS
gst_plugin_feature_get_name
gst_plugin_feature_get_rank
gst_plugin_feature_get_type
+ gst_plugin_feature_list_copy
gst_plugin_feature_list_free
gst_plugin_feature_load
gst_plugin_feature_set_name
More information about the Gstreamer-commits
mailing list