Ticket #2071: 2071-UN-needed-extern-profile_name-in-src-setup.c.patch

File 2071-UN-needed-extern-profile_name-in-src-setup.c.patch, 4.3 KB (added by vit_r, 15 years ago)

UN-needed-extern-profile_name-in-src-seup.c

  • src/setup.c

    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  
    7575 
    7676extern int num_history_items_recorded; 
    7777 
    78 char *profile_name;             /* .mc/ini */ 
    7978char *global_profile_name;      /* mc.lib */ 
    8079 
    8180char *setup_color_string; 
    load_setup_get_keymap_profile_config (void) 
    727726char * 
    728727setup_init (void) 
    729728{ 
    730     char *profile; 
    731     char *inifile; 
     729    static char *profile_name = NULL; 
     730    char *tmp; 
    732731 
    733     if (profile_name) 
    734         return profile_name; 
     732    if (profile_name != NULL)  
     733        return (tmp = g_strdup (profile_name)); 
     734         
    735735 
    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; 
    758755 
    759     profile_name = profile; 
     756    if (exist_file (tmp)) 
     757        return tmp; 
    760758 
    761     return profile; 
     759    g_free (tmp); 
     760    return NULL; 
    762761} 
    763762 
    764763void 
    765764load_setup (void) 
    766765{ 
    767     char *profile; 
     766    char *profile_name; 
    768767    int i; 
    769768    char *buffer; 
    770769 
    771     profile = setup_init (); 
     770    profile_name = setup_init (); 
    772771 
    773772    /* mc.lib is common for all users, but has priority lower than 
    774773       ~/.mc/ini.  FIXME: it's only used for keys and treestore now */ 
    load_setup (void) 
    781780 
    782781    panels_profile_name = g_build_filename (home_dir, MC_USERCONF_DIR, MC_PANELS_FILE, NULL); 
    783782 
    784     mc_main_config = mc_config_init (profile); 
     783    mc_main_config = mc_config_init (profile_name); 
    785784 
    786785    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); 
    788789 
    789790    mc_panels_config = mc_config_init (panels_profile_name); 
    790791 
    done_setup (void) 
    893894{ 
    894895    int i; 
    895896 
    896     g_free (profile_name); 
    897897    g_free (global_profile_name); 
    898898    g_free (color_terminal_string); 
    899899    g_free (term_color_string); 
  • src/setup.h

    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); 
    2222void save_panel_types (void); 
    2323void load_keymap_defs (void); 
    2424void free_keymap_defs (void); 
    25 extern char *profile_name; 
    2625extern char *global_profile_name; 
    2726 
    2827extern char *setup_color_string; 
  • src/treestore.c

    diff --git a/src/treestore.c b/src/treestore.c
    index 2d2c4d6..7419a4f 100644
    a b should_skip_directory(const char *dir) 
    753753    static int loaded; 
    754754 
    755755    if (loaded == 0) { 
    756         loaded = 1; 
    757         setup_init(); 
     756        char *profile_name; 
     757         
     758        profile_name = setup_init(); 
    758759        process_special_dirs(&special_dirs, profile_name); 
     760        g_free (profile_name); 
    759761        process_special_dirs(&special_dirs, global_profile_name); 
     762        loaded = 1; 
    760763    } 
    761764 
    762765    for (l = special_dirs; l; l = l->next) {