[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-2.7 v4 03/36] glib-compat: add g_(s)list_free_fu
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH for-2.7 v4 03/36] glib-compat: add g_(s)list_free_full() |
Date: |
Fri, 5 Aug 2016 12:23:48 +0400 |
From: Marc-André Lureau <address@hidden>
Those functions are only available since glib 2.28.
Signed-off-by: Marc-André Lureau <address@hidden>
---
include/glib-compat.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/include/glib-compat.h b/include/glib-compat.h
index 01aa7b3..ff7eae5 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -260,4 +260,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
--
2.9.0
- [Qemu-devel] [PATCH for-2.7 v4 00/36] Various memory leak fixes, marcandre . lureau, 2016/08/05
- [Qemu-devel] [PATCH for-2.7 v4 01/36] build-sys: fix building with make CFLAGS=.. argument, marcandre . lureau, 2016/08/05
- [Qemu-devel] [PATCH for-2.7 v4 02/36] tests: fix test-qga leaks, marcandre . lureau, 2016/08/05
- [Qemu-devel] [PATCH for-2.7 v4 03/36] glib-compat: add g_(s)list_free_full(),
marcandre . lureau <=
- [Qemu-devel] [PATCH for-2.7 v4 04/36] qga: free the whole blacklist, marcandre . lureau, 2016/08/05
- [Qemu-devel] [PATCH for-2.7 v4 05/36] qga: free remaining leaking state, marcandre . lureau, 2016/08/05
- [Qemu-devel] [PATCH for-2.7 v4 06/36] tests: fix test-cutils leaks, marcandre . lureau, 2016/08/05
- [Qemu-devel] [PATCH for-2.7 v4 07/36] tests: fix test-vmstate leaks, marcandre . lureau, 2016/08/05
- [Qemu-devel] [PATCH for-2.7 v4 08/36] tests: fix test-iov leaks, marcandre . lureau, 2016/08/05