From 5c645c7781143aab05c2713dd8016fb85936e9a5 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sat, 23 Feb 2013 11:31:53 +0100 Subject: [PATCH] Fixed missed freeing of list items. --- src/completion.c | 5 +---- src/history.c | 2 +- src/keybind.c | 10 +++++++++- src/searchengine.c | 10 +++++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/completion.c b/src/completion.c index 62ea0f0..39ba98b 100644 --- a/src/completion.c +++ b/src/completion.c @@ -78,10 +78,7 @@ gboolean completion_complete(gboolean back) void completion_clean(void) { - for (GList *l = vp.comps.completions; l; l = l->next) { - g_free(l->data); - } - g_list_free(vp.comps.completions); + g_list_free_full(vp.comps.completions, (GDestroyNotify)g_free); if (vp.gui.compbox) { gtk_widget_destroy(vp.gui.compbox); diff --git a/src/history.c b/src/history.c index 8c6494c..7e5f4d4 100644 --- a/src/history.c +++ b/src/history.c @@ -24,7 +24,7 @@ extern const int COMMAND_HISTORY_SIZE; void history_cleanup(void) { - g_list_free(vp.state.history); + g_list_free_full(vp.state.history, (GDestroyNotify)g_free); } void history_append(const char* line) diff --git a/src/keybind.c b/src/keybind.c index c4fa3c7..c71ccc0 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -28,6 +28,7 @@ static void keybind_str_to_keybind(char* str, Keybind* key); static guint keybind_str_to_modmask(const char* str); static guint keybind_str_to_value(const char* str); static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* event); +static void keybind_free(Keybind* keybind); void keybind_init(void) @@ -39,7 +40,7 @@ void keybind_init(void) void keybind_cleanup(void) { if (vp.behave.keys) { - g_slist_free(vp.behave.keys); + g_slist_free_full(vp.behave.keys, (GDestroyNotify)keybind_free); } if (vp.behave.modkeys) { g_string_free(vp.behave.modkeys, TRUE); @@ -263,3 +264,10 @@ static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* e return FALSE; } + +static void keybind_free(Keybind* keybind) +{ + g_free(keybind->command); + g_free(keybind->param); + g_free(keybind); +} diff --git a/src/searchengine.c b/src/searchengine.c index a0d73f8..195146b 100644 --- a/src/searchengine.c +++ b/src/searchengine.c @@ -22,12 +22,13 @@ static GSList* searchengine_find(const char* handle); static gboolean searchengine_is_valid_uri(const char* uri); +static void searchengine_free(Searchengine* se); void searchengine_cleanup(void) { if (vp.behave.searchengines) { - g_slist_free(vp.behave.searchengines); + g_slist_free_full(vp.behave.searchengines, (GDestroyNotify)searchengine_free); } } @@ -102,3 +103,10 @@ static gboolean searchengine_is_valid_uri(const char* uri) return count == 1; } + +static void searchengine_free(Searchengine* se) +{ + g_free(se->uri); + g_free(se->handle); + g_free(se); +} -- 2.20.1