Fixed some more memory leaks.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 4 Mar 2013 13:14:08 +0000 (14:14 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 4 Mar 2013 13:14:08 +0000 (14:14 +0100)
src/history.c
src/keybind.c
src/searchengine.c
src/url_history.c

index 6ff9ee7..55c3a67 100644 (file)
@@ -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));
 }
index 0e75b1d..e232688 100644 (file)
@@ -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);
     }
 
index dca7541..7d0fac7 100644 (file)
@@ -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;
index f0aba78..8ae771e 100644 (file)
@@ -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);