mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Bug 158725 - free linked list with data
Add some helpers for freeing a linked list along with its elements by providing a GDestroyNotify to call on each of them. Add a test. Based on a patch from Cosimo Cecchi.
This commit is contained in:
@@ -186,6 +186,24 @@ g_slist_free_1 (GSList *list)
|
||||
_g_slist_free1 (list);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_slist_free_full:
|
||||
* @list: a pointer to a #GSList
|
||||
* @free_func: the function to be called to free each element's data
|
||||
*
|
||||
* Convenience method, which frees all the memory used by a #GSList, and
|
||||
* calls the specified destroy function on every element's data.
|
||||
*
|
||||
* Since: 2.28
|
||||
**/
|
||||
void
|
||||
g_slist_free_full (GSList *list,
|
||||
GDestroyNotify free_func)
|
||||
{
|
||||
g_slist_foreach (list, (GFunc) free_func, NULL);
|
||||
g_slist_free (list);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_slist_append:
|
||||
* @list: a #GSList
|
||||
|
Reference in New Issue
Block a user