From 268c33e1c6e7ee5a4a26299311289933c66460e2 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 9 Feb 2015 19:50:41 +0000 Subject: [PATCH 1/5] Free resource lists on /account command --- .gitignore | 2 +- src/ui/console.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 7f15f3c9..37449348 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ configure.scan stamp-h1 *~ *dirstamp -valgrind.out +valgrind*.out* core bugs/ TODO diff --git a/src/ui/console.c b/src/ui/console.c index cdf5d1b8..2c37c40c 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -717,20 +717,24 @@ cons_show_account(ProfAccount *account) GList *resources = jabber_get_available_resources(); GList *ordered_resources = NULL; - if (resources != NULL) { + GList *curr = resources; + if (curr != NULL) { win_save_println(console, "Resources:"); // sort in order of availabiltiy - while (resources != NULL) { - Resource *resource = resources->data; + while (curr != NULL) { + Resource *resource = curr->data; ordered_resources = g_list_insert_sorted(ordered_resources, resource, (GCompareFunc)resource_compare_availability); - resources = g_list_next(resources); + curr = g_list_next(curr); } } - while (ordered_resources != NULL) { - Resource *resource = ordered_resources->data; + g_list_free(resources); + + curr = ordered_resources; + while (curr != NULL) { + Resource *resource = curr->data; const char *resource_presence = string_from_resource_presence(resource->presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_save_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); @@ -785,8 +789,9 @@ cons_show_account(ProfAccount *account) caps_destroy(caps); } - ordered_resources = g_list_next(ordered_resources); + curr = g_list_next(curr); } + g_list_free(ordered_resources); } cons_alert(); From 23aaa51a2af836d705a49bde561d9b8431695499 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 9 Feb 2015 19:59:04 +0000 Subject: [PATCH 2/5] Free utf8 substrings for delete word (ctrl-w) --- src/ui/inputwin.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 85ddc79a..b2d5e420 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -747,6 +747,9 @@ _delete_previous_word(void) input_len_bytes = strlen(start_string)+i; input[input_len_bytes] = '\0'; + g_free(start_string); + g_free(end_string); + _clear_input(); waddstr(inp_win, input); wmove(inp_win, 0, start_del); From 893b58bf4e0f6329ac36caac4408aa1200912e30 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 9 Feb 2015 20:11:51 +0000 Subject: [PATCH 3/5] Use chat_state_free to free chat states --- src/ui/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/window.c b/src/ui/window.c index 54f1b99f..1cdf2f26 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -336,7 +336,7 @@ win_free(ProfWin* window) ProfChatWin *chatwin = (ProfChatWin*)window; free(chatwin->barejid); free(chatwin->resource_override); - free(chatwin->state); + chat_state_free(chatwin->state); } if (window->type == WIN_MUC) { From aad7b3ed8ac245252e8d400ee79205a196989a11 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 9 Feb 2015 20:15:24 +0000 Subject: [PATCH 4/5] Free GTimer on switch to console --- src/ui/titlebar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 326dbf8b..a3299946 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -109,8 +109,11 @@ void title_bar_console(void) { werase(win); - typing = FALSE; + if (typing_elapsed) { + g_timer_destroy(typing_elapsed); + } typing_elapsed = NULL; + typing = FALSE; _title_bar_draw(); } From 6682f243ce2cbb46a1323bcd5fdf3a672b5a5d00 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 9 Feb 2015 21:21:22 +0000 Subject: [PATCH 5/5] Free theme list after use --- src/command/command.c | 11 ++++++----- src/config/theme.c | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/command/command.c b/src/command/command.c index 9f17596b..f05d2a79 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1659,7 +1659,7 @@ cmd_reset_autocomplete() autocomplete_reset(autoconnect_ac); autocomplete_reset(theme_ac); if (theme_load_ac != NULL) { - autocomplete_reset(theme_load_ac); + autocomplete_free(theme_load_ac); theme_load_ac = NULL; } autocomplete_reset(account_ac); @@ -2473,11 +2473,12 @@ _theme_autocomplete(const char * const input) if (theme_load_ac == NULL) { theme_load_ac = autocomplete_new(); GSList *themes = theme_list(); - while (themes != NULL) { - autocomplete_add(theme_load_ac, themes->data); - themes = g_slist_next(themes); + GSList *curr = themes; + while (curr != NULL) { + autocomplete_add(theme_load_ac, curr->data); + curr = g_slist_next(curr); } - g_slist_free(themes); + g_slist_free_full(themes, g_free); autocomplete_add(theme_load_ac, "default"); } result = autocomplete_param_with_ac(input, "/theme set", theme_load_ac, TRUE); diff --git a/src/config/theme.c b/src/config/theme.c index a5dbd0dd..26d48091 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -192,7 +192,9 @@ GSList * theme_list(void) { GSList *result = NULL; - _theme_list_dir(_get_themes_dir(), &result); + char *themes_dir = _get_themes_dir(); + _theme_list_dir(themes_dir, &result); + free(themes_dir); #ifdef THEMES_PATH _theme_list_dir(THEMES_PATH, &result); #endif