From e71d68daeec26f239f6c81eb5de1162cc8bd4f6f Mon Sep 17 00:00:00 2001
From: Vit Rosin <vit_r@list.ru>
Date: Mon, 1 Mar 2010 20:37:03 +0000
Subject: [PATCH] UN needed extern profile_name in src/setup.c
'char * setup_init (void);' with allocated 'return (char *) profile_name;'
is called from
src/treestore.c:757:
{{{
loaded = 1;
setup_init();
}}}
without even possible g_free ....
---
src/setup.c | 68 +++++++++++++++++++++++++++---------------------------
src/setup.h | 1 -
src/treestore.c | 7 ++++-
3 files changed, 39 insertions(+), 37 deletions(-)
diff --git a/src/setup.c b/src/setup.c
index 78dfb1b..ed4b8c5 100644
a
|
b
|
|
75 | 75 | |
76 | 76 | extern int num_history_items_recorded; |
77 | 77 | |
78 | | char *profile_name; /* .mc/ini */ |
79 | 78 | char *global_profile_name; /* mc.lib */ |
80 | 79 | |
81 | 80 | char *setup_color_string; |
… |
… |
load_setup_get_keymap_profile_config (void) |
727 | 726 | char * |
728 | 727 | setup_init (void) |
729 | 728 | { |
730 | | char *profile; |
731 | | char *inifile; |
| 729 | static char *profile_name = NULL; |
| 730 | char *tmp; |
732 | 731 | |
733 | | if (profile_name) |
734 | | return profile_name; |
| 732 | if (profile_name != NULL) |
| 733 | return (tmp = g_strdup (profile_name)); |
| 734 | |
735 | 735 | |
736 | | profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_CONFIG_FILE, NULL); |
737 | | if (!exist_file (profile)) |
738 | | { |
739 | | inifile = concat_dir_and_file (mc_home, "mc.ini"); |
740 | | if (exist_file (inifile)) |
741 | | { |
742 | | g_free (profile); |
743 | | profile = inifile; |
744 | | } |
745 | | else |
746 | | { |
747 | | g_free (inifile); |
748 | | inifile = concat_dir_and_file (mc_home_alt, "mc.ini"); |
749 | | if (exist_file (inifile)) |
750 | | { |
751 | | g_free (profile); |
752 | | profile = inifile; |
753 | | } |
754 | | else |
755 | | g_free (inifile); |
756 | | } |
757 | | } |
| 736 | tmp = g_build_filename (home_dir, MC_USERCONF_DIR, MC_CONFIG_FILE, NULL); |
| 737 | if (tmp == NULL) |
| 738 | return NULL; |
| 739 | |
| 740 | if (exist_file (tmp)) |
| 741 | return tmp; |
| 742 | |
| 743 | g_free (tmp); |
| 744 | tmp = concat_dir_and_file (mc_home, "mc.ini"); |
| 745 | if (tmp == NULL) |
| 746 | return NULL; |
| 747 | |
| 748 | if (exist_file (tmp)) |
| 749 | return tmp; |
| 750 | |
| 751 | g_free (tmp); |
| 752 | tmp = concat_dir_and_file (mc_home_alt, "mc.ini"); |
| 753 | if (tmp == NULL) |
| 754 | return NULL; |
758 | 755 | |
759 | | profile_name = profile; |
| 756 | if (exist_file (tmp)) |
| 757 | return tmp; |
760 | 758 | |
761 | | return profile; |
| 759 | g_free (tmp); |
| 760 | return NULL; |
762 | 761 | } |
763 | 762 | |
764 | 763 | void |
765 | 764 | load_setup (void) |
766 | 765 | { |
767 | | char *profile; |
| 766 | char *profile_name; |
768 | 767 | int i; |
769 | 768 | char *buffer; |
770 | 769 | |
771 | | profile = setup_init (); |
| 770 | profile_name = setup_init (); |
772 | 771 | |
773 | 772 | /* mc.lib is common for all users, but has priority lower than |
774 | 773 | ~/.mc/ini. FIXME: it's only used for keys and treestore now */ |
… |
… |
load_setup (void) |
781 | 780 | |
782 | 781 | panels_profile_name = g_build_filename (home_dir, MC_USERCONF_DIR, MC_PANELS_FILE, NULL); |
783 | 782 | |
784 | | mc_main_config = mc_config_init (profile); |
| 783 | mc_main_config = mc_config_init (profile_name); |
785 | 784 | |
786 | 785 | if (!exist_file (panels_profile_name)) |
787 | | setup__move_panels_config_into_separate_file (profile); |
| 786 | setup__move_panels_config_into_separate_file (profile_name); |
| 787 | |
| 788 | g_free (profile_name); |
788 | 789 | |
789 | 790 | mc_panels_config = mc_config_init (panels_profile_name); |
790 | 791 | |
… |
… |
done_setup (void) |
893 | 894 | { |
894 | 895 | int i; |
895 | 896 | |
896 | | g_free (profile_name); |
897 | 897 | g_free (global_profile_name); |
898 | 898 | g_free (color_terminal_string); |
899 | 899 | g_free (term_color_string); |
diff --git a/src/setup.h b/src/setup.h
index 04d66d8..bf9e41e 100644
a
|
b
|
void panel_load_setup (struct WPanel *panel, const char *section); |
22 | 22 | void save_panel_types (void); |
23 | 23 | void load_keymap_defs (void); |
24 | 24 | void free_keymap_defs (void); |
25 | | extern char *profile_name; |
26 | 25 | extern char *global_profile_name; |
27 | 26 | |
28 | 27 | extern char *setup_color_string; |
diff --git a/src/treestore.c b/src/treestore.c
index 2d2c4d6..7419a4f 100644
a
|
b
|
should_skip_directory(const char *dir) |
753 | 753 | static int loaded; |
754 | 754 | |
755 | 755 | if (loaded == 0) { |
756 | | loaded = 1; |
757 | | setup_init(); |
| 756 | char *profile_name; |
| 757 | |
| 758 | profile_name = setup_init(); |
758 | 759 | process_special_dirs(&special_dirs, profile_name); |
| 760 | g_free (profile_name); |
759 | 761 | process_special_dirs(&special_dirs, global_profile_name); |
| 762 | loaded = 1; |
760 | 763 | } |
761 | 764 | |
762 | 765 | for (l = special_dirs; l; l = l->next) { |