[Spice-devel] [SPICE-GTK PATCH 1/2] glib-compat: add g_slist_free_full
Uri Lublin
uril at redhat.com
Thu Dec 6 04:32:27 PST 2012
---
gtk/glib-compat.c | 27 +++++++++++++++++++++++++++
gtk/glib-compat.h | 5 +++++
gtk/spice-channel.c | 1 +
3 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/gtk/glib-compat.c b/gtk/glib-compat.c
index 7bb906c..5f2e29e 100644
--- a/gtk/glib-compat.c
+++ b/gtk/glib-compat.c
@@ -41,6 +41,33 @@ g_simple_async_result_take_error (GSimpleAsyncResult *simple,
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
}
+
+
+/**
+ * g_slist_free_full: (skip)
+ * @list: a #GSList
+ * @free_func: a #GDestroyNotify
+ *
+ * Convenience method, which frees all the memory used by a #GSList,
+ * and calls the specified destroy function on every element's data
+ *
+ * Since: 2.28
+ **/
+G_GNUC_INTERNAL void
+g_slist_free_full(GSList *list,
+ GDestroyNotify free_func)
+{
+ GSList *el;
+
+ if (free_func) {
+ for (el = list; el ; el = g_slist_next(el)) {
+ free_func(el);
+ }
+ }
+
+ g_slist_free(list);
+}
+
#endif
#if !GLIB_CHECK_VERSION(2,30,0)
diff --git a/gtk/glib-compat.h b/gtk/glib-compat.h
index 909b4e1..64e7eb1 100644
--- a/gtk/glib-compat.h
+++ b/gtk/glib-compat.h
@@ -88,6 +88,11 @@ GType spice_error_get_type (void) G_GNUC_CONST;
void
g_simple_async_result_take_error(GSimpleAsyncResult *simple,
GError *error);
+
+void
+g_slist_free_full(GSList *list,
+ GDestroyNotify free_func);
+
#endif /* glib 2.28 */
#if !GLIB_CHECK_VERSION(2,30,0)
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 36fe21e..264d1f2 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -17,6 +17,7 @@
*/
#include "spice-client.h"
#include "spice-common.h"
+#include "glib-compat.h"
#include "spice-channel-priv.h"
#include "spice-session-priv.h"
--
1.7.1
More information about the Spice-devel
mailing list