Use g_queue_free_full().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-12-03 20:17:21 +03:00
parent c0abaa6508
commit 1ff4005228
3 changed files with 27 additions and 3 deletions

View File

@ -87,6 +87,27 @@ g_list_free_full (GList * list, GDestroyNotify free_func)
g_list_free (list); g_list_free (list);
} }
/* --------------------------------------------------------------------------------------------- */
#endif /* ! GLIB_CHECK_VERSION (2, 28, 0) */ #endif /* ! GLIB_CHECK_VERSION (2, 28, 0) */
#if ! GLIB_CHECK_VERSION (2, 32, 0)
/**
* g_queue_free_full:
* @queue: a pointer to a #GQueue
* @free_func: the function to be called to free each element's data
*
* Convenience method, which frees all the memory used by a #GQueue,
* and calls the specified destroy function on every element's data.
*
* Since: 2.32
*/
void
g_queue_free_full (GQueue * queue, GDestroyNotify free_func)
{
g_queue_foreach (queue, (GFunc) free_func, NULL);
g_queue_free (queue);
}
#endif /* ! GLIB_CHECK_VERSION (2, 32, 0) */
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -16,6 +16,10 @@ void g_slist_free_full (GSList * list, GDestroyNotify free_func);
void g_list_free_full (GList * list, GDestroyNotify free_func); void g_list_free_full (GList * list, GDestroyNotify free_func);
#endif /* ! GLIB_CHECK_VERSION (2, 28, 0) */ #endif /* ! GLIB_CHECK_VERSION (2, 28, 0) */
#if ! GLIB_CHECK_VERSION (2, 32, 0)
void g_queue_free_full (GQueue * queue, GDestroyNotify free_func);
#endif /* ! GLIB_CHECK_VERSION (2, 32, 0) */
/*** inline functions ****************************************************************************/ /*** inline functions ****************************************************************************/
#endif /* MC_GLIBCOMPAT_H */ #endif /* MC_GLIBCOMPAT_H */

View File

@ -759,11 +759,10 @@ listbox_remove_list (WListbox * l)
{ {
if (l->list != NULL) if (l->list != NULL)
{ {
g_queue_foreach (l->list, (GFunc) listbox_entry_free, NULL); g_queue_free_full (l->list, (GDestroyNotify) listbox_entry_free);
g_queue_free (l->list); l->list = NULL;
} }
l->list = NULL;
l->pos = l->top = 0; l->pos = l->top = 0;
} }
} }