[json-glib/json-glib-0-14] Conditionally use g_list_free_full()



commit e95d570170a89c1175adf06720ba1efad96372bd
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Mon Oct 17 11:00:52 2011 +0100

    Conditionally use g_list_free_full()
    
    JSON-GLib depends on GLib â 2.26, and g_list_free_full() was introduced
    in GLib 2.28, so we have to check against the GLib version if we want to
    use it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=661244

 json-glib/json-path.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/json-glib/json-path.c b/json-glib/json-path.c
index 4be1909..abcc505 100644
--- a/json-glib/json-path.c
+++ b/json-glib/json-path.c
@@ -292,7 +292,12 @@ json_path_finalize (GObject *gobject)
 {
   JsonPath *self = JSON_PATH (gobject);
 
+#if GLIB_CHECK_VERSION (2, 28, 0)
   g_list_free_full (self->nodes, path_node_free);
+#else
+  g_list_foreach (self->nodes, (GFunc) path_node_free, NULL);
+  g_list_free (self->nodes);
+#endif
 
   G_OBJECT_CLASS (json_path_parent_class)->finalize (gobject);
 }
@@ -706,7 +711,14 @@ json_path_compile (JsonPath    *path,
 #endif /* JSON_ENABLE_DEBUG */
 
   if (path->nodes != NULL)
-    g_list_free_full (path->nodes, path_node_free);
+    {
+#if GLIB_CHECK_VERSION (2, 28, 0)
+      g_list_free_full (path->nodes, path_node_free);
+#else
+      g_list_foreach (path->nodes, (GFunc) path_node_free, NULL);
+      g_list_free (path->nodes);
+#endif
+    }
 
   path->nodes = nodes;
   path->is_compiled = (path->nodes != NULL);
@@ -714,7 +726,12 @@ json_path_compile (JsonPath    *path,
   return path->nodes != NULL;
 
 fail:
+#if GLIB_CHECK_VERSION (2, 28, 0)
   g_list_free_full (nodes, path_node_free);
+#else
+  g_list_foreach (nodes, (GFunc) path_node_free, NULL);
+  g_list_free (nodes);
+#endif
 
   return FALSE;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]