]> git.proxmox.com Git - mirror_qemu.git/commitdiff
glib-compat: add g_(s)list_free_full()
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Fri, 5 Aug 2016 07:16:07 +0000 (11:16 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 8 Sep 2016 13:57:32 +0000 (17:57 +0400)
Those functions are only available since glib 2.28.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
include/glib-compat.h

index 8d5a7f380172f718b86a590bc65dc69d04a0866b..8093163bee4c91150fb818eafd36cafaa8e4554a 100644 (file)
@@ -280,4 +280,28 @@ static inline void g_hash_table_add(GHashTable *hash_table, gpointer key)
     } while (0)
 #endif
 
+#if !GLIB_CHECK_VERSION(2, 28, 0)
+static inline void g_list_free_full(GList *list, GDestroyNotify free_func)
+{
+    GList *l;
+
+    for (l = list; l; l = l->next) {
+        free_func(l->data);
+    }
+
+    g_list_free(list);
+}
+
+static inline void g_slist_free_full(GSList *list, GDestroyNotify free_func)
+{
+    GSList *l;
+
+    for (l = list; l; l = l->next) {
+        free_func(l->data);
+    }
+
+    g_slist_free(list);
+}
+#endif
+
 #endif