From b3d49f2a3c48d9174e02341ce2f69ccd08a4c87c Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 21 May 2014 21:39:31 +0100 Subject: Added backwards compatible g_list_free_full for glib < 2.28 --- src/common.c | 7 +++++++ src/common.h | 2 ++ src/config/account.c | 1 + src/muc.c | 1 + tests/test_cmd_bookmark.c | 1 + 5 files changed, 12 insertions(+) diff --git a/src/common.c b/src/common.c index 4ad7f0bd..be2dd2bf 100644 --- a/src/common.c +++ b/src/common.c @@ -72,6 +72,13 @@ p_slist_free_full(GSList *items, GDestroyNotify free_func) g_slist_free (items); } +void +p_list_free_full(GList *items, GDestroyNotify free_func) +{ + g_list_foreach (items, (GFunc) free_func, NULL); + g_list_free (items); +} + gboolean create_dir(char *name) { diff --git a/src/common.h b/src/common.h index e6b0b267..48d6c97e 100644 --- a/src/common.h +++ b/src/common.h @@ -29,6 +29,7 @@ #if !GLIB_CHECK_VERSION(2,28,0) #define g_slist_free_full(items, free_func) p_slist_free_full(items, free_func) +#define g_list_free_full(items, free_func) p_list_free_full(items, free_func) #endif #if !GLIB_CHECK_VERSION(2,30,0) @@ -72,6 +73,7 @@ typedef enum { gchar* p_utf8_substring(const gchar *str, glong start_pos, glong end_pos); void p_slist_free_full(GSList *items, GDestroyNotify free_func); +void p_list_free_full(GList *items, GDestroyNotify free_func); gboolean create_dir(char *name); gboolean mkdir_recursive(const char *dir); char * str_replace(const char *string, const char *substr, diff --git a/src/config/account.c b/src/config/account.c index e019bf83..82e1a398 100644 --- a/src/config/account.c +++ b/src/config/account.c @@ -27,6 +27,7 @@ #include "jid.h" #include "config/account.h" +#include "common.h" ProfAccount* account_new(const gchar * const name, const gchar * const jid, diff --git a/src/muc.c b/src/muc.c index 369d19e1..3cf1f506 100644 --- a/src/muc.c +++ b/src/muc.c @@ -26,6 +26,7 @@ #include #include "contact.h" +#include "common.h" #include "jid.h" #include "tools/autocomplete.h" diff --git a/tests/test_cmd_bookmark.c b/tests/test_cmd_bookmark.c index 3a78ba5b..f576196c 100644 --- a/tests/test_cmd_bookmark.c +++ b/tests/test_cmd_bookmark.c @@ -12,6 +12,7 @@ #include "xmpp/mock_xmpp.h" #include "muc.h" +#include "common.h" #include "command/commands.h" -- cgit 1.4.1-2-gfad0