Massive use of MC_PTR_FREE macro.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2014-08-05 11:18:30 +04:00
parent de026dd1fc
commit 6d82155270
35 changed files with 85 additions and 182 deletions

View File

@ -104,8 +104,7 @@ mc_fhl_free (mc_fhl_t ** fhl)
mc_fhl_clear (*fhl); mc_fhl_clear (*fhl);
g_free (*fhl); MC_PTR_FREE (*fhl);
*fhl = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -168,10 +168,8 @@ mc_config_init_one_config_path (const char *path_base, const char *subdir, GErro
mc_config_mkdir (full_path, mcerror); mc_config_mkdir (full_path, mcerror);
if (mcerror != NULL && *mcerror != NULL) if (mcerror != NULL && *mcerror != NULL)
{ MC_PTR_FREE (full_path);
g_free (full_path);
full_path = NULL;
}
return full_path; return full_path;
} }

View File

@ -33,6 +33,7 @@
#include "lib/global.h" #include "lib/global.h"
#include "lib/strutil.h" #include "lib/strutil.h"
#include "lib/search.h" #include "lib/search.h"
#include "lib/util.h"
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
#include "lib/charsets.h" #include "lib/charsets.h"
#endif #endif
@ -273,8 +274,7 @@ mc_search_run (mc_search_t * lc_mc_search, const void *user_data,
#endif /* SEARCH_TYPE_GLIB */ #endif /* SEARCH_TYPE_GLIB */
lc_mc_search->error = MC_SEARCH_E_OK; lc_mc_search->error = MC_SEARCH_E_OK;
g_free (lc_mc_search->error_str); MC_PTR_FREE (lc_mc_search->error_str);
lc_mc_search->error_str = NULL;
if ((lc_mc_search->conditions == NULL) && !mc_search_prepare (lc_mc_search)) if ((lc_mc_search->conditions == NULL) && !mc_search_prepare (lc_mc_search))
return FALSE; return FALSE;

View File

@ -168,13 +168,11 @@ mc_skin_deinit (void)
tty_color_free_all_tmp (); tty_color_free_all_tmp ();
tty_color_free_all_non_tmp (); tty_color_free_all_non_tmp ();
g_free (mc_skin__default.name); MC_PTR_FREE (mc_skin__default.name);
mc_skin__default.name = NULL;
g_hash_table_destroy (mc_skin__default.colors); g_hash_table_destroy (mc_skin__default.colors);
mc_skin__default.colors = NULL; mc_skin__default.colors = NULL;
g_free (mc_skin__default.description); MC_PTR_FREE (mc_skin__default.description);
mc_skin__default.description = NULL;
mc_config_deinit (mc_skin__default.config); mc_config_deinit (mc_skin__default.config);
mc_skin__default.config = NULL; mc_skin__default.config = NULL;

View File

@ -135,8 +135,7 @@ resolve_symlinks (const vfs_path_t * vpath)
*q = 0; *q = 0;
if (mc_lstat (vpath, &mybuf) < 0) if (mc_lstat (vpath, &mybuf) < 0)
{ {
g_free (buf); MC_PTR_FREE (buf);
buf = NULL;
goto ret; goto ret;
} }
if (!S_ISLNK (mybuf.st_mode)) if (!S_ISLNK (mybuf.st_mode))
@ -148,8 +147,7 @@ resolve_symlinks (const vfs_path_t * vpath)
len = mc_readlink (vpath, buf2, MC_MAXPATHLEN - 1); len = mc_readlink (vpath, buf2, MC_MAXPATHLEN - 1);
if (len < 0) if (len < 0)
{ {
g_free (buf); MC_PTR_FREE (buf);
buf = NULL;
goto ret; goto ret;
} }
buf2[len] = 0; buf2[len] = 0;

View File

@ -963,8 +963,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent)
if (ent->dir != NULL) if (ent->dir != NULL)
ent->dir->subdir = g_list_remove (ent->dir->subdir, ent); ent->dir->subdir = g_list_remove (ent->dir->subdir, ent);
g_free (ent->name); MC_PTR_FREE (ent->name);
/* ent->name = NULL; */
if (ent->ino != NULL) if (ent->ino != NULL)
{ {
@ -1405,8 +1404,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
close (handle); close (handle);
unlink (ino->localname); unlink (ino->localname);
error_4: error_4:
g_free (ino->localname); MC_PTR_FREE (ino->localname);
ino->localname = NULL;
g_free (fh.data); g_free (fh.data);
return -1; return -1;
} }

