diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-08-05 11:16:07 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-09-08 17:57:32 +0400 |
commit | 5c7e3e9fb1d7fd3f542fce83ef1d911196d48e11 (patch) | |
tree | a18d4feb2ab41a453b05bdd705f8670702db2501 /include/glib-compat.h | |
parent | 1e2713384c58037ad44f716c31c08daca18862c5 (diff) |
glib-compat: add g_(s)list_free_full()
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>
Diffstat (limited to 'include/glib-compat.h')
-rw-r--r-- | include/glib-compat.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/glib-compat.h b/include/glib-compat.h index 8d5a7f3801..8093163bee 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -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 |