Use g_slist_free_full().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2013-11-04 11:56:14 +04:00
parent d0a082fbd5
commit 90dc6fffac
7 changed files with 31 additions and 11 deletions

View File

@ -96,3 +96,24 @@ g_strcmp0 (const char *str1, const char *str2)
#endif /* ! GLIB_CHECK_VERSION (2, 16, 0) */
/* --------------------------------------------------------------------------------------------- */
#if ! GLIB_CHECK_VERSION (2, 28, 0)
/**
* 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);
}
#endif /* ! GLIB_CHECK_VERSION (2, 28, 0) */
/* --------------------------------------------------------------------------------------------- */

View File

@ -19,6 +19,10 @@ gboolean g_unichar_iszerowidth (gunichar);
int g_strcmp0 (const char *str1, const char *str2);
#endif /* ! GLIB_CHECK_VERSION (2, 16, 0) */
#if ! GLIB_CHECK_VERSION (2, 28, 0)
void g_slist_free_full (GSList * list, GDestroyNotify free_func);
#endif /* ! GLIB_CHECK_VERSION (2, 28, 0) */
/*** inline functions ****************************************************************************/
#endif /* MC_GLIBCOMPAT_H */

View File

@ -1450,8 +1450,7 @@ edit_free_syntax_rules (WEdit * edit)
MC_PTR_FREE (edit->rules[i]);
}
g_slist_foreach (edit->syntax_marker, (GFunc) g_free, NULL);
g_slist_free (edit->syntax_marker);
g_slist_free_full (edit->syntax_marker, g_free);
edit->syntax_marker = NULL;
MC_PTR_FREE (edit->rules);
tty_color_free_all_tmp ();

View File

@ -245,11 +245,10 @@ free_link (void *data)
/* --------------------------------------------------------------------------------------------- */
static void *
static inline void *
free_linklist (GSList * lp)
{
g_slist_foreach (lp, (GFunc) free_link, NULL);
g_slist_free (lp);
g_slist_free_full (lp, free_link);
return NULL;
}

View File

@ -394,8 +394,7 @@ end_link_area (int x, int y)
static void
clear_link_areas (void)
{
g_slist_foreach (link_area, (GFunc) g_free, NULL);
g_slist_free (link_area);
g_slist_free_full (link_area, g_free);
link_area = NULL;
inside_link_area = FALSE;
}

View File

@ -205,8 +205,7 @@ cpio_free_archive (struct vfs_class *me, struct vfs_s_super *super)
if (arch->fd != -1)
mc_close (arch->fd);
arch->fd = -1;
g_slist_foreach (arch->deferred, (GFunc) g_free, NULL);
g_slist_free (arch->deferred);
g_slist_free_full (arch->deferred, g_free);
arch->deferred = NULL;
g_free (super->data);
super->data = NULL;

View File

@ -2236,8 +2236,7 @@ ftpfs_done (struct vfs_class *me)
{
(void) me;
g_slist_foreach (no_proxy, (GFunc) g_free, NULL);
g_slist_free (no_proxy);
g_slist_free_full (no_proxy, g_free);
g_free (ftpfs_anonymous_passwd);
g_free (ftpfs_proxy_host);