mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
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>
This commit is contained in:
parent
1e2713384c
commit
5c7e3e9fb1
1 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue