# HG changeset patch # User Sadrul Habib Chowdhury # Date 1186824036 0 # Node ID 8988a205112b771e20d1cb1b374a858d9ee255eb # Parent e4a4d7ab4bf01af9c8ade616ca9a2d59d501740e Fix a memory leak from not freeing the ui-info hashtable on exit. diff -r e4a4d7ab4bf0 -r 8988a205112b finch/finch.c --- a/finch/finch.c Sat Aug 11 08:55:32 2007 +0000 +++ b/finch/finch.c Sat Aug 11 09:20:36 2007 +0000 @@ -55,16 +55,10 @@ purple_debug_set_ui_ops(finch_debug_get_ui_ops()); } -/* XXX: this "leaks" a hashtable on shutdown. I'll let - * the finch guys decide if they want to go through the trouble - * of properly freeing it, since their quit function doesn't - * live in this file */ - static GHashTable *ui_info = NULL; - static GHashTable *finch_ui_get_info() { - if(NULL == ui_info) { + if (ui_info == NULL) { ui_info = g_hash_table_new(g_str_hash, g_str_equal); g_hash_table_insert(ui_info, "name", (char*)_("Finch")); @@ -74,12 +68,20 @@ return ui_info; } +static void +finch_quit(void) +{ + gnt_ui_uninit(); + if (ui_info) + g_hash_table_destroy(ui_info); +} + static PurpleCoreUiOps core_ops = { finch_prefs_init, debug_init, gnt_ui_init, - gnt_ui_uninit, + finch_quit, finch_ui_get_info, /* padding */ @@ -396,7 +398,17 @@ return 1; } -int main(int argc, char **argv) +static gboolean gnt_start(int *argc, char ***argv) +{ + /* Initialize the libpurple stuff */ + if (!init_libpurple(*argc, *argv)) + return FALSE; + + purple_blist_show(); + return TRUE; +} + +int main(int argc, char *argv[]) { signal(SIGPIPE, SIG_IGN); @@ -405,11 +417,10 @@ g_set_application_name(_("Finch")); #endif - /* Initialize the libpurple stuff */ - if (!init_libpurple(argc, argv)) - return 0; - - purple_blist_show(); + gnt_init(); + + gnt_start(&argc, &argv); + gnt_main(); #ifdef STANDALONE