summaryrefslogtreecommitdiff
path: root/json-glib/json-object.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@openedhand.com>2007-10-15 10:28:39 +0100
committerEmmanuele Bassi <ebassi@openedhand.com>2007-10-15 10:28:39 +0100
commit73a7671dedfd3bb9bc1a8c197a68dcef90e627f7 (patch)
tree4f3b91a87be06f2244082fcd69dcfe2f39c99026 /json-glib/json-object.c
parent28928a2f1cbe83a2f1bf699c915daa6eca80f587 (diff)
downloadjson-glib-73a7671dedfd3bb9bc1a8c197a68dcef90e627f7.tar.gz
Provide an internal g_hash_table_get_keys() and bump down GLib dependency
Even though GLib 2.14 is now available, many systems still come out with GLib 2.12. Since we are using just a single 2.14 function for retrieving the members from a JsonObject, we can provide an internal version of that function and hideit behind a pre-processor macro.
Diffstat (limited to 'json-glib/json-object.c')
-rw-r--r--json-glib/json-object.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/json-glib/json-object.c b/json-glib/json-object.c
index 8eb41fc..736df6a 100644
--- a/json-glib/json-object.c
+++ b/json-glib/json-object.c
@@ -160,6 +160,31 @@ json_object_add_member (JsonObject *object,
g_hash_table_replace (object->members, g_strdup (member_name), node);
}
+/* FIXME: yuck */
+#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14
+static void
+get_keys (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ GList **keys = user_data;
+
+ *keys = g_list_prepend (*keys, key);
+}
+
+static GList *
+g_hash_table_get_keys (GHashTable *hash_table)
+{
+ GList *retval = NULL;
+
+ g_return_val_if_fail (hash_table != NULL, NULL);
+
+ g_hash_table_foreach (hash_table, get_keys, &retval);
+
+ return retval;
+}
+#endif /* GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 14 */
+
/**
* json_object_get_members:
* @object: a #JsonObject