[libgda/LIBGDA_4.2] Check for correct GLib version before using g_int64_*()



commit ee97665991d0543fbce6812e89c78bc3eae39da8
Author: Vivien Malerba <malerba gnome-db org>
Date:   Mon May 30 21:15:15 2011 +0200

    Check for correct GLib version before using g_int64_*()

 libgda/sqlite/virtual/gda-vprovider-data-model.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/libgda/sqlite/virtual/gda-vprovider-data-model.c b/libgda/sqlite/virtual/gda-vprovider-data-model.c
index 6e476bf..d37d479 100644
--- a/libgda/sqlite/virtual/gda-vprovider-data-model.c
+++ b/libgda/sqlite/virtual/gda-vprovider-data-model.c
@@ -691,6 +691,25 @@ virtualColumn (sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i)
 	}
 }
 
+#if GLIB_CHECK_VERSION (2,22,0)
+#define rowid_equal g_int64_equal
+#define rowid_hash g_int64_hash
+#else
+/* taken from GLib to ensure compatibility with older GLibe versions */
+static
+gboolean
+rowid_equal (gconstpointer v1, gconstpointer v2)
+{
+	return *((const gint64*) v1) == *((const gint64*) v2);
+}
+
+static guint
+rowid_hash (gconstpointer v)
+{
+	return (guint) *(const gint64*) v;
+}
+#endif
+
 static int
 virtualRowid (sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid)
 {
@@ -702,7 +721,7 @@ virtualRowid (sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid)
 	*pRowid = gda_data_model_iter_get_row (cursor->iter);
 	if (! vtable->rowid_hash || (vtable->rowid_hash_model == vtable->td->real_model)) {
 		if (! vtable->rowid_hash) {
-			vtable->rowid_hash = g_hash_table_new_full (g_int64_hash, g_int64_equal,
+			vtable->rowid_hash = g_hash_table_new_full (rowid_hash, rowid_equal,
 								    g_free,
 								    (GDestroyNotify) g_object_unref);
 			vtable->rowid_hash_model = vtable->td->real_model;



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