View File

@ -39,6 +39,7 @@
#include "lib/tty/tty.h" #include "lib/tty/tty.h"
#include "lib/tty/color.h" #include "lib/tty/color.h"
#include "lib/skin.h" #include "lib/skin.h"
#include "lib/util.h"
#include "lib/widget.h" #include "lib/widget.h"
/*** global variables ****************************************************************************/ /*** global variables ****************************************************************************/
@ -120,8 +121,7 @@ groupbox_new (int y, int x, int height, int width, const char *title)
void void
groupbox_set_title (WGroupbox * g, const char *title) groupbox_set_title (WGroupbox * g, const char *title)
{ {
g_free (g->title); MC_PTR_FREE (g->title);
g->title = NULL;
/* Strip existing spaces, add one space before and after the title */ /* Strip existing spaces, add one space before and after the title */
if (title != NULL && *title != '\0') if (title != NULL && *title != '\0')

View File

@ -890,9 +890,7 @@ input_destroy (WInput * in)
} }
g_free (in->history.name); g_free (in->history.name);
g_free (in->buffer); g_free (in->buffer);
MC_PTR_FREE (kill_buffer);
g_free (kill_buffer);
kill_buffer = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -270,14 +270,11 @@ filename_completion_function (const char *text, int state, input_complete_t flag
mc_closedir (directory); mc_closedir (directory);
directory = NULL; directory = NULL;
} }
g_free (dirname); MC_PTR_FREE (dirname);
dirname = NULL;
vfs_path_free (dirname_vpath); vfs_path_free (dirname_vpath);
dirname_vpath = NULL; dirname_vpath = NULL;
g_free (filename); MC_PTR_FREE (filename);
filename = NULL; MC_PTR_FREE (users_dirname);
g_free (users_dirname);
users_dirname = NULL;
return NULL; return NULL;
} }
@ -660,18 +657,12 @@ command_completion_function (const char *_text, int state, input_complete_t flag
} }
found = filename_completion_function (cur_word, state - init_state, flags); found = filename_completion_function (cur_word, state - init_state, flags);
if (!found) if (!found)
{ MC_PTR_FREE (cur_word);
g_free (cur_word);
cur_word = NULL;
}
} }
} }
if (found == NULL) if (found == NULL)
{ MC_PTR_FREE (path);
g_free (path);
path = NULL;
}
else else
{ {
p = strrchr (found, PATH_SEP); p = strrchr (found, PATH_SEP);
@ -795,11 +786,9 @@ completion_matches (const char *text, CompletionFunction entry_function, input_c
match_list[0] = g_strndup (match_list[1], low); match_list[0] = g_strndup (match_list[1], low);
} }
} }
else else /* There were no matches. */
{ /* There were no matches. */ MC_PTR_FREE (match_list);
g_free (match_list);
match_list = NULL;
}
return match_list; return match_list;
} }

View File

@ -330,17 +330,10 @@ static gchar *mc_args__loc__usage_string = NULL;
static void static void
mc_args_clean_temp_help_strings (void) mc_args_clean_temp_help_strings (void)
{ {
g_free (mc_args__loc__colors_string); MC_PTR_FREE (mc_args__loc__colors_string);
mc_args__loc__colors_string = NULL; MC_PTR_FREE (mc_args__loc__footer_string);
MC_PTR_FREE (mc_args__loc__header_string);
g_free (mc_args__loc__footer_string); MC_PTR_FREE (mc_args__loc__usage_string);
mc_args__loc__footer_string = NULL;
g_free (mc_args__loc__header_string);
mc_args__loc__header_string = NULL;
g_free (mc_args__loc__usage_string);
mc_args__loc__usage_string = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -1858,8 +1858,7 @@ destroy_hdiff (WDiff * dview)
mc_search_free (dview->search.handle); mc_search_free (dview->search.handle);
dview->search.handle = NULL; dview->search.handle = NULL;
g_free (dview->search.last_string); MC_PTR_FREE (dview->search.last_string);
dview->search.last_string = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -238,10 +238,8 @@ book_mark_clear (WEdit * edit, long line, int c)
} }
/* if there is only our dummy book mark left, clear it for speed */ /* if there is only our dummy book mark left, clear it for speed */
if (edit->book_mark->line == -1 && edit->book_mark->next == NULL) if (edit->book_mark->line == -1 && edit->book_mark->next == NULL)
{ MC_PTR_FREE (edit->book_mark);
g_free (edit->book_mark);
edit->book_mark = NULL;
}
return r; return r;
} }
@ -271,10 +269,7 @@ book_mark_flush (WEdit * edit, int c)
} }
} }
if (edit->book_mark->next == NULL) if (edit->book_mark->next == NULL)
{ MC_PTR_FREE (edit->book_mark);
g_free (edit->book_mark);
edit->book_mark = NULL;
}
edit->force |= REDRAW_PAGE; edit->force |= REDRAW_PAGE;
} }

