From 0a42be57a31882d000437cc10729c360f3482ae0 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 31 Jul 2012 23:01:15 +0100 Subject: [PATCH] Cleaning up memory allocated by ncurses pads --- .gitignore | 1 + runvalgrind.sh | 3 +++ src/preferences.c | 6 ++++++ src/preferences.h | 1 + src/profanity.c | 3 ++- src/windows.c | 7 +++++++ 6 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 runvalgrind.sh diff --git a/.gitignore b/.gitignore index e27dfb93..cbf66597 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ configure.scan stamp-h1 *~ *dirstamp +valgrind.out diff --git a/runvalgrind.sh b/runvalgrind.sh new file mode 100755 index 00000000..b57e45e4 --- /dev/null +++ b/runvalgrind.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -f valgrind.out +valgrind --log-file=valgrind.out --leak-check=full --track-origins=yes --show-reachable=yes ./profanity diff --git a/src/preferences.c b/src/preferences.c index 6cd7ac78..bcd749ce 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -96,6 +96,12 @@ prefs_load(void) _load_colours(); } +void +prefs_close(void) +{ + g_key_file_free(prefs); +} + static NCURSES_COLOR_T _lookup_colour(const char * const colour) { diff --git a/src/preferences.h b/src/preferences.h index dd3b7916..160d9d9d 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -26,6 +26,7 @@ #include void prefs_load(void); +void prefs_close(void); char * find_login(char *prefix); void reset_login_search(void); diff --git a/src/profanity.c b/src/profanity.c index 440f3b33..4a17f68c 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -79,7 +79,7 @@ profanity_init(const int disable_tls) jabber_init(disable_tls); command_init(); contact_list_init(); - tinyurl_init(); +// tinyurl_init(); atexit(_profanity_shutdown); } @@ -90,4 +90,5 @@ _profanity_shutdown(void) gui_close(); log_close(); chat_log_close(); + prefs_close(); } diff --git a/src/windows.c b/src/windows.c index 6fc62ebe..68d4b053 100644 --- a/src/windows.c +++ b/src/windows.c @@ -125,6 +125,13 @@ gui_refresh(void) void gui_close(void) { + int i; + for (i = 0; i < NUM_WINS; i++) { + if (_wins[i].win != NULL) { + delwin(_wins[i].win); + } + } + endwin(); }