From 91a4598b546851967b85850e3b29239cae0f15bd Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 29 Oct 2009 22:04:44 +0300 Subject: [PATCH] Ticket #1755: code cleanup before 4.7.0-pre4 release. Free some variables allocated at MC startup. Signed-off-by: Andrew Borodin --- src/main.c | 2 ++ src/setup.c | 38 +++++++++++++++++++++++++++++++------- src/setup.h | 1 + src/strutil.c | 3 ++- vfs/vfs.c | 2 +- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index 511e494e1..b231aba8f 100644 --- a/src/main.c +++ b/src/main.c @@ -2236,6 +2236,8 @@ main (int argc, char *argv[]) /* Save the tree store */ tree_store_save (); + free_keymap_defs (); + /* Virtual File System shutdown */ vfs_shut (); diff --git a/src/setup.c b/src/setup.c index 66d3457e3..adea57c39 100644 --- a/src/setup.c +++ b/src/setup.c @@ -78,7 +78,6 @@ extern int num_history_items_recorded; char *profile_name; /* .mc/ini */ char *global_profile_name; /* mc.lib */ -char *panels_profile_name; /* .mc/panels.ini */ char *setup_color_string; char *term_color_string; @@ -92,6 +91,8 @@ int startup_right_mode; int saving_setup; int setup_copymove_persistent_attr = 1; +static char *panels_profile_name = NULL; /* .mc/panels.ini */ + static const struct { const char *key; int list_type; @@ -834,15 +835,23 @@ load_anon_passwd () } #endif /* USE_VFS && USE_NETCODE */ -void done_setup (void) +void +done_setup (void) { + int i; + g_free (profile_name); g_free (global_profile_name); - g_free(color_terminal_string); - g_free(term_color_string); - g_free(setup_color_string); - mc_config_deinit(mc_main_config); - mc_config_deinit(mc_panels_config); + g_free (color_terminal_string); + g_free (term_color_string); + g_free (setup_color_string); + g_free (panels_profile_name); + mc_config_deinit (mc_main_config); + mc_config_deinit (mc_panels_config); + + for (i = 0; str_options[i].opt_name != NULL; i++) + g_free (*str_options[i].opt_addr); + done_hotlist (); done_panelize (); /* directory_history_free (); */ @@ -1001,6 +1010,21 @@ load_keymap_defs (void) } } +void +free_keymap_defs (void) +{ +#ifdef USE_INTERNAL_EDIT + g_array_free (editor_keymap, TRUE); + g_array_free (editor_x_keymap, TRUE); +#endif + g_array_free (viewer_keymap, TRUE); + g_array_free (viewer_hex_keymap, TRUE); + g_array_free (main_keymap, TRUE); + g_array_free (main_x_keymap, TRUE); + g_array_free (panel_keymap, TRUE); + g_array_free (input_keymap, TRUE); +} + void setup_save_config_show_error(const char *filename, GError **error) { diff --git a/src/setup.h b/src/setup.h index 7716c459a..8d1e8dd2c 100644 --- a/src/setup.h +++ b/src/setup.h @@ -21,6 +21,7 @@ void panel_save_setup (struct WPanel *panel, const char *section); void panel_load_setup (struct WPanel *panel, const char *section); void save_panel_types (void); void load_keymap_defs (void); +void free_keymap_defs (void); extern char *profile_name; extern char *global_profile_name; diff --git a/src/strutil.c b/src/strutil.c index dfd5fd630..51d92edbb 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -61,7 +61,7 @@ static const char *str_8bit_encodings[] = { }; /* terminal encoding*/ -static char *codeset; +static char *codeset = NULL; /* function for encoding specific operations*/ static struct str_class used_class; @@ -405,6 +405,7 @@ void str_uninit_strings () { g_iconv_close (str_cnv_not_convert); + g_free (codeset); } const char * diff --git a/vfs/vfs.c b/vfs/vfs.c index 28633abff..7c1de542a 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -1300,8 +1300,8 @@ vfs_shut (void) (*vfs->done) (vfs); g_ptr_array_free (vfs_openfiles, TRUE); - g_string_free (vfs_str_buffer, TRUE); + g_free (mc_readdir_result); } /*