[Pacemaker] Pacemaker-1.1.4, when?

Andrew Beekhof andrew at beekhof.net
Thu Nov 11 08:48:23 UTC 2010


This might be a little better:

diff -r dd75da218e4f configure.ac
--- a/configure.ac      Fri Oct 29 12:12:45 2010 +0200
+++ b/configure.ac      Tue Nov 09 13:20:55 2010 +0100
@@ -654,7 +654,7 @@ AC_MSG_RESULT(using $GLIBCONFIG)

 AC_CHECK_LIB(glib-2.0, g_hash_table_get_values)
 if test "x$ac_cv_lib_glib_2_0_g_hash_table_get_values" != x""yes; then
-   AC_MSG_ERROR(Your version of Glib is too old, you need at least 2.14)
+   AC_MSG_WARN(Your version of Glib is too old, you should have at least 2.14)
 fi

 #
diff -r dd75da218e4f include/crm/common/util.h
--- a/include/crm/common/util.h Fri Oct 29 12:12:45 2010 +0200
+++ b/include/crm/common/util.h Tue Nov 09 13:20:55 2010 +0100
@@ -298,4 +298,59 @@ extern int node_score_infinity;
 extern xmlNode *create_operation_update(xmlNode *parent, lrm_op_t
*op, const char *caller_version, int target_rc, const char *origin,
int level);
 extern void free_lrm_op(lrm_op_t *op);

+#if HAVE_LIBGLIB_2_0
+
+#else
+
+typedef struct fake_ghi
+{
+       int         offset;
+       GHashTable *hash;
+       GList      *values;
+
+} GHashTableIter;
+
+static inline void g_hash_append_value(gpointer key, gpointer value,
gpointer user_data)
+{
+    GList **values = (GList **)user_data;
+    *values = g_list_append(*values, value);
+}
+
+static inline GList *g_hash_table_get_values(GHashTable *hash_table);
+{
+    GList *values = NULL;
+    g_hash_table_foreach(hash_table, g_hash_append_value, &values);
+}
+
+static inline void g_hash_table_iter_init(GHashTableIter *iter,
GHashTable *hash_table)
+{
+    iter->offset = 0;
+    iter->hash = hash_table;
+
+    /* iter->values = g_hash_table_get_values(hash_table); */
+
+    /* We could cache the values, but then we need to clean up the list
+     * later which doesn't fit the glib2 API
+     * So instead we calculate it in _next() every time its needed
+     */
+}
+
+
+static inline gboolean g_hash_table_iter_next(GHashTableIter *iter,
gpointer *key, gpointer *value)
+{
+    GList *values = iter->values;
+    if(iter->values == NULL) {
+       values = g_hash_table_get_values(iter->hash_table);
+    }
+
+    iter->offset++;
+    *value = g_list_nth_data(values, iter->offset);
+
+    if(iter->values == NULL) {
+       g_list_free(values);
+    }
+    return (*value) != NULL;
+}
+
 #endif
+
+#endif




More information about the Pacemaker mailing list