From 68a7c1dfab778376c715fa6eb25d7eb68d8cdec5 Mon Sep 17 00:00:00 2001 From: "Andrew V. Samoilov" Date: Fri, 24 Sep 2004 22:22:35 +0000 Subject: [PATCH] * boxes.c (configure_vfs): g_free handles NULL argument too, no need for the comparison. * cmd.c (set_panel_filter_to): Likewise. (do_link): Likewise. (quick_cd_cmd): Likewise. * color.c (done_colors): Likewise. * dialog.c (destroy_dlg): Likewise. * dir.c (alloc_dir_copy): Likewise. * ext.c (flush_extension_file): Likewise. * file.c (copy_file_file): Likewise. (panel_operate): Likewise. * hotlist.c (remove_group): Likewise. (remove_from_hotlist): Likewise. (done_hotlist): Likewise. * main.c (main): Likewise. * setup.c (panel_load_setup): Likewise. * tree.c (tree_destroy): Likewise. (show_tree): Likewise. * user.c (user_menu_cmd): Likewise. * utilunix.c (i_cache_add): Likewise. (putenv): Likewise. * view.c (view_done): Likewise. (regexp_search): Likewise. (normal_search): Likewise. (change_viewer): Likewise. * widget.c (label_set_text): Likewise. (set_label_text): Likewise. --- src/ChangeLog | 30 ++++++++++++++++++++++++++++++ src/boxes.c | 3 +-- src/cmd.c | 17 +++++++---------- src/color.c | 6 ++---- src/dialog.c | 4 +--- src/dir.c | 3 +-- src/ext.c | 6 ++---- src/file.c | 20 ++++++-------------- src/hotlist.c | 28 ++++++++++------------------ src/main.c | 6 ++---- src/setup.c | 8 ++------ src/tree.c | 9 +++------ src/user.c | 3 +-- src/utilunix.c | 6 ++---- src/view.c | 12 ++++-------- src/widget.c | 8 +++----- 16 files changed, 77 insertions(+), 92 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index af92713ee..c3ebf3c19 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,33 @@ +2004-09-25 Pavel Shirshov + + * boxes.c (configure_vfs): g_free handles NULL argument too, + no need for the comparison. + * cmd.c (set_panel_filter_to): Likewise. + (do_link): Likewise. + (quick_cd_cmd): Likewise. + * color.c (done_colors): Likewise. + * dialog.c (destroy_dlg): Likewise. + * dir.c (alloc_dir_copy): Likewise. + * ext.c (flush_extension_file): Likewise. + * file.c (copy_file_file): Likewise. + (panel_operate): Likewise. + * hotlist.c (remove_group): Likewise. + (remove_from_hotlist): Likewise. + (done_hotlist): Likewise. + * main.c (main): Likewise. + * setup.c (panel_load_setup): Likewise. + * tree.c (tree_destroy): Likewise. + (show_tree): Likewise. + * user.c (user_menu_cmd): Likewise. + * utilunix.c (i_cache_add): Likewise. + (putenv): Likewise. + * view.c (view_done): Likewise. + (regexp_search): Likewise. + (normal_search): Likewise. + (change_viewer): Likewise. + * widget.c (label_set_text): Likewise. + (set_label_text): Likewise. + 2004-09-24 Roland Illig * file.c (progress_update_one): Changed parameter type from int diff --git a/src/boxes.c b/src/boxes.c index 93860d839..17838d02b 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -771,8 +771,7 @@ configure_vfs (void) #if defined(USE_NETCODE) g_free (ftpfs_anonymous_passwd); ftpfs_anonymous_passwd = ret_passwd; - if (ftpfs_proxy_host) - g_free (ftpfs_proxy_host); + g_free (ftpfs_proxy_host); ftpfs_proxy_host = ret_ftp_proxy; ftpfs_directory_timeout = atoi(ret_directory_timeout); use_netrc = ret_use_netrc; diff --git a/src/cmd.c b/src/cmd.c index 433c8b9eb..1be5b0671 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -405,10 +405,9 @@ void find_cmd (void) static void set_panel_filter_to (WPanel *p, char *allocated_filter_string) { - if (p->filter){ - g_free (p->filter); - p->filter = 0; - } + g_free (p->filter); + p->filter = 0; + if (!(allocated_filter_string [0] == '*' && allocated_filter_string [1] == 0)) p->filter = allocated_filter_string; else @@ -970,11 +969,10 @@ do_link (int symbolic_link, const char *fname) } update_panels (UP_OPTIMIZE, UP_KEEPSEL); repaint_screen (); + cleanup: - if (src != NULL) - g_free (src); - if (dest != NULL) - g_free (dest); + g_free (src); + g_free (dest); } void link_cmd (void) @@ -1205,8 +1203,7 @@ void quick_cd_cmd (void) do_cd_command (q); g_free (q); } - if (p) - g_free (p); + g_free (p); } void diff --git a/src/color.c b/src/color.c index 76016576e..921b8ae78 100644 --- a/src/color.c +++ b/src/color.c @@ -458,10 +458,8 @@ done_colors (void) for (p = c.next; p; p = next) { next = p->next; - if (p->fg) - g_free (p->fg); - if (p->bg) - g_free (p->bg); + g_free (p->fg); + g_free (p->bg); g_free (p); } c.next = NULL; diff --git a/src/dialog.c b/src/dialog.c index 47e6b6a26..b14b7e05a 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -804,9 +804,7 @@ destroy_dlg (Dlg_head *h) c = h->current; for (i = 0; i < h->count; i++) { c = c->next; - if (h->current) { - g_free (h->current); - } + g_free (h->current); h->current = c; } g_free (h->title); diff --git a/src/dir.c b/src/dir.c index 802938dff..332c46199 100644 --- a/src/dir.c +++ b/src/dir.c @@ -544,8 +544,7 @@ alloc_dir_copy (int size) if (dir_copy.list){ for (i = 0; i < dir_copy.size; i++) { - if (dir_copy.list [i].fname) - g_free (dir_copy.list [i].fname); + g_free (dir_copy.list [i].fname); } g_free (dir_copy.list); dir_copy.list = 0; diff --git a/src/ext.c b/src/ext.c index 718ed7c22..0ea4f37d4 100644 --- a/src/ext.c +++ b/src/ext.c @@ -52,10 +52,8 @@ static char *data = NULL; void flush_extension_file (void) { - if (data) { - g_free (data); - data = NULL; - } + g_free (data); + data = NULL; } typedef char *(*quote_func_t) (const char *name, int quote_percent); diff --git a/src/file.c b/src/file.c index 5835b993d..36ce5b36e 100644 --- a/src/file.c +++ b/src/file.c @@ -774,8 +774,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path, dst_status = DEST_FULL; /* copy successful, don't remove target file */ ret: - if (buf) - g_free (buf); + g_free (buf); while (src_desc != -1 && mc_close (src_desc) < 0) { temp_status = @@ -2011,8 +2010,7 @@ panel_operate (void *source_panel, FileOperation operation, src_stat = panel->dir.list[i].st; #ifdef WITH_FULL_PATHS - if (source_with_path) - g_free (source_with_path); + g_free (source_with_path); source_with_path = concat_dir_and_file (panel->cwd, source); #endif /* WITH_FULL_PATHS */ @@ -2106,17 +2104,11 @@ panel_operate (void *source_panel, FileOperation operation, free_linklist (&linklist); free_linklist (&dest_dirs); #ifdef WITH_FULL_PATHS - if (source_with_path) - g_free (source_with_path); + g_free (source_with_path); #endif /* WITH_FULL_PATHS */ - - if (dest) - g_free (dest); - - if (ctx->dest_mask) { - g_free (ctx->dest_mask); - ctx->dest_mask = NULL; - } + g_free (dest); + g_free (ctx->dest_mask); + ctx->dest_mask = NULL; #ifdef WITH_BACKGROUND /* Let our parent know we are saying bye bye */ if (we_are_background) { diff --git a/src/hotlist.c b/src/hotlist.c index 6c12e852d..132edf7c8 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -1025,11 +1025,9 @@ static void remove_group (struct hotlist *grp) if (current->type == HL_TYPE_GROUP) remove_group (current); - if (current->label) - g_free (current->label); - if (current->directory) - g_free (current->directory); - g_free (current); + g_free (current->label); + g_free (current->directory); + g_free (current); current = next; } @@ -1061,10 +1059,8 @@ static void remove_from_hotlist (struct hotlist *entry) unlink_entry (entry); - if (entry->label) - g_free (entry->label); - if (entry->directory) - g_free (entry->directory); + g_free (entry->label); + g_free (entry->directory); g_free (entry); /* now remove list entry from screen */ listbox_remove_current (l_hotlist, 1); @@ -1564,20 +1560,16 @@ void done_hotlist (void) { if (hotlist){ remove_group (hotlist); - if (hotlist->label) - g_free (hotlist->label); - if (hotlist->directory) - g_free (hotlist->directory); - g_free (hotlist); + g_free (hotlist->label); + g_free (hotlist->directory); + g_free (hotlist); hotlist = 0; } hotlist_state.loaded = 0; - if (hotlist_file_name){ - g_free (hotlist_file_name); - hotlist_file_name = 0; - } + g_free (hotlist_file_name); + hotlist_file_name = 0; l_hotlist = 0; current_group = 0; if (tkn_buf){ diff --git a/src/main.c b/src/main.c index dd454f992..2eadd8fbe 100644 --- a/src/main.c +++ b/src/main.c @@ -2286,10 +2286,8 @@ main (int argc, char *argv[]) #ifdef HAVE_CHARSET free_codepages_list (); #endif - if (this_dir) - g_free (this_dir); - if (other_dir) - g_free (other_dir); + g_free (this_dir); + g_free (other_dir); return 0; } diff --git a/src/setup.c b/src/setup.c index 013b4e39a..e467cb6d4 100644 --- a/src/setup.c +++ b/src/setup.c @@ -386,16 +386,12 @@ panel_load_setup (WPanel *panel, const char *section) } /* User formats */ - if (panel->user_format){ - g_free (panel->user_format); - panel->user_format = 0; - } + g_free (panel->user_format); panel->user_format = g_strdup (get_profile_string (section, "user_format", DEFAULT_USER_FORMAT, profile_name)); for (i = 0; i < LIST_TYPES; i++){ - if (panel->user_status_format [i]) - g_free (panel->user_status_format [i]); + g_free (panel->user_status_format [i]); g_snprintf (buffer, sizeof (buffer), "user_status%d", i); panel->user_status_format [i] = g_strdup (get_profile_string (section, buffer, diff --git a/src/tree.c b/src/tree.c index a6d0dc1ff..5d49895d4 100644 --- a/src/tree.c +++ b/src/tree.c @@ -120,10 +120,8 @@ static void tree_destroy (WTree *tree) tree_store_remove_entry_remove_hook (remove_callback); save_tree (tree); - if (tree->tree_shown){ - g_free (tree->tree_shown); - tree->tree_shown = 0; - } + g_free (tree->tree_shown); + tree->tree_shown = 0; tree->selected_ptr = NULL; } @@ -202,8 +200,7 @@ static void show_tree (WTree *tree) x = y = 1; } - if (tree->tree_shown) - g_free (tree->tree_shown); + g_free (tree->tree_shown); tree->tree_shown = g_new (tree_entry*, tree_lines); for (i = 0; i < tree_lines; i++) diff --git a/src/user.c b/src/user.c index f55712c86..f8565140b 100644 --- a/src/user.c +++ b/src/user.c @@ -809,8 +809,7 @@ user_menu_cmd (struct WEdit *edit_widget) easy_patterns = old_patterns; g_free (menu); menu = NULL; - if (entries) - g_free (entries); + g_free (entries); g_free (data); } diff --git a/src/utilunix.c b/src/utilunix.c index 5b2f39db1..baf728e5e 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -150,8 +150,7 @@ static char *i_cache_match (int id, int_cache *cache, int size) static void i_cache_add (int id, int_cache *cache, int size, char *text, int *last) { - if (cache [*last].string) - g_free (cache [*last].string); + g_free (cache [*last].string); cache [*last].string = g_strdup (text); cache [*last].index = id; *last = ((*last)+1) % size; @@ -653,8 +652,7 @@ putenv (char *string) size * sizeof (char *)); new_environ[size] = (char *) string; new_environ[size + 1] = NULL; - if (last_environ != NULL) - g_free ((void *) last_environ); + g_free ((void *) last_environ); last_environ = new_environ; __environ = new_environ; } diff --git a/src/view.c b/src/view.c index 3e6505934..3cffb65c1 100644 --- a/src/view.c +++ b/src/view.c @@ -269,8 +269,7 @@ view_done (WView *view) if (view->view_active) { free_file (view); g_free (view->filename); - if (view->command) - g_free (view->command); + g_free (view->command); } view->view_active = 0; default_hex_mode = view->hex_mode; @@ -2107,8 +2106,7 @@ regexp_search (WView *view, int direction) g_free (regexp); return; } - if (old) - g_free (old); + g_free (old); old = regexp; #if 0 /* Mhm, do we really need to load all the file in the core? */ @@ -2184,8 +2182,7 @@ normal_search (WView *view, int direction) return; } - if (old) - g_free (old); + g_free (old); old = exp; convert_from_input (exp); @@ -2220,8 +2217,7 @@ change_viewer (WView *view) view_done (view); view_init (view, t, s, 0); g_free (s); - if (t) - g_free (t); + g_free (t); view_labels (view); view->dirty++; view_update (view, TRUE); diff --git a/src/widget.c b/src/widget.c index 6876075f2..8d23a4d49 100644 --- a/src/widget.c +++ b/src/widget.c @@ -555,9 +555,8 @@ label_set_text (WLabel *label, const char *text) if (label->text && text && !strcmp (label->text, text)) return; /* Flickering is not nice */ - if (label->text){ - g_free (label->text); - } + g_free (label->text); + if (text){ label->text = g_strdup (text); if (label->auto_adjust_cols) { @@ -2304,8 +2303,7 @@ buttonbar_new (int visible) static void set_label_text (WButtonBar * bb, int index, const char *text) { - if (bb->labels[index - 1].text) - g_free (bb->labels[index - 1].text); + g_free (bb->labels[index - 1].text); bb->labels[index - 1].text = g_strdup (text); }