From: Daniel Carl Date: Mon, 4 Mar 2013 13:14:08 +0000 (+0100) Subject: Fixed some more memory leaks. X-Git-Url: https://git.owens.tech/assets/static/git-logo.png/assets/static/git-logo.png/git?a=commitdiff_plain;h=8a9caa082080a945ec30cb47df306a9d09f29cbb;p=vimb.git Fixed some more memory leaks. --- diff --git a/src/history.c b/src/history.c index 6ff9ee7..55c3a67 100644 --- a/src/history.c +++ b/src/history.c @@ -31,7 +31,9 @@ void history_append(const char* line) { if (COMMAND_HISTORY_SIZE <= g_list_length(core.behave.history)) { /* if list is too long - remove items from beginning */ - core.behave.history = g_list_delete_link(core.behave.history, g_list_first(core.behave.history)); + GList* first = g_list_first(core.behave.history); + g_free((char*)first->data); + core.behave.history = g_list_delete_link(core.behave.history, first); } core.behave.history = g_list_append(core.behave.history, g_strdup(line)); } diff --git a/src/keybind.c b/src/keybind.c index 0e75b1d..e232688 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -93,6 +93,7 @@ gboolean keybind_remove_from_string(char* str, const Mode mode) GSList* link = keybind_find(keybind.mode, keybind.modkey, keybind.modmask, keybind.keyval); if (link) { + keybind_free((Keybind*)link->data); core.behave.keys = g_slist_delete_link(core.behave.keys, link); } diff --git a/src/searchengine.c b/src/searchengine.c index dca7541..7d0fac7 100644 --- a/src/searchengine.c +++ b/src/searchengine.c @@ -53,10 +53,7 @@ gboolean searchengine_remove(const char* handle) GSList* list = searchengine_find(handle); if (list) { - Searchengine* s = (Searchengine*)list->data; - g_free(s->handle); - g_free(s->uri); - + searchengine_free((Searchengine*)list->data); core.behave.searchengines = g_slist_delete_link(core.behave.searchengines, list); return TRUE; diff --git a/src/url_history.c b/src/url_history.c index f0aba78..8ae771e 100644 --- a/src/url_history.c +++ b/src/url_history.c @@ -59,6 +59,7 @@ void url_history_cleanup(void) void url_history_add(const char* url, const char* title) { /* uf the url is already in history, remove this entry */ + /* TODO use g_list_find_custom for this task */ for (GList* link = core.behave.url_history; link; link = link->next) { UrlHist* hi = (UrlHist*)link->data; if (!g_strcmp0(url, hi->uri)) { @@ -70,10 +71,9 @@ void url_history_add(const char* url, const char* title) while (core.config.url_history_max < g_list_length(core.behave.url_history)) { /* if list is too long - remove items from end */ - core.behave.url_history = g_list_delete_link( - core.behave.url_history, - g_list_last(core.behave.url_history) - ); + GList* last = g_list_last(core.behave.url_history); + url_history_free((UrlHist*)last->data); + core.behave.url_history = g_list_delete_link(core.behave.url_history, last); } UrlHist* item = g_new0(UrlHist, 1);