diff --git a/lib/filehighlight/common.c b/lib/filehighlight/common.c index 1397b1828..2f578fd34 100644 --- a/lib/filehighlight/common.c +++ b/lib/filehighlight/common.c @@ -104,8 +104,7 @@ mc_fhl_free (mc_fhl_t ** fhl) mc_fhl_clear (*fhl); - g_free (*fhl); - *fhl = NULL; + MC_PTR_FREE (*fhl); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/mcconfig/paths.c b/lib/mcconfig/paths.c index d8ef43494..c2aefa998 100644 --- a/lib/mcconfig/paths.c +++ b/lib/mcconfig/paths.c @@ -168,10 +168,8 @@ mc_config_init_one_config_path (const char *path_base, const char *subdir, GErro mc_config_mkdir (full_path, mcerror); if (mcerror != NULL && *mcerror != NULL) - { - g_free (full_path); - full_path = NULL; - } + MC_PTR_FREE (full_path); + return full_path; } diff --git a/lib/search/search.c b/lib/search/search.c index 65952f3b8..a404c70ca 100644 --- a/lib/search/search.c +++ b/lib/search/search.c @@ -33,6 +33,7 @@ #include "lib/global.h" #include "lib/strutil.h" #include "lib/search.h" +#include "lib/util.h" #ifdef HAVE_CHARSET #include "lib/charsets.h" #endif @@ -273,8 +274,7 @@ mc_search_run (mc_search_t * lc_mc_search, const void *user_data, #endif /* SEARCH_TYPE_GLIB */ lc_mc_search->error = MC_SEARCH_E_OK; - g_free (lc_mc_search->error_str); - lc_mc_search->error_str = NULL; + MC_PTR_FREE (lc_mc_search->error_str); if ((lc_mc_search->conditions == NULL) && !mc_search_prepare (lc_mc_search)) return FALSE; diff --git a/lib/skin/common.c b/lib/skin/common.c index f7e94a0c8..6aaa47915 100644 --- a/lib/skin/common.c +++ b/lib/skin/common.c @@ -168,13 +168,11 @@ mc_skin_deinit (void) tty_color_free_all_tmp (); tty_color_free_all_non_tmp (); - g_free (mc_skin__default.name); - mc_skin__default.name = NULL; + MC_PTR_FREE (mc_skin__default.name); g_hash_table_destroy (mc_skin__default.colors); mc_skin__default.colors = NULL; - g_free (mc_skin__default.description); - mc_skin__default.description = NULL; + MC_PTR_FREE (mc_skin__default.description); mc_config_deinit (mc_skin__default.config); mc_skin__default.config = NULL; diff --git a/lib/util.c b/lib/util.c index 504c8ea24..a592b822f 100644 --- a/lib/util.c +++ b/lib/util.c @@ -135,8 +135,7 @@ resolve_symlinks (const vfs_path_t * vpath) *q = 0; if (mc_lstat (vpath, &mybuf) < 0) { - g_free (buf); - buf = NULL; + MC_PTR_FREE (buf); goto ret; } 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); if (len < 0) { - g_free (buf); - buf = NULL; + MC_PTR_FREE (buf); goto ret; } buf2[len] = 0; diff --git a/lib/vfs/direntry.c b/lib/vfs/direntry.c index 550292f69..e8e14e327 100644 --- a/lib/vfs/direntry.c +++ b/lib/vfs/direntry.c @@ -963,8 +963,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent) if (ent->dir != NULL) ent->dir->subdir = g_list_remove (ent->dir->subdir, ent); - g_free (ent->name); - /* ent->name = NULL; */ + MC_PTR_FREE (ent->name); if (ent->ino != NULL) { @@ -1405,8 +1404,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino) close (handle); unlink (ino->localname); error_4: - g_free (ino->localname); - ino->localname = NULL; + MC_PTR_FREE (ino->localname); g_free (fh.data); return -1; } diff --git a/lib/widget/groupbox.c b/lib/widget/groupbox.c index 18b6099c5..8e0025a62 100644 --- a/lib/widget/groupbox.c +++ b/lib/widget/groupbox.c @@ -39,6 +39,7 @@ #include "lib/tty/tty.h" #include "lib/tty/color.h" #include "lib/skin.h" +#include "lib/util.h" #include "lib/widget.h" /*** global variables ****************************************************************************/ @@ -120,8 +121,7 @@ groupbox_new (int y, int x, int height, int width, const char *title) void groupbox_set_title (WGroupbox * g, const char *title) { - g_free (g->title); - g->title = NULL; + MC_PTR_FREE (g->title); /* Strip existing spaces, add one space before and after the title */ if (title != NULL && *title != '\0') diff --git a/lib/widget/input.c b/lib/widget/input.c index d259296af..4ce2ddb50 100644 --- a/lib/widget/input.c +++ b/lib/widget/input.c @@ -890,9 +890,7 @@ input_destroy (WInput * in) } g_free (in->history.name); g_free (in->buffer); - - g_free (kill_buffer); - kill_buffer = NULL; + MC_PTR_FREE (kill_buffer); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c index a4a0ffe94..cb35e1942 100644 --- a/lib/widget/input_complete.c +++ b/lib/widget/input_complete.c @@ -270,14 +270,11 @@ filename_completion_function (const char *text, int state, input_complete_t flag mc_closedir (directory); directory = NULL; } - g_free (dirname); - dirname = NULL; + MC_PTR_FREE (dirname); vfs_path_free (dirname_vpath); dirname_vpath = NULL; - g_free (filename); - filename = NULL; - g_free (users_dirname); - users_dirname = NULL; + MC_PTR_FREE (filename); + MC_PTR_FREE (users_dirname); 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); if (!found) - { - g_free (cur_word); - cur_word = NULL; - } + MC_PTR_FREE (cur_word); } } if (found == NULL) - { - g_free (path); - path = NULL; - } + MC_PTR_FREE (path); else { 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); } } - else - { /* There were no matches. */ - g_free (match_list); - match_list = NULL; - } + else /* There were no matches. */ + MC_PTR_FREE (match_list); + return match_list; } diff --git a/src/args.c b/src/args.c index f1f7f34dd..300a3b0dd 100644 --- a/src/args.c +++ b/src/args.c @@ -330,17 +330,10 @@ static gchar *mc_args__loc__usage_string = NULL; static void mc_args_clean_temp_help_strings (void) { - g_free (mc_args__loc__colors_string); - mc_args__loc__colors_string = NULL; - - g_free (mc_args__loc__footer_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; + MC_PTR_FREE (mc_args__loc__colors_string); + MC_PTR_FREE (mc_args__loc__footer_string); + MC_PTR_FREE (mc_args__loc__header_string); + MC_PTR_FREE (mc_args__loc__usage_string); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c index 54415bf8f..570be84fa 100644 --- a/src/diffviewer/ydiff.c +++ b/src/diffviewer/ydiff.c @@ -1858,8 +1858,7 @@ destroy_hdiff (WDiff * dview) mc_search_free (dview->search.handle); dview->search.handle = NULL; - g_free (dview->search.last_string); - dview->search.last_string = NULL; + MC_PTR_FREE (dview->search.last_string); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/editor/bookmark.c b/src/editor/bookmark.c index 8f79f3f42..d8797887b 100644 --- a/src/editor/bookmark.c +++ b/src/editor/bookmark.c @@ -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 (edit->book_mark->line == -1 && edit->book_mark->next == NULL) - { - g_free (edit->book_mark); - edit->book_mark = NULL; - } + MC_PTR_FREE (edit->book_mark); + return r; } @@ -271,10 +269,7 @@ book_mark_flush (WEdit * edit, int c) } } if (edit->book_mark->next == NULL) - { - g_free (edit->book_mark); - edit->book_mark = NULL; - } + MC_PTR_FREE (edit->book_mark); edit->force |= REDRAW_PAGE; } diff --git a/src/editor/edit.c b/src/editor/edit.c index 30eed4bc6..758fce8b2 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -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?"), vfs_path_as_str (filename_vpath)); act = edit_query_dialog2 (_("Warning"), errmsg, _("&Yes"), _("&No")); - g_free (errmsg); - errmsg = NULL; + MC_PTR_FREE (errmsg); if (act != 0) ret = FALSE; diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index dcd1a3c1c..46bafc362 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -2017,16 +2017,14 @@ edit_load_macro_cmd (WEdit * edit) else { m_act.action = keybind_lookup_action (macro_pair[0]); - g_free (macro_pair[0]); - macro_pair[0] = NULL; + MC_PTR_FREE (macro_pair[0]); } if (macro_pair[1] == NULL || macro_pair[1][0] == '\0') m_act.ch = -1; else { m_act.ch = strtol (macro_pair[1], NULL, 0); - g_free (macro_pair[1]); - macro_pair[1] = NULL; + MC_PTR_FREE (macro_pair[1]); } if (m_act.action != 0) { @@ -2516,8 +2514,8 @@ edit_replace_cmd (WEdit * edit, int again) if (edit == NULL) { - g_free (saved1), saved1 = NULL; - g_free (saved2), saved2 = NULL; + MC_PTR_FREE (saved1); + MC_PTR_FREE (saved2); return; } @@ -2799,8 +2797,7 @@ edit_search_cmd (WEdit * edit, gboolean again) if (edit->search == NULL) { /* if not... then ask for an expression */ - g_free (edit->last_search_string); - edit->last_search_string = NULL; + MC_PTR_FREE (edit->last_search_string); edit_search (edit); } else @@ -2820,8 +2817,7 @@ edit_search_cmd (WEdit * edit, gboolean again) else { /* if not... then ask for an expression */ - g_free (edit->last_search_string); - edit->last_search_string = NULL; + MC_PTR_FREE (edit->last_search_string); edit_search (edit); } } diff --git a/src/editor/spell.c b/src/editor/spell.c index 5bfc5a01a..e91a98407 100644 --- a/src/editor/spell.c +++ b/src/editor/spell.c @@ -298,8 +298,7 @@ aspell_init (void) if (!spell_available ()) { - g_free (global_speller); - global_speller = NULL; + MC_PTR_FREE (global_speller); return; } @@ -338,8 +337,7 @@ aspell_clean (void) if (global_speller->config != NULL) mc_delete_aspell_config (global_speller->config); - g_free (global_speller); - global_speller = NULL; + MC_PTR_FREE (global_speller); g_module_close (spell_module); spell_module = NULL; diff --git a/src/filemanager/dir.c b/src/filemanager/dir.c index 84b657bb2..d2d07be82 100644 --- a/src/filemanager/dir.c +++ b/src/filemanager/dir.c @@ -537,8 +537,7 @@ dir_list_clean (dir_list * list) file_entry_t *fentry; fentry = &list->list[i]; - g_free (fentry->fname); - fentry->fname = NULL; + MC_PTR_FREE (fentry->fname); } list->len = 0; diff --git a/src/filemanager/ext.c b/src/filemanager/ext.c index 5828142af..fd933abbc 100644 --- a/src/filemanager/ext.c +++ b/src/filemanager/ext.c @@ -747,8 +747,7 @@ regex_check_type (const vfs_path_t * filename_vpath, const char *ptr, gboolean c void flush_extension_file (void) { - g_free (data); - data = NULL; + MC_PTR_FREE (data); } /* --------------------------------------------------------------------------------------------- */ @@ -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 && strstr (data, "type/") == NULL) { - g_free (data); - data = NULL; + MC_PTR_FREE (data); if (!mc_user_ext) { diff --git a/src/filemanager/file.c b/src/filemanager/file.c index 9f8eeb7b6..caf375b37 100644 --- a/src/filemanager/file.c +++ b/src/filemanager/file.c @@ -3077,8 +3077,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl #endif /* WITH_FULL_PATHS */ g_free (dest); vfs_path_free (dest_vpath); - g_free (ctx->dest_mask); - ctx->dest_mask = NULL; + MC_PTR_FREE (ctx->dest_mask); #ifdef ENABLE_BACKGROUND /* Let our parent know we are saying bye bye */ diff --git a/src/filemanager/filegui.c b/src/filemanager/filegui.c index dfc88ca8e..57af8280e 100644 --- a/src/filemanager/filegui.c +++ b/src/filemanager/filegui.c @@ -862,8 +862,7 @@ file_op_context_destroy_ui (file_op_context_t * ctx) dlg_run_done (ui->op_dlg); dlg_destroy (ui->op_dlg); - g_free (ui); - ctx->ui = NULL; + MC_PTR_FREE (ctx->ui); } } diff --git a/src/filemanager/find.c b/src/filemanager/find.c index 23c2ba1c6..6f718088b 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -265,10 +265,7 @@ parse_ignore_dirs (const char *ignore_dirs) if (find_ignore_dirs[w][0] != '\0') w++; else - { - g_free (find_ignore_dirs[w]); - find_ignore_dirs[w] = NULL; - } + MC_PTR_FREE (find_ignore_dirs[w]); } 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", ""); if (options.ignore_dirs[0] == '\0') - { - g_free (options.ignore_dirs); - options.ignore_dirs = NULL; - } + MC_PTR_FREE (options.ignore_dirs); } /* --------------------------------------------------------------------------------------------- */ @@ -1251,8 +1245,7 @@ do_search (WDialog * h) mc_closedir (dirp); dirp = NULL; } - g_free (directory); - directory = NULL; + MC_PTR_FREE (directory); dp = NULL; return 1; } @@ -1386,8 +1379,7 @@ do_search (WDialog * h) static void init_find_vars (void) { - g_free (old_dir); - old_dir = NULL; + MC_PTR_FREE (old_dir); matches = 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); kill_gui (); do_search (NULL); /* force do_search to release resources */ - g_free (old_dir); - old_dir = NULL; + MC_PTR_FREE (old_dir); rotate_dash (FALSE); return return_value; diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c index 5d2e24db5..0e3c61f44 100644 --- a/src/filemanager/hotlist.c +++ b/src/filemanager/hotlist.c @@ -1663,14 +1663,12 @@ done_hotlist (void) remove_group (hotlist); g_free (hotlist->label); g_free (hotlist->directory); - g_free (hotlist); - hotlist = NULL; + MC_PTR_FREE (hotlist); } hotlist_state.loaded = FALSE; - g_free (hotlist_file_name); - hotlist_file_name = NULL; + MC_PTR_FREE (hotlist_file_name); l_hotlist = NULL; current_group = NULL; diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index 4c36d1eda..38029fa6a 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -4694,8 +4694,7 @@ remove_encoding_from_path (const vfs_path_t * vpath) continue; } - g_free (path_element->encoding); - path_element->encoding = NULL; + MC_PTR_FREE (path_element->encoding); str_vfs_convert_from (converter, path_element->path, tmp_conv); diff --git a/src/filemanager/treestore.c b/src/filemanager/treestore.c index 065eda5c0..f2a8f167a 100644 --- a/src/filemanager/treestore.c +++ b/src/filemanager/treestore.c @@ -894,8 +894,7 @@ tree_store_end_check (void) } /* get the stuff in the scan order */ - ts.add_queue_vpath = g_list_reverse (ts.add_queue_vpath); - the_queue = ts.add_queue_vpath; + the_queue = g_list_reverse (ts.add_queue_vpath); ts.add_queue_vpath = NULL; vfs_path_free (ts.check_name); ts.check_name = NULL; diff --git a/src/filemanager/usermenu.c b/src/filemanager/usermenu.c index bf198dcfc..38f71977f 100644 --- a/src/filemanager/usermenu.c +++ b/src/filemanager/usermenu.c @@ -321,8 +321,7 @@ debug_out (char *start, char *end, int cond) } debug_flag = 0; - g_free (msg); - msg = NULL; + MC_PTR_FREE (msg); } 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, unix_error_string (errno)); - g_free (menu); - menu = NULL; + MC_PTR_FREE (menu); 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)) { message (D_ERROR, MSG_ERROR, _("Cannot open file%s\n%s"), menu, unix_error_string (errno)); - g_free (menu); - menu = NULL; + MC_PTR_FREE (menu); return FALSE; } @@ -1124,8 +1121,7 @@ user_menu_cmd (struct WEdit * edit_widget, const char *menu_file, int selected_e } easy_patterns = old_patterns; - g_free (menu); - menu = NULL; + MC_PTR_FREE (menu); g_free (entries); g_free (data); return res; diff --git a/src/learn.c b/src/learn.c index 7bfe96367..b6faf0ae0 100644 --- a/src/learn.c +++ b/src/learn.c @@ -95,10 +95,7 @@ learn_button (WButton * button, int action) "and wait as well."), _(key_name_conv_tab[action - B_USER].longname)); mc_refresh (); if (learnkeys[action - B_USER].sequence != NULL) - { - g_free (learnkeys[action - B_USER].sequence); - learnkeys[action - B_USER].sequence = NULL; - } + MC_PTR_FREE (learnkeys[action - B_USER].sequence); seq = learn_key (); if (seq != NULL) diff --git a/src/vfs/cpio/cpio.c b/src/vfs/cpio/cpio.c index 553a0ffb6..ea5f9e4f2 100644 --- a/src/vfs/cpio/cpio.c +++ b/src/vfs/cpio/cpio.c @@ -206,8 +206,7 @@ cpio_free_archive (struct vfs_class *me, struct vfs_s_super *super) arch->fd = -1; g_slist_free_full (arch->deferred, g_free); arch->deferred = NULL; - g_free (super->data); - super->data = NULL; + MC_PTR_FREE (super->data); } /* --------------------------------------------------------------------------------------------- */ @@ -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); g_free (s); - g_free (super->name); - super->name = NULL; + MC_PTR_FREE (super->name); return -1; } g_free (s); diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c index 0c2f5f85a..a1f260d4a 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -1489,10 +1489,7 @@ static void fish_fh_free_data (vfs_file_handler_t * fh) { if (fh != NULL) - { - g_free (fh->data); - fh->data = NULL; - } + MC_PTR_FREE (fh->data); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/vfs/ftpfs/ftpfs.c b/src/vfs/ftpfs/ftpfs.c index bb87af681..05be4bbb0 100644 --- a/src/vfs/ftpfs/ftpfs.c +++ b/src/vfs/ftpfs/ftpfs.c @@ -355,10 +355,7 @@ ftpfs_correct_url_parameters (const vfs_path_element_t * velement) /* If user is different, remove password */ if (new_user != NULL && strcmp (path_element->user, new_user) != 0) - { - g_free (path_element->password); - path_element->password = NULL; - } + MC_PTR_FREE (path_element->password); g_free (new_user); g_free (new_passwd); @@ -552,8 +549,7 @@ ftpfs_free_archive (struct vfs_class *me, struct vfs_s_super *super) close (SUP->sock); } g_free (SUP->current_dir); - g_free (super->data); - super->data = NULL; + MC_PTR_FREE (super->data); } /* --------------------------------------------------------------------------------------------- */ @@ -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); - g_free (host); - host = NULL; + MC_PTR_FREE (host); if (connect (my_socket, curr_res->ai_addr, curr_res->ai_addrlen) >= 0) break; @@ -2119,10 +2114,7 @@ static void ftpfs_fh_free_data (vfs_file_handler_t * fh) { if (fh != NULL) - { - g_free (fh->data); - fh->data = NULL; - } + MC_PTR_FREE (fh->data); } /* --------------------------------------------------------------------------------------------- */ @@ -2189,8 +2181,7 @@ ftpfs_fh_open (struct vfs_class *me, vfs_file_handler_t * fh, int flags, mode_t if (fh->ino->localname) { unlink (fh->ino->localname); - g_free (fh->ino->localname); - fh->ino->localname = NULL; + MC_PTR_FREE (fh->ino->localname); } return 0; } @@ -2421,10 +2412,8 @@ ftpfs_netrc_lookup (const char *host, char **login, char **pass) } *rup_cache = NULL, *rupp; /* Initialize *login and *pass */ - g_free (*login); - *login = NULL; - g_free (*pass); - *pass = NULL; + MC_PTR_FREE (*login); + MC_PTR_FREE (*pass); /* Look up in the cache first */ for (rupp = rup_cache; rupp != NULL; rupp = rupp->next) diff --git a/src/vfs/sfs/sfs.c b/src/vfs/sfs/sfs.c index 09c8b5e1f..14717f77c 100644 --- a/src/vfs/sfs/sfs.c +++ b/src/vfs/sfs/sfs.c @@ -505,9 +505,8 @@ sfs_done (struct vfs_class *me) for (i = 0; i < sfs_no; i++) { - g_free (sfs_prefix[i]); - g_free (sfs_command[i]); - sfs_prefix[i] = sfs_command[i] = NULL; + MC_PTR_FREE (sfs_prefix[i]); + MC_PTR_FREE (sfs_command[i]); } sfs_no = 0; } diff --git a/src/vfs/tar/tar.c b/src/vfs/tar/tar.c index 28978877b..d0ebaa9fb 100644 --- a/src/vfs/tar/tar.c +++ b/src/vfs/tar/tar.c @@ -320,8 +320,7 @@ tar_open_archive_int (struct vfs_class *me, const vfs_path_t * vpath, struct vfs g_free (s); if (result == -1) { - g_free (archive->name); - archive->name = NULL; + MC_PTR_FREE (archive->name); 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; if (data == NULL) { - g_free (*longp); - *longp = NULL; + MC_PTR_FREE (*longp); message (D_ERROR, MSG_ERROR, _("Unexpected EOF on archive file")); 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') { - g_free (*longp); - *longp = NULL; + MC_PTR_FREE (*longp); message (D_ERROR, MSG_ERROR, _("Inconsistent tar archive")); return STATUS_BADCHECKSUM; } diff --git a/src/vfs/undelfs/undelfs.c b/src/vfs/undelfs/undelfs.c index 9c5acf3b7..9bf8beedf 100644 --- a/src/vfs/undelfs/undelfs.c +++ b/src/vfs/undelfs/undelfs.c @@ -63,6 +63,7 @@ #include "lib/global.h" +#include "lib/util.h" #include "lib/widget.h" /* message() */ #include "lib/vfs/utilvfs.h" #include "lib/vfs/vfs.h" @@ -140,12 +141,9 @@ undelfs_shutdown (void) if (fs) ext2fs_close (fs); fs = NULL; - g_free (ext2_fname); - ext2_fname = NULL; - g_free (delarray); - delarray = NULL; - g_free (block_buf); - block_buf = NULL; + MC_PTR_FREE (ext2_fname); + MC_PTR_FREE (delarray); + MC_PTR_FREE (block_buf); } /* --------------------------------------------------------------------------------------------- */ @@ -328,11 +326,9 @@ undelfs_loaddel (void) error_out: ext2fs_close_inode_scan (scan); free_block_buf: - g_free (block_buf); - block_buf = NULL; + MC_PTR_FREE (block_buf); free_delarray: - g_free (delarray); - delarray = NULL; + MC_PTR_FREE (delarray); return 0; } diff --git a/src/viewer/actions_cmd.c b/src/viewer/actions_cmd.c index c96e8e308..8df149e24 100644 --- a/src/viewer/actions_cmd.c +++ b/src/viewer/actions_cmd.c @@ -154,8 +154,7 @@ mcview_continue_search_cmd (mcview_t * view) if (view->search == NULL) { /* if not... then ask for an expression */ - g_free (view->last_search_string); - view->last_search_string = NULL; + MC_PTR_FREE (view->last_search_string); mcview_search (view, TRUE); } else @@ -175,8 +174,7 @@ mcview_continue_search_cmd (mcview_t * view) else { /* if not... then ask for an expression */ - g_free (view->last_search_string); - view->last_search_string = NULL; + MC_PTR_FREE (view->last_search_string); mcview_search (view, TRUE); } } diff --git a/src/viewer/datasource.c b/src/viewer/datasource.c index 9ec5ab43b..3389ee4dd 100644 --- a/src/viewer/datasource.c +++ b/src/viewer/datasource.c @@ -368,12 +368,10 @@ mcview_close_datasource (mcview_t * view) case DS_FILE: (void) mc_close (view->ds_file_fd); view->ds_file_fd = -1; - g_free (view->ds_file_data); - view->ds_file_data = NULL; + MC_PTR_FREE (view->ds_file_data); break; case DS_STRING: - g_free (view->ds_string_data); - view->ds_string_data = NULL; + MC_PTR_FREE (view->ds_string_data); break; default: #ifdef HAVE_ASSERT_H diff --git a/src/viewer/lib.c b/src/viewer/lib.c index c996c45c3..bef763ed7 100644 --- a/src/viewer/lib.c +++ b/src/viewer/lib.c @@ -224,8 +224,7 @@ mcview_done (mcview_t * view) view->filename_vpath = NULL; vfs_path_free (view->workdir_vpath); view->workdir_vpath = NULL; - g_free (view->command); - view->command = NULL; + MC_PTR_FREE (view->command); mcview_close_datasource (view); /* the growing buffer is freed with the datasource */ diff --git a/src/viewer/nroff.c b/src/viewer/nroff.c index eb3a4869f..4ec2e4c85 100644 --- a/src/viewer/nroff.c +++ b/src/viewer/nroff.c @@ -319,8 +319,7 @@ mcview_nroff_seq_free (mcview_nroff_t ** nroff) { if (nroff == NULL || *nroff == NULL) return; - g_free (*nroff); - *nroff = NULL; + MC_PTR_FREE (*nroff); } /* --------------------------------------------------------------------------------------------- */