View File

@ -357,8 +357,7 @@ check_file_access (WEdit * edit, const vfs_path_t * filename_vpath, struct stat
errmsg = g_strdup_printf (_("File \"%s\" is too large.\nOpen it anyway?"), errmsg = g_strdup_printf (_("File \"%s\" is too large.\nOpen it anyway?"),
vfs_path_as_str (filename_vpath)); vfs_path_as_str (filename_vpath));
act = edit_query_dialog2 (_("Warning"), errmsg, _("&Yes"), _("&No")); act = edit_query_dialog2 (_("Warning"), errmsg, _("&Yes"), _("&No"));
g_free (errmsg); MC_PTR_FREE (errmsg);
errmsg = NULL;
if (act != 0) if (act != 0)
ret = FALSE; ret = FALSE;

View File

@ -2017,16 +2017,14 @@ edit_load_macro_cmd (WEdit * edit)
else else
{ {
m_act.action = keybind_lookup_action (macro_pair[0]); m_act.action = keybind_lookup_action (macro_pair[0]);
g_free (macro_pair[0]); MC_PTR_FREE (macro_pair[0]);
macro_pair[0] = NULL;
} }
if (macro_pair[1] == NULL || macro_pair[1][0] == '\0') if (macro_pair[1] == NULL || macro_pair[1][0] == '\0')
m_act.ch = -1; m_act.ch = -1;
else else
{ {
m_act.ch = strtol (macro_pair[1], NULL, 0); m_act.ch = strtol (macro_pair[1], NULL, 0);
g_free (macro_pair[1]); MC_PTR_FREE (macro_pair[1]);
macro_pair[1] = NULL;
} }
if (m_act.action != 0) if (m_act.action != 0)
{ {
@ -2516,8 +2514,8 @@ edit_replace_cmd (WEdit * edit, int again)
if (edit == NULL) if (edit == NULL)
{ {
g_free (saved1), saved1 = NULL; MC_PTR_FREE (saved1);
g_free (saved2), saved2 = NULL; MC_PTR_FREE (saved2);
return; return;
} }
@ -2799,8 +2797,7 @@ edit_search_cmd (WEdit * edit, gboolean again)
if (edit->search == NULL) if (edit->search == NULL)
{ {
/* if not... then ask for an expression */ /* if not... then ask for an expression */
g_free (edit->last_search_string); MC_PTR_FREE (edit->last_search_string);
edit->last_search_string = NULL;
edit_search (edit); edit_search (edit);
} }
else else
@ -2820,8 +2817,7 @@ edit_search_cmd (WEdit * edit, gboolean again)
else else
{ {
/* if not... then ask for an expression */ /* if not... then ask for an expression */
g_free (edit->last_search_string); MC_PTR_FREE (edit->last_search_string);
edit->last_search_string = NULL;
edit_search (edit); edit_search (edit);
} }
} }

View File

@ -298,8 +298,7 @@ aspell_init (void)
if (!spell_available ()) if (!spell_available ())
{ {
g_free (global_speller); MC_PTR_FREE (global_speller);
global_speller = NULL;
return; return;
} }
@ -338,8 +337,7 @@ aspell_clean (void)
if (global_speller->config != NULL) if (global_speller->config != NULL)
mc_delete_aspell_config (global_speller->config); mc_delete_aspell_config (global_speller->config);
g_free (global_speller); MC_PTR_FREE (global_speller);
global_speller = NULL;
g_module_close (spell_module); g_module_close (spell_module);
spell_module = NULL; spell_module = NULL;

View File

@ -537,8 +537,7 @@ dir_list_clean (dir_list * list)
file_entry_t *fentry; file_entry_t *fentry;
fentry = &list->list[i]; fentry = &list->list[i];
g_free (fentry->fname); MC_PTR_FREE (fentry->fname);
fentry->fname = NULL;
} }
list->len = 0; list->len = 0;

