glib: add compatibility interface for g_hash_table_add()
authorMarkus Armbruster <armbru@redhat.com>
Tue, 27 Oct 2015 14:44:00 +0000 (15:44 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 30 Oct 2015 08:01:03 +0000 (09:01 +0100)
The next commit will use it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
include/glib-compat.h

index fb25f437b48316fdb5bc4bee42e5230c6c2a5342..03d8b1267518bae59e83de77ae1f602906a2deb2 100644 (file)
@@ -165,6 +165,14 @@ static inline GThread *g_thread_new(const char *name,
 #define CompatGCond GCond
 #endif /* glib 2.31 */
 
+#if !GLIB_CHECK_VERSION(2, 32, 0)
+/* Beware, function returns gboolean since 2.39.2, see GLib commit 9101915 */
+static inline void g_hash_table_add(GHashTable *hash_table, gpointer key)
+{
+    g_hash_table_replace(hash_table, key, key);
+}
+#endif
+
 #ifndef g_assert_true
 #define g_assert_true(expr)                                                    \
     do {                                                                       \