View File

@ -747,8 +747,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c
void void
flush_extension_file (void) flush_extension_file (void)
{ {
g_free (data); MC_PTR_FREE (data);
data = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -828,8 +827,7 @@ regex_command_for (void *target, const vfs_path_t * filename_vpath, const char *
if (strstr (data, "regex/") == NULL && strstr (data, "shell/") == NULL && if (strstr (data, "regex/") == NULL && strstr (data, "shell/") == NULL &&
strstr (data, "type/") == NULL) strstr (data, "type/") == NULL)
{ {
g_free (data); MC_PTR_FREE (data);
data = NULL;
if (!mc_user_ext) if (!mc_user_ext)
{ {

View File

@ -3077,8 +3077,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
#endif /* WITH_FULL_PATHS */ #endif /* WITH_FULL_PATHS */
g_free (dest); g_free (dest);
vfs_path_free (dest_vpath); vfs_path_free (dest_vpath);
g_free (ctx->dest_mask); MC_PTR_FREE (ctx->dest_mask);
ctx->dest_mask = NULL;
#ifdef ENABLE_BACKGROUND #ifdef ENABLE_BACKGROUND
/* Let our parent know we are saying bye bye */ /* Let our parent know we are saying bye bye */

View File

@ -862,8 +862,7 @@ file_op_context_destroy_ui (file_op_context_t * ctx)
dlg_run_done (ui->op_dlg); dlg_run_done (ui->op_dlg);
dlg_destroy (ui->op_dlg); dlg_destroy (ui->op_dlg);
g_free (ui); MC_PTR_FREE (ctx->ui);
ctx->ui = NULL;
} }
} }

View File

@ -265,10 +265,7 @@ parse_ignore_dirs (const char *ignore_dirs)
if (find_ignore_dirs[w][0] != '\0') if (find_ignore_dirs[w][0] != '\0')
w++; w++;
else else
{ MC_PTR_FREE (find_ignore_dirs[w]);
g_free (find_ignore_dirs[w]);
find_ignore_dirs[w] = NULL;
}
} }
if (find_ignore_dirs[0] == NULL) if (find_ignore_dirs[0] == NULL)
@ -315,10 +312,7 @@ find_load_options (void)
options.ignore_dirs = mc_config_get_string (mc_main_config, "FindFile", "ignore_dirs", ""); options.ignore_dirs = mc_config_get_string (mc_main_config, "FindFile", "ignore_dirs", "");
if (options.ignore_dirs[0] == '\0') if (options.ignore_dirs[0] == '\0')
{ MC_PTR_FREE (options.ignore_dirs);
g_free (options.ignore_dirs);
options.ignore_dirs = NULL;
}
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -1251,8 +1245,7 @@ do_search (WDialog * h)
mc_closedir (dirp); mc_closedir (dirp);
dirp = NULL; dirp = NULL;
} }
g_free (directory); MC_PTR_FREE (directory);
directory = NULL;
dp = NULL; dp = NULL;
return 1; return 1;
} }
@ -1386,8 +1379,7 @@ do_search (WDialog * h)
static void static void
init_find_vars (void) init_find_vars (void)
{ {
g_free (old_dir); MC_PTR_FREE (old_dir);
old_dir = NULL;
matches = 0; matches = 0;
ignore_count = 0; ignore_count = 0;
@ -1813,8 +1805,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs,
g_free (content_pattern); g_free (content_pattern);
kill_gui (); kill_gui ();
do_search (NULL); /* force do_search to release resources */ do_search (NULL); /* force do_search to release resources */
g_free (old_dir); MC_PTR_FREE (old_dir);
old_dir = NULL;
rotate_dash (FALSE); rotate_dash (FALSE);
return return_value; return return_value;

View File

@ -1663,14 +1663,12 @@ done_hotlist (void)
remove_group (hotlist); remove_group (hotlist);
g_free (hotlist->label); g_free (hotlist->label);
g_free (hotlist->directory); g_free (hotlist->directory);
g_free (hotlist); MC_PTR_FREE (hotlist);
hotlist = NULL;
} }
hotlist_state.loaded = FALSE; hotlist_state.loaded = FALSE;
g_free (hotlist_file_name); MC_PTR_FREE (hotlist_file_name);
hotlist_file_name = NULL;
l_hotlist = NULL; l_hotlist = NULL;
current_group = NULL; current_group = NULL;

View File

@ -4694,8 +4694,7 @@ remove_encoding_from_path (const vfs_path_t * vpath)
continue; continue;
} }
g_free (path_element->encoding); MC_PTR_FREE (path_element->encoding);
path_element->encoding = NULL;
str_vfs_convert_from (converter, path_element->path, tmp_conv); str_vfs_convert_from (converter, path_element->path, tmp_conv);

View File

@ -894,8 +894,7 @@ tree_store_end_check (void)
} }
/* get the stuff in the scan order */ /* get the stuff in the scan order */
ts.add_queue_vpath = g_list_reverse (ts.add_queue_vpath); the_queue = g_list_reverse (ts.add_queue_vpath);
the_queue = ts.add_queue_vpath;
ts.add_queue_vpath = NULL; ts.add_queue_vpath = NULL;
vfs_path_free (ts.check_name); vfs_path_free (ts.check_name);
ts.check_name = NULL; ts.check_name = NULL;

View File

@ -321,8 +321,7 @@ debug_out (char *start, char *end, int cond)
} }
debug_flag = 0; debug_flag = 0;
g_free (msg); MC_PTR_FREE (msg);
msg = NULL;
} }
else else
{ {
@ -946,8 +945,7 @@ user_menu_cmd (struct WEdit * edit_widget, const char *menu_file, int selected_e
{ {
message (D_ERROR, MSG_ERROR, _("Cannot open file %s\n%s"), menu, message (D_ERROR, MSG_ERROR, _("Cannot open file %s\n%s"), menu,
unix_error_string (errno)); unix_error_string (errno));
g_free (menu); MC_PTR_FREE (menu);
menu = NULL;
return FALSE; return FALSE;
} }
@ -984,8 +982,7 @@ user_menu_cmd (struct WEdit * edit_widget, const char *menu_file, int selected_e
if (!g_file_get_contents (menu, &data, NULL, NULL)) if (!g_file_get_contents (menu, &data, NULL, NULL))
{ {
message (D_ERROR, MSG_ERROR, _("Cannot open file%s\n%s"), menu, unix_error_string (errno)); message (D_ERROR, MSG_ERROR, _("Cannot open file%s\n%s"), menu, unix_error_string (errno));
g_free (menu); MC_PTR_FREE (menu);
menu = NULL;
return FALSE; return FALSE;
} }
@ -1124,8 +1121,7 @@ user_menu_cmd (struct WEdit * edit_widget, const char *menu_file, int selected_e
} }
easy_patterns = old_patterns; easy_patterns = old_patterns;
g_free (menu); MC_PTR_FREE (menu);
menu = NULL;
g_free (entries); g_free (entries);
g_free (data); g_free (data);
return res; return res;

View File

@ -95,10 +95,7 @@ learn_button (WButton * button, int action)
"and wait as well."), _(key_name_conv_tab[action - B_USER].longname)); "and wait as well."), _(key_name_conv_tab[action - B_USER].longname));
mc_refresh (); mc_refresh ();
if (learnkeys[action - B_USER].sequence != NULL) if (learnkeys[action - B_USER].sequence != NULL)
{ MC_PTR_FREE (learnkeys[action - B_USER].sequence);
g_free (learnkeys[action - B_USER].sequence);
learnkeys[action - B_USER].sequence = NULL;
}
seq = learn_key (); seq = learn_key ();
if (seq != NULL) if (seq != NULL)

View File

@ -206,8 +206,7 @@ cpio_free_archive (struct vfs_class *me, struct vfs_s_super *super)
arch->fd = -1; arch->fd = -1;
g_slist_free_full (arch->deferred, g_free); g_slist_free_full (arch->deferred, g_free);
arch->deferred = NULL; arch->deferred = NULL;
g_free (super->data); MC_PTR_FREE (super->data);
super->data = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -250,8 +249,7 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, const vfs_
{ {
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s); message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
g_free (s); g_free (s);
g_free (super->name); MC_PTR_FREE (super->name);
super->name = NULL;
return -1; return -1;
} }
g_free (s); g_free (s);

View File

@ -1489,10 +1489,7 @@ static void
fish_fh_free_data (vfs_file_handler_t * fh) fish_fh_free_data (vfs_file_handler_t * fh)
{ {
if (fh != NULL) if (fh != NULL)
{ MC_PTR_FREE (fh->data);
g_free (fh->data);
fh->data = NULL;
}
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */

View File

@ -355,10 +355,7 @@ ftpfs_correct_url_parameters (const vfs_path_element_t * velement)
/* If user is different, remove password */ /* If user is different, remove password */
if (new_user != NULL && strcmp (path_element->user, new_user) != 0) if (new_user != NULL && strcmp (path_element->user, new_user) != 0)
{ MC_PTR_FREE (path_element->password);
g_free (path_element->password);
path_element->password = NULL;
}
g_free (new_user); g_free (new_user);
g_free (new_passwd); g_free (new_passwd);
@ -552,8 +549,7 @@ ftpfs_free_archive (struct vfs_class *me, struct vfs_s_super *super)
close (SUP->sock); close (SUP->sock);
} }
g_free (SUP->current_dir); g_free (SUP->current_dir);
g_free (super->data); MC_PTR_FREE (super->data);
super->data = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -887,8 +883,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
} }
vfs_print_message (_("ftpfs: making connection to %s"), host); vfs_print_message (_("ftpfs: making connection to %s"), host);
g_free (host); MC_PTR_FREE (host);
host = NULL;
if (connect (my_socket, curr_res->ai_addr, curr_res->ai_addrlen) >= 0) if (connect (my_socket, curr_res->ai_addr, curr_res->ai_addrlen) >= 0)
break; break;
@ -2119,10 +2114,7 @@ static void
ftpfs_fh_free_data (vfs_file_handler_t * fh) ftpfs_fh_free_data (vfs_file_handler_t * fh)
{ {
if (fh != NULL) if (fh != NULL)
{ MC_PTR_FREE (fh->data);
g_free (fh->data);
fh->data = NULL;
}
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -2189,8 +2181,7 @@ ftpfs_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t
if (fh->ino->localname) if (fh->ino->localname)
{ {
unlink (fh->ino->localname); unlink (fh->ino->localname);
g_free (fh->ino->localname); MC_PTR_FREE (fh->ino->localname);
fh->ino->localname = NULL;
} }
return 0; return 0;
} }
@ -2421,10 +2412,8 @@ ftpfs_netrc_lookup (const char *host, char **login, char **pass)
} *rup_cache = NULL, *rupp; } *rup_cache = NULL, *rupp;
/* Initialize *login and *pass */ /* Initialize *login and *pass */
g_free (*login); MC_PTR_FREE (*login);
*login = NULL; MC_PTR_FREE (*pass);
g_free (*pass);
*pass = NULL;
/* Look up in the cache first */ /* Look up in the cache first */
for (rupp = rup_cache; rupp != NULL; rupp = rupp->next) for (rupp = rup_cache; rupp != NULL; rupp = rupp->next)

View File

@ -505,9 +505,8 @@ sfs_done (struct vfs_class *me)
for (i = 0; i < sfs_no; i++) for (i = 0; i < sfs_no; i++)
{ {
g_free (sfs_prefix[i]); MC_PTR_FREE (sfs_prefix[i]);
g_free (sfs_command[i]); MC_PTR_FREE (sfs_command[i]);
sfs_prefix[i] = sfs_command[i] = NULL;
} }
sfs_no = 0; sfs_no = 0;
} }

View File

@ -320,8 +320,7 @@ tar_open_archive_int (struct vfs_class *me, const vfs_path_t * vpath, struct vfs
g_free (s); g_free (s);
if (result == -1) if (result == -1)
{ {
g_free (archive->name); MC_PTR_FREE (archive->name);
archive->name = NULL;
ERRNOR (ENOENT, -1); ERRNOR (ENOENT, -1);
} }
} }
@ -585,8 +584,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
data = tar_get_next_record (archive, tard)->charptr; data = tar_get_next_record (archive, tard)->charptr;
if (data == NULL) if (data == NULL)
{ {
g_free (*longp); MC_PTR_FREE (*longp);
*longp = NULL;
message (D_ERROR, MSG_ERROR, _("Unexpected EOF on archive file")); message (D_ERROR, MSG_ERROR, _("Unexpected EOF on archive file"));
return STATUS_BADCHECKSUM; return STATUS_BADCHECKSUM;
} }
@ -600,8 +598,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
if (bp - *longp == MC_MAXPATHLEN && bp[-1] != '\0') if (bp - *longp == MC_MAXPATHLEN && bp[-1] != '\0')
{ {
g_free (*longp); MC_PTR_FREE (*longp);
*longp = NULL;
message (D_ERROR, MSG_ERROR, _("Inconsistent tar archive")); message (D_ERROR, MSG_ERROR, _("Inconsistent tar archive"));
return STATUS_BADCHECKSUM; return STATUS_BADCHECKSUM;
} }

View File

@ -63,6 +63,7 @@
#include "lib/global.h" #include "lib/global.h"
#include "lib/util.h"
#include "lib/widget.h" /* message() */ #include "lib/widget.h" /* message() */
#include "lib/vfs/utilvfs.h" #include "lib/vfs/utilvfs.h"
#include "lib/vfs/vfs.h" #include "lib/vfs/vfs.h"
@ -140,12 +141,9 @@ undelfs_shutdown (void)
if (fs) if (fs)
ext2fs_close (fs); ext2fs_close (fs);
fs = NULL; fs = NULL;
g_free (ext2_fname); MC_PTR_FREE (ext2_fname);
ext2_fname = NULL; MC_PTR_FREE (delarray);
g_free (delarray); MC_PTR_FREE (block_buf);
delarray = NULL;
g_free (block_buf);
block_buf = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -328,11 +326,9 @@ undelfs_loaddel (void)
error_out: error_out:
ext2fs_close_inode_scan (scan); ext2fs_close_inode_scan (scan);
free_block_buf: free_block_buf:
g_free (block_buf); MC_PTR_FREE (block_buf);
block_buf = NULL;
free_delarray: free_delarray:
g_free (delarray); MC_PTR_FREE (delarray);
delarray = NULL;
return 0; return 0;
} }

View File

@ -154,8 +154,7 @@ mcview_continue_search_cmd (mcview_t * view)
if (view->search == NULL) if (view->search == NULL)
{ {
/* if not... then ask for an expression */ /* if not... then ask for an expression */
g_free (view->last_search_string); MC_PTR_FREE (view->last_search_string);
view->last_search_string = NULL;
mcview_search (view, TRUE); mcview_search (view, TRUE);
} }
else else
@ -175,8 +174,7 @@ mcview_continue_search_cmd (mcview_t * view)
else else
{ {
/* if not... then ask for an expression */ /* if not... then ask for an expression */
g_free (view->last_search_string); MC_PTR_FREE (view->last_search_string);
view->last_search_string = NULL;
mcview_search (view, TRUE); mcview_search (view, TRUE);
} }
} }

View File

@ -368,12 +368,10 @@ mcview_close_datasource (mcview_t * view)
case DS_FILE: case DS_FILE:
(void) mc_close (view->ds_file_fd); (void) mc_close (view->ds_file_fd);
view->ds_file_fd = -1; view->ds_file_fd = -1;
g_free (view->ds_file_data); MC_PTR_FREE (view->ds_file_data);
view->ds_file_data = NULL;
break; break;
case DS_STRING: case DS_STRING:
g_free (view->ds_string_data); MC_PTR_FREE (view->ds_string_data);
view->ds_string_data = NULL;
break; break;
default: default:
#ifdef HAVE_ASSERT_H #ifdef HAVE_ASSERT_H

View File

@ -224,8 +224,7 @@ mcview_done (mcview_t * view)
view->filename_vpath = NULL; view->filename_vpath = NULL;
vfs_path_free (view->workdir_vpath); vfs_path_free (view->workdir_vpath);
view->workdir_vpath = NULL; view->workdir_vpath = NULL;
g_free (view->command); MC_PTR_FREE (view->command);
view->command = NULL;
mcview_close_datasource (view); mcview_close_datasource (view);
/* the growing buffer is freed with the datasource */ /* the growing buffer is freed with the datasource */

View File

@ -319,8 +319,7 @@ mcview_nroff_seq_free (mcview_nroff_t ** nroff)
{ {
if (nroff == NULL || *nroff == NULL) if (nroff == NULL || *nroff == NULL)
return; return;
g_free (*nroff); MC_PTR_FREE (*nroff);
*nroff = NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */