From 1c287d798d3b4f3d21356234d605321b5410479d Mon Sep 17 00:00:00 2001 From: Patrick Winnertz Date: Thu, 5 Feb 2009 23:27:37 +0100 Subject: [PATCH] First bunch of mhl_mem_free removal patches Signed-off-by: Patrick Winnertz --- ChangeLog | 2 +- edit/bookmark.c | 11 ++-- edit/choosesyntax.c | 12 ++--- edit/edit.c | 41 +++++++-------- edit/editcmd.c | 123 ++++++++++++++++++++++---------------------- edit/editdraw.c | 4 +- edit/editlock.c | 26 +++++----- edit/editmenu.c | 5 +- edit/editoptions.c | 7 ++- edit/editwidget.c | 2 +- edit/syntax.c | 16 +++--- edit/usermap.c | 12 ++--- edit/wordproc.c | 9 ++-- mhl/README | 8 +-- mhl/memory.h | 4 +- mhl/strhash.h | 2 +- src/achown.c | 5 +- src/background.c | 11 ++-- src/boxes.c | 22 ++++---- src/charsets.c | 12 ++--- src/cmd.c | 75 ++++++++++++++------------- src/color.c | 8 +-- src/command.c | 18 +++---- src/complete.c | 50 +++++++++--------- src/cons.handler.c | 2 +- src/dialog.c | 8 +-- src/dir.c | 6 +-- src/ecs-test.c | 4 +- src/ecs.c | 4 +- src/ecs.h | 2 +- src/execute.c | 8 +-- src/ext.c | 40 +++++++------- src/file.c | 70 ++++++++++++------------- src/filegui.c | 18 +++---- src/filenot.c | 10 ++-- src/fileopctx.c | 4 +- src/find.c | 66 ++++++++++++------------ src/help.c | 8 +-- src/hotlist.c | 54 +++++++++---------- src/key.c | 6 +-- src/layout.c | 5 +- src/learn.c | 9 ++-- src/listmode.c | 2 +- src/logging.c | 4 +- src/main.c | 38 +++++++------- src/menu.c | 6 +-- src/panelize.c | 16 +++--- src/profile.c | 20 +++---- src/rxvt.c | 5 +- src/screen.c | 58 ++++++++++----------- src/setup.c | 26 +++++----- src/subshell.c | 8 +-- src/tree.c | 20 ++++--- src/treestore.c | 30 +++++------ src/user.c | 36 ++++++------- src/util.c | 70 ++++++++++++------------- src/utilunix.c | 6 +-- src/view.c | 64 +++++++++++------------ src/widget.c | 50 +++++++++--------- src/wtools.c | 16 +++--- src/x11conn.c | 5 +- vfs/cpio.c | 22 ++++---- vfs/direntry.c | 60 ++++++++++----------- vfs/extfs.c | 100 +++++++++++++++++------------------ vfs/fish.c | 54 +++++++++---------- vfs/ftpfs.c | 91 ++++++++++++++++---------------- vfs/gc.c | 6 +-- vfs/local.c | 4 +- vfs/mcfs.c | 66 ++++++++++++------------ vfs/mcserv.c | 56 ++++++++++---------- vfs/sfs.c | 30 +++++------ vfs/smbfs.c | 122 +++++++++++++++++++++---------------------- vfs/tar.c | 20 ++++--- vfs/undelfs.c | 66 ++++++++++++------------ vfs/utilvfs.c | 8 +-- vfs/vfs.c | 51 +++++++++--------- 76 files changed, 1016 insertions(+), 1029 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3fd7ee340..a4b977f99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,7 +40,7 @@ 2009-01-30 Enrico Weigelt, metux ITS - * replaced calls to g_free() by mhl_mem_free() + * replaced calls to g_free() by g_free() 2009-01-29 Mikhail S. Pobolovets diff --git a/edit/bookmark.c b/edit/bookmark.c index bb5c6b1f4..403b93c33 100644 --- a/edit/bookmark.c +++ b/edit/bookmark.c @@ -28,12 +28,11 @@ #include #include #include + #include #include #include -#include - #include "../src/global.h" #include "edit.h" @@ -159,13 +158,13 @@ int book_mark_clear (WEdit * edit, int line, int c) p->prev->next = p->next; if (p->next) p->next->prev = p->prev; - mhl_mem_free (p); + g_free (p); break; } } /* if there is only our dummy book mark left, clear it for speed */ if (edit->book_mark->line == -1 && !edit->book_mark->next) { - mhl_mem_free (edit->book_mark); + g_free (edit->book_mark); edit->book_mark = 0; } return r; @@ -186,11 +185,11 @@ void book_mark_flush (WEdit * edit, int c) q->prev->next = q->next; if (p) p->prev = q->prev; - mhl_mem_free (q); + g_free (q); } } if (!edit->book_mark->next) { - mhl_mem_free (edit->book_mark); + g_free (edit->book_mark); edit->book_mark = 0; } } diff --git a/edit/choosesyntax.c b/edit/choosesyntax.c index 886fe90a3..5715ac9a0 100644 --- a/edit/choosesyntax.c +++ b/edit/choosesyntax.c @@ -74,9 +74,9 @@ edit_syntax_dialog (void) { if ((syntax = exec_edit_syntax_dialog ((const char**) names)) < 0) { for (i = 0; names[i]; i++) { - mhl_mem_free (names[i]); + g_free (names[i]); } - mhl_mem_free (names); + g_free (names); return; } @@ -92,7 +92,7 @@ edit_syntax_dialog (void) { break; default: option_auto_syntax = 0; - mhl_mem_free (option_syntax_type); + g_free (option_syntax_type); option_syntax_type = mhl_str_dup (names[syntax - N_DFLT_ENTRIES]); } @@ -104,8 +104,8 @@ edit_syntax_dialog (void) { edit_load_syntax (wedit, NULL, option_syntax_type); for (i = 0; names[i]; i++) { - mhl_mem_free (names[i]); + g_free (names[i]); } - mhl_mem_free (names); - mhl_mem_free (old_syntax_type); + g_free (names); + g_free (old_syntax_type); } diff --git a/edit/edit.c b/edit/edit.c index 4504df798..e8c0c8e1c 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -22,7 +22,6 @@ */ #include - #include #include #include @@ -219,7 +218,7 @@ edit_get_filter (const char *filename) l = strlen (quoted_name); p = g_malloc (strlen (all_filters[i].read) + l + 2); sprintf (p, all_filters[i].read, quoted_name); - mhl_mem_free (quoted_name); + g_free (quoted_name); return p; } @@ -235,7 +234,7 @@ edit_get_write_filter (const char *write_name, const char *filename) l = strlen (writename); p = g_malloc (strlen (all_filters[i].write) + l + 2); sprintf (p, all_filters[i].write, writename); - mhl_mem_free (writename); + g_free (writename); return p; } @@ -303,7 +302,7 @@ edit_insert_file (WEdit *edit, const char *filename) edit_insert (edit, buf[i]); } edit_cursor_move (edit, current - edit->curs1); - mhl_mem_free (buf); + g_free (buf); mc_close (file); if (blocklen) return 0; @@ -450,7 +449,7 @@ edit_load_position (WEdit *edit) filename = vfs_canon (edit->filename); load_file_position (filename, &line, &column); - mhl_mem_free (filename); + g_free (filename); edit_move_to_line (edit, line - 1); edit->prev_col = column; @@ -469,7 +468,7 @@ edit_save_position (WEdit *edit) filename = vfs_canon (edit->filename); save_file_position (filename, edit->curs_line + 1, edit->curs_col); - mhl_mem_free (filename); + g_free (filename); } /* Clean the WEdit stricture except the widget part */ @@ -543,7 +542,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename, if (edit_load_file (edit)) { /* edit_load_file already gives an error message */ if (to_free) - mhl_mem_free (edit); + g_free (edit); return 0; } edit->loading_done = 1; @@ -594,13 +593,13 @@ edit_clean (WEdit *edit) edit_free_syntax_rules (edit); book_mark_flush (edit, -1); for (; j <= MAXBUFF; j++) { - mhl_mem_free (edit->buffers1[j]); - mhl_mem_free (edit->buffers2[j]); + g_free (edit->buffers1[j]); + g_free (edit->buffers2[j]); } - mhl_mem_free (edit->undo_stack); - mhl_mem_free (edit->filename); - mhl_mem_free (edit->dir); + g_free (edit->undo_stack); + g_free (edit->filename); + g_free (edit->dir); edit_purge_widget (edit); @@ -640,12 +639,12 @@ edit_reload (WEdit *edit, const char *filename) e = g_malloc0 (sizeof (WEdit)); e->widget = edit->widget; if (!edit_init (e, lines, columns, filename, 0)) { - mhl_mem_free (e); + g_free (e); return 0; } edit_clean (edit); memcpy (edit, e, sizeof (WEdit)); - mhl_mem_free (e); + g_free (e); return 1; } @@ -931,7 +930,7 @@ int edit_delete (WEdit * edit) p = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1]; if (!(edit->curs2 & M_EDIT_BUF_SIZE)) { - mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); + g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = NULL; } edit->last_byte--; @@ -968,7 +967,7 @@ edit_backspace (WEdit * edit) p = *(edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE] + ((edit->curs1 - 1) & M_EDIT_BUF_SIZE)); if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) { - mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); + g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL; } edit->last_byte--; @@ -1053,7 +1052,7 @@ edit_move_backward_lots (WEdit *edit, long increment) edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE); } else { - mhl_mem_free (p); + g_free (p); } s = edit->curs1 & M_EDIT_BUF_SIZE; @@ -1091,7 +1090,7 @@ edit_move_backward_lots (WEdit *edit, long increment) edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE); } else { - mhl_mem_free (p); + g_free (p); } } return edit_get_byte (edit, edit->curs1); @@ -1127,7 +1126,7 @@ void edit_cursor_move (WEdit * edit, long increment) edit->curs2++; c = edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 - 1) & M_EDIT_BUF_SIZE]; if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) { - mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); + g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL; } edit->curs1--; @@ -1151,7 +1150,7 @@ void edit_cursor_move (WEdit * edit, long increment) edit->curs1++; c = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1]; if (!(edit->curs2 & M_EDIT_BUF_SIZE)) { - mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); + g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = 0; } edit->curs2--; @@ -2701,5 +2700,5 @@ user_menu (WEdit * edit) edit->force |= REDRAW_COMPLETELY; cleanup: - mhl_mem_free (block_file); + g_free (block_file); } diff --git a/edit/editcmd.c b/edit/editcmd.c index 9d730e0ee..3a14b86bc 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -28,6 +28,7 @@ #include #include + #include #include #include @@ -145,7 +146,7 @@ catstrs (const char *first,...) len++; i = (i + 1) % 16; - mhl_mem_free (stacked[i]); + g_free (stacked[i]); stacked[i] = g_malloc (len); va_end (ap); @@ -164,7 +165,7 @@ void freestrs(void) size_t i; for (i = 0; i < sizeof(stacked) / sizeof(stacked[0]); i++) { - mhl_mem_free (stacked[i]); + g_free (stacked[i]); stacked[i] = NULL; } } @@ -216,7 +217,7 @@ edit_save_file (WEdit *edit, const char *filename) if (*filename != PATH_SEP && edit->dir) { savename = mhl_str_dir_plus_file (edit->dir, filename); filename = catstrs (savename, (char *) NULL); - mhl_mem_free (savename); + g_free (savename); } this_save_mode = option_save_mode; @@ -281,9 +282,9 @@ edit_save_file (WEdit *edit, const char *filename) } else savedir = mhl_str_dup ("."); saveprefix = mhl_str_dir_plus_file (savedir, "cooledit"); - mhl_mem_free (savedir); + g_free (savedir); fd = mc_mkstemps (&savename, saveprefix, NULL); - mhl_mem_free (saveprefix); + g_free (saveprefix); if (!savename) return 0; /* FIXME: @@ -319,7 +320,7 @@ edit_save_file (WEdit *edit, const char *filename) edit_error_dialog (_("Error"), catstrs (_(" Error writing to pipe: "), p, " ", (char *) NULL)); - mhl_mem_free (p); + g_free (p); goto error_save; } #endif @@ -329,10 +330,10 @@ edit_save_file (WEdit *edit, const char *filename) (_ (" Cannot open pipe for writing: "), p, " ", (char *) NULL))); - mhl_mem_free (p); + g_free (p); goto error_save; } - mhl_mem_free (p); + g_free (p); } else { long buf; buf = 0; @@ -393,14 +394,14 @@ edit_save_file (WEdit *edit, const char *filename) if (this_save_mode != EDIT_QUICK_SAVE) if (mc_rename (savename, filename) == -1) goto error_save; - mhl_mem_free (savename); + g_free (savename); return 1; error_save: /* FIXME: Is this safe ? * if (this_save_mode != EDIT_QUICK_SAVE) * mc_unlink (savename); */ - mhl_mem_free (savename); + g_free (savename); return 0; } @@ -471,7 +472,7 @@ void menu_save_mode_cmd (void) return; option_save_mode = save_mode_new; - mhl_mem_free (option_backup_ext); + g_free (option_backup_ext); option_backup_ext = str_result; str_result = NULL; } @@ -479,7 +480,7 @@ void menu_save_mode_cmd (void) void edit_set_filename (WEdit *edit, const char *f) { - mhl_mem_free (edit->filename); + g_free (edit->filename); if (!f) f = ""; edit->filename = mhl_str_dup (f); @@ -508,7 +509,7 @@ edit_save_as_cmd (WEdit *edit) if (exp) { if (!*exp) { - mhl_mem_free (exp); + g_free (exp); edit->force |= REDRAW_COMPLETELY; return 0; } else { @@ -525,7 +526,7 @@ edit_save_as_cmd (WEdit *edit) _(" A file already exists with this name. "), _("&Overwrite"), _("&Cancel"))) { edit->force |= REDRAW_COMPLETELY; - mhl_mem_free (exp); + g_free (exp); return 0; } } @@ -551,7 +552,7 @@ edit_save_as_cmd (WEdit *edit) } edit_set_filename (edit, exp); - mhl_mem_free (exp); + g_free (exp); edit->modified = 0; edit->delete_file = 0; if (different_filename) @@ -567,7 +568,7 @@ edit_save_as_cmd (WEdit *edit) /* Failed, so maintain modify (not save) lock */ if (save_lock) edit_unlock_file (exp); - mhl_mem_free (exp); + g_free (exp); edit->force |= REDRAW_COMPLETELY; return 0; } @@ -859,13 +860,13 @@ edit_load_file_from_filename (WEdit * edit, char *exp) char *prev_filename = mhl_str_dup (edit->filename); if (!edit_reload (edit, exp)) { - mhl_mem_free (prev_filename); + g_free (prev_filename); return 1; } if (prev_locked) edit_unlock_file (prev_filename); - mhl_mem_free (prev_filename); + g_free (prev_filename); return 0; } @@ -891,7 +892,7 @@ edit_load_cmd (WEdit *edit) if (exp) { if (*exp) edit_load_file_from_filename (edit, exp); - mhl_mem_free (exp); + g_free (exp); } edit->force |= REDRAW_COMPLETELY; return 0; @@ -992,7 +993,7 @@ edit_block_copy_cmd (WEdit *edit) edit_insert_ahead (edit, copy_buf[size]); } - mhl_mem_free (copy_buf); + g_free (copy_buf); edit_scroll_screen_over_cursor (edit); if (column_highlighting) { @@ -1093,7 +1094,7 @@ edit_block_move_cmd (WEdit *edit) edit->curs1 + end_mark - start_mark, 0, 0); } edit_scroll_screen_over_cursor (edit); - mhl_mem_free (copy_buf); + g_free (copy_buf); edit->force |= REDRAW_PAGE; } @@ -1429,7 +1430,7 @@ string_regexp_search (char *pattern, char *string, int match_type, || old_type != match_type || old_icase != icase) { if (old_pattern) { regfree (&r); - mhl_mem_free (old_pattern); + g_free (old_pattern); old_pattern = 0; } if (regcomp (&r, pattern, REG_EXTENDED | (icase ? REG_ICASE : 0) | @@ -1805,9 +1806,9 @@ edit_replace_cmd (WEdit *edit, int again) int argord[NUM_REPL_ARGS]; if (!edit) { - mhl_mem_free (saved1), saved1 = NULL; - mhl_mem_free (saved2), saved2 = NULL; - mhl_mem_free (saved3), saved3 = NULL; + g_free (saved1), saved1 = NULL; + g_free (saved2), saved2 = NULL; + g_free (saved3), saved3 = NULL; return; } @@ -1835,9 +1836,9 @@ edit_replace_cmd (WEdit *edit, int again) edit_replace_dialog (edit, disp1, disp2, disp3, &input1, &input2, &input3); - mhl_mem_free (disp1); - mhl_mem_free (disp2); - mhl_mem_free (disp3); + g_free (disp1); + g_free (disp2); + g_free (disp3); convert_from_input (input1); convert_from_input (input2); @@ -1849,9 +1850,9 @@ edit_replace_cmd (WEdit *edit, int again) goto cleanup; } - mhl_mem_free (saved1), saved1 = mhl_str_dup (input1); - mhl_mem_free (saved2), saved2 = mhl_str_dup (input2); - mhl_mem_free (saved3), saved3 = mhl_str_dup (input3); + g_free (saved1), saved1 = mhl_str_dup (input1); + g_free (saved2), saved2 = mhl_str_dup (input2); + g_free (saved3), saved3 = mhl_str_dup (input3); } { @@ -2042,9 +2043,9 @@ edit_replace_cmd (WEdit *edit, int again) edit->force = REDRAW_COMPLETELY; edit_scroll_screen_over_cursor (edit); cleanup: - mhl_mem_free (input1); - mhl_mem_free (input2); - mhl_mem_free (input3); + g_free (input1); + g_free (input2); + g_free (input3); } @@ -2056,7 +2057,7 @@ void edit_search_cmd (WEdit * edit, int again) char *exp = ""; if (!edit) { - mhl_mem_free (old); + g_free (old); old = NULL; return; } @@ -2086,7 +2087,7 @@ void edit_search_cmd (WEdit * edit, int again) if (exp) { if (*exp) { int len = 0; - mhl_mem_free (old); + g_free (old); old = mhl_str_dup (exp); if (search_create_bookmark) { @@ -2143,7 +2144,7 @@ void edit_search_cmd (WEdit * edit, int again) } } } - mhl_mem_free (exp); + g_free (exp); } edit->force |= REDRAW_COMPLETELY; edit_scroll_screen_over_cursor (edit); @@ -2182,7 +2183,7 @@ edit_ok_to_exit (WEdit *edit) #define TEMP_BUF_LEN 1024 -/* Return a null terminated length of text. Result must be mhl_mem_free'd */ +/* Return a null terminated length of text. Result must be g_free'd */ static unsigned char * edit_get_block (WEdit *edit, long start, long finish, int *l) { @@ -2235,7 +2236,7 @@ edit_save_block (WEdit * edit, const char *filename, long start, p += r; len -= r; } - mhl_mem_free (block); + g_free (block); } else { unsigned char *buf; int i = start, end; @@ -2248,7 +2249,7 @@ edit_save_block (WEdit * edit, const char *filename, long start, len -= mc_write (file, (char *) buf, end - start); start = end; } - mhl_mem_free (buf); + g_free (buf); } mc_close (file); if (len) @@ -2322,13 +2323,13 @@ edit_goto_cmd (WEdit *edit) return; if (!*f) { - mhl_mem_free (f); + g_free (f); return; } l = strtol (f, &error, 0); if (*error) { - mhl_mem_free (f); + g_free (f); return; } @@ -2338,7 +2339,7 @@ edit_goto_cmd (WEdit *edit) edit_move_display (edit, l - edit->num_widget_lines / 2 - 1); edit_move_to_line (edit, l - 1); edit->force |= REDRAW_COMPLETELY; - mhl_mem_free (f); + g_free (f); } @@ -2357,15 +2358,15 @@ edit_save_block_cmd (WEdit *edit) edit_push_action (edit, KEY_PRESS + edit->start_display); if (exp) { if (!*exp) { - mhl_mem_free (exp); + g_free (exp); return 0; } else { if (edit_save_block (edit, exp, start_mark, end_mark)) { - mhl_mem_free (exp); + g_free (exp); edit->force |= REDRAW_COMPLETELY; return 1; } else { - mhl_mem_free (exp); + g_free (exp); edit_error_dialog (_(" Save Block "), get_sys_error (_ (" Cannot save file. "))); @@ -2387,15 +2388,15 @@ edit_insert_file_cmd (WEdit *edit) edit_push_action (edit, KEY_PRESS + edit->start_display); if (exp) { if (!*exp) { - mhl_mem_free (exp); + g_free (exp); return 0; } else { if (edit_insert_file (edit, exp)) { - mhl_mem_free (exp); + g_free (exp); edit->force |= REDRAW_COMPLETELY; return 1; } else { - mhl_mem_free (exp); + g_free (exp); edit_error_dialog (_(" Insert File "), get_sys_error (_ (" Cannot insert file. "))); @@ -2426,7 +2427,7 @@ int edit_sort_cmd (WEdit * edit) if (!exp) return 1; - mhl_mem_free (old); + g_free (old); old = exp; e = system (catstrs (" sort ", exp, " ", home_dir, PATH_SEP_STR BLOCK_FILE, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL)); @@ -2470,7 +2471,7 @@ edit_ext_cmd (WEdit *edit) return 1; e = system (catstrs (exp, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL)); - mhl_mem_free (exp); + g_free (exp); if (e) { edit_error_dialog (_("External command"), @@ -2566,7 +2567,7 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block) system (catstrs (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ", quoted_name, (char *) NULL)); } - mhl_mem_free (quoted_name); + g_free (quoted_name); close_error_pipe (D_NORMAL, NULL); edit_refresh_cmd (edit); @@ -2607,13 +2608,13 @@ static void pipe_mail (WEdit *edit, char *to, char *subject, char *cc) subject = name_quote (subject, 0); cc = name_quote (cc, 0); s = g_strconcat ("mail -s ", subject, *cc ? " -c " : "" , cc, " ", to, (char *) NULL); - mhl_mem_free (to); - mhl_mem_free (subject); - mhl_mem_free (cc); + g_free (to); + g_free (subject); + g_free (cc); if (s) { p = popen (s, "w"); - mhl_mem_free (s); + g_free (s); } if (p) { @@ -2672,9 +2673,9 @@ void edit_mail_dialog (WEdit * edit) Quick_input.widgets = quick_widgets; if (quick_dialog (&Quick_input) != B_CANCEL) { - mhl_mem_free (mail_cc_last); - mhl_mem_free (mail_subject_last); - mhl_mem_free (mail_to_last); + g_free (mail_cc_last); + g_free (mail_subject_last); + g_free (mail_to_last); mail_cc_last = tmail_cc; mail_subject_last = tmail_subject; mail_to_last = tmail_to; @@ -2916,10 +2917,10 @@ edit_complete_word_cmd (WEdit *edit) } } - mhl_mem_free (match_expr); + g_free (match_expr); /* release memory before return */ for (i = 0; i < num_compl; i++) - mhl_mem_free (compl[i].text); + g_free (compl[i].text); /* restore search parameters */ edit_set_search_parameters (old_rs, old_rb, old_rr, old_rw, old_rc); diff --git a/edit/editdraw.c b/edit/editdraw.c index 68a9033d6..b19139163 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -34,8 +34,6 @@ #include #include -#include - #include "../src/global.h" #include "edit.h" @@ -147,7 +145,7 @@ edit_status (WEdit *edit) printwstr (status, w - (fname_len + gap)); attrset (EDITOR_NORMAL_COLOR); - mhl_mem_free (status); + g_free (status); } /* this scrolls the text so that cursor is on the screen */ diff --git a/edit/editlock.c b/edit/editlock.c index 50682974c..2f83a2b55 100644 --- a/edit/editlock.c +++ b/edit/editlock.c @@ -22,8 +22,8 @@ */ #include - #include /* kill() */ + #include #include #include @@ -101,7 +101,7 @@ lock_build_symlink_name (const char *fname) fname_copy = mhl_str_dup (fname); absolute_fname[fname - absolute_fname] = '\0'; symlink_name = g_strconcat (absolute_fname, ".#", fname_copy, (char *) NULL); - mhl_mem_free (fname_copy); + g_free (fname_copy); return symlink_name; } @@ -176,7 +176,7 @@ edit_lock_file (const char *fname) if (lstat (lockfname, &statbuf) == 0) { lock = lock_get_info (lockfname); if (!lock) { - mhl_mem_free (lockfname); + g_free (lockfname); return 0; } lockinfo = lock_extract_info (lock); @@ -197,11 +197,11 @@ edit_lock_file (const char *fname) break; case 1: case -1: - mhl_mem_free (lockfname); - mhl_mem_free (msg); + g_free (lockfname); + g_free (msg); return 0; } - mhl_mem_free (msg); + g_free (msg); } unlink (lockfname); } @@ -209,13 +209,13 @@ edit_lock_file (const char *fname) /* Create lock symlink */ newlock = lock_build_name (); if (symlink (newlock, lockfname) == -1) { - mhl_mem_free (lockfname); - mhl_mem_free (newlock); + g_free (lockfname); + g_free (newlock); return 0; } - mhl_mem_free (lockfname); - mhl_mem_free (newlock); + g_free (lockfname); + g_free (newlock); return 1; } @@ -237,7 +237,7 @@ edit_unlock_file (const char *fname) /* Check if lock exists */ if (lstat (lockfname, &statbuf) == -1) { - mhl_mem_free (lockfname); + g_free (lockfname); return 0; } @@ -245,13 +245,13 @@ edit_unlock_file (const char *fname) if (lock) { /* Don't touch if lock is not ours */ if (lock_extract_info (lock)->pid != getpid ()) { - mhl_mem_free (lockfname); + g_free (lockfname); return 0; } } /* Remove lock */ unlink (lockfname); - mhl_mem_free (lockfname); + g_free (lockfname); return 0; } diff --git a/edit/editmenu.c b/edit/editmenu.c index 6a3e0da8e..596b32fa0 100644 --- a/edit/editmenu.c +++ b/edit/editmenu.c @@ -33,9 +33,8 @@ #include #include #include -#include -#include +#include #include "../src/global.h" @@ -476,7 +475,7 @@ edit_done_menu (struct WMenu *wmenu) for (i = 0; i < N_menus; i++) destroy_menu (wmenu->menu[i]); - mhl_mem_free(wmenu->menu); + g_free(wmenu->menu); } diff --git a/edit/editoptions.c b/edit/editoptions.c index 56785c7c7..777431f0d 100644 --- a/edit/editoptions.c +++ b/edit/editoptions.c @@ -33,9 +33,8 @@ #include #include #include -#include -#include +#include #include "../src/global.h" @@ -187,13 +186,13 @@ edit_options_dialog (void) if (p) { option_word_wrap_line_length = atoi (p); - mhl_mem_free (p); + g_free (p); } if (q) { option_tab_spacing = atoi (q); if (option_tab_spacing <= 0) option_tab_spacing = 8; - mhl_mem_free (q); + g_free (q); } option_syntax_highlighting = tedit_syntax_highlighting; diff --git a/edit/editwidget.c b/edit/editwidget.c index 048926257..8fb8c1471 100644 --- a/edit/editwidget.c +++ b/edit/editwidget.c @@ -178,7 +178,7 @@ edit_file (const char *_file, int line) if (!made_directory) { char *dir = mhl_str_dir_plus_file (home_dir, EDIT_DIR); made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST); - mhl_mem_free (dir); + g_free (dir); } if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, line))) { diff --git a/edit/syntax.c b/edit/syntax.c index 479f3c5cc..282a700f9 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -111,10 +111,10 @@ mc_defines_destroy (gpointer key, gpointer value, gpointer data) (void) data; - mhl_mem_free (key); + g_free (key); while (*values) - mhl_mem_free (*values++); - mhl_mem_free (value); + g_free (*values++); + g_free (value); return FALSE; } @@ -671,14 +671,14 @@ static FILE *open_include_file (const char *filename) if (*filename == PATH_SEP) return fopen (filename, "r"); - mhl_mem_free (error_file_name); + g_free (error_file_name); error_file_name = g_strconcat (home_dir, PATH_SEP_STR EDIT_DIR PATH_SEP_STR, filename, (char *) NULL); f = fopen (error_file_name, "r"); if (f) return f; - mhl_mem_free (error_file_name); + g_free (error_file_name); error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR, filename, (char *) NULL); return fopen (error_file_name, "r"); @@ -958,7 +958,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) c->keyword_first_chars = mhl_str_dup (first_chars); } - mhl_mem_free (first_chars); + g_free (first_chars); } return result; @@ -1028,7 +1028,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, if (!f){ lib_file = mhl_str_dir_plus_file (mc_home, "syntax" PATH_SEP_STR "Syntax"); f = fopen (lib_file, "r"); - mhl_mem_free (lib_file); + g_free (lib_file); if (!f) return -1; } @@ -1204,5 +1204,5 @@ edit_load_syntax (WEdit *edit, char ***pnames, const char *type) } else { /* succeeded */ } - mhl_mem_free (f); + g_free (f); } diff --git a/edit/usermap.c b/edit/usermap.c index b25cad949..c1beafd82 100644 --- a/edit/usermap.c +++ b/edit/usermap.c @@ -244,7 +244,7 @@ cfg_free_maps(config_t *cfg) cfg->ext_keymap = NULL; for (i = 0; i < 10; i++) - mhl_mem_free(cfg->labels[i]); + g_free(cfg->labels[i]); } /* Returns an array containing the words in str. WARNING: As long as @@ -556,7 +556,7 @@ parse_file(config_t *cfg, const char *file, const command_t *cmd) char *ss = mhl_str_dup(error_msg); snprintf(error_msg, sizeof(error_msg), _("%s:%d: %s"), file, line, ss); - mhl_mem_free(ss); + g_free(ss); g_ptr_array_free(args, TRUE); fclose(fp); return false; @@ -604,8 +604,8 @@ edit_load_user_map(WEdit *edit) if (stat(file, &s) < 0) { char *msg = g_strdup_printf(_("%s not found!"), file); edit_error_dialog(_("Error"), msg); - mhl_mem_free(msg); - mhl_mem_free(file); + g_free(msg); + g_free(file); return false; } @@ -616,7 +616,7 @@ edit_load_user_map(WEdit *edit) if (!load_user_keymap(&new_cfg, file)) { edit_error_dialog(_("Error"), error_msg); cfg_free_maps(&new_cfg); - mhl_mem_free(file); + g_free(file); return false; } else { cfg_free_maps(&cfg); @@ -628,7 +628,7 @@ edit_load_user_map(WEdit *edit) edit->ext_map = (edit_key_map_type *) cfg.ext_keymap->data; memcpy(edit->labels, cfg.labels, sizeof(edit->labels)); - mhl_mem_free(file); + g_free(file); return true; } diff --git a/edit/wordproc.c b/edit/wordproc.c index db64a0a54..fc16136b1 100644 --- a/edit/wordproc.c +++ b/edit/wordproc.c @@ -30,9 +30,8 @@ #include #include #include -#include -#include +#include #include "../src/global.h" @@ -350,13 +349,13 @@ format_paragraph (WEdit *edit, int force) if (!force) { int i; if (strchr (NO_FORMAT_CHARS_START, *t)) { - mhl_mem_free (t); + g_free (t); return; } for (i = 0; i < size - 1; i++) { if (t[i] == '\n') { if (strchr (NO_FORMAT_CHARS_START "\t ", t[i + 1])) { - mhl_mem_free (t); + g_free (t); return; } } @@ -364,7 +363,7 @@ format_paragraph (WEdit *edit, int force) } format_this (t, q - p, indent); put_paragraph (edit, t, p, indent, size); - mhl_mem_free (t); + g_free (t); /* Scroll left as much as possible to show the formatted paragraph */ edit_scroll_left (edit, -edit->start_col); diff --git a/mhl/README b/mhl/README index dbf3490bf..1a51be7b8 100644 --- a/mhl/README +++ b/mhl/README @@ -20,7 +20,7 @@ mhl/memory.h: Memory management functions Allocate sz bytes on stack, zero'ed - * mhl_mem_free(ptr) [INLINE-FUNC] + * g_free(ptr) [INLINE-FUNC] Free chunk @ptr (MUST be allocated w/ mhl_mem_alloc_*()), passing NULL is graciously allowed @@ -31,8 +31,8 @@ mhl/memory.h: Memory management functions * MHL_PTR_FREE(ptr) [MACRO-ONLY] - like mhl_mem_free(), but with ptr as a variable that gets cleared - (use this as shortcut to "mhl_mem_free(foo); foo = NULL") + like g_free(), but with ptr as a variable that gets cleared + (use this as shortcut to "g_free(foo); foo = NULL") mhl/string.h: String helpers @@ -58,7 +58,7 @@ mhl/string.h: String helpers * mhl_str_concat_1(const char* base, const char* one) -> char* [INLINE-FUNC] Concatenates the string one onto the string base and returns the - result in a newly allocated buffer (free it w/ mhl_mem_free()). + result in a newly allocated buffer (free it w/ g_free()). For NULL strings, "" is assumed. * mhl_str_concat_2(const char* base,const char* one,const char* two) -> char* diff --git a/mhl/memory.h b/mhl/memory.h index 3268e93a1..3a7793478 100644 --- a/mhl/memory.h +++ b/mhl/memory.h @@ -11,13 +11,13 @@ #define mhl_mem_alloc_z(sz) (calloc(1,sz)) /* free a chunk of memory from stack, passing NULL does no harm */ -static inline void mhl_mem_free(void* ptr) +static inline void g_free(void* ptr) { if (ptr) free(ptr); } /* free an ptr and NULL it */ -#define MHL_PTR_FREE(ptr) do { mhl_mem_free(ptr); (ptr) = NULL; } while (0) +#define MHL_PTR_FREE(ptr) do { g_free(ptr); (ptr) = NULL; } while (0) /* allocate a chunk on stack - automatically free'd on function exit */ #define mhl_stack_alloc(sz) (alloca(sz)) diff --git a/mhl/strhash.h b/mhl/strhash.h index 8ff17cba6..423ff09c3 100644 --- a/mhl/strhash.h +++ b/mhl/strhash.h @@ -6,7 +6,7 @@ static void __mhl_strhash_free_key(void* ptr) { - mhl_mem_free(ptr); + g_free(ptr); } static void __mhl_strhash_free_dummy(void* ptr) diff --git a/src/achown.c b/src/achown.c index c68a80668..de2ae0783 100644 --- a/src/achown.c +++ b/src/achown.c @@ -22,12 +22,11 @@ #include #include #include + #include #include #include -#include - #include "global.h" #include "tty.h" #include "win.h" @@ -597,7 +596,7 @@ init_chown_advanced (void) static void chown_advanced_done (void) { - mhl_mem_free (sf_stat); + g_free (sf_stat); if (need_update) update_panels (UP_OPTIMIZE, UP_KEEPSEL); repaint_screen (); diff --git a/src/background.c b/src/background.c index 689a3865c..fa828ddda 100644 --- a/src/background.c +++ b/src/background.c @@ -31,12 +31,11 @@ #include #include #include + #include #include #include -#include - #include "global.h" #include "background.h" #include "tty.h" /* doupdate() */ @@ -90,8 +89,8 @@ unregister_task_running (pid_t pid, int fd) prev->next = p->next; else task_list = p->next; - mhl_mem_free (p->info); - mhl_mem_free (p); + g_free (p->info); + g_free (p); break; } prev = p; @@ -322,7 +321,7 @@ background_attention (int fd, void *closure) write (fd, &len, sizeof (len)); if (len){ write (fd, resstr, len); - mhl_mem_free (resstr); + g_free (resstr); } } else { len = 0; @@ -330,7 +329,7 @@ background_attention (int fd, void *closure) } } for (i = 0; i < argc; i++) - mhl_mem_free (data [i]); + g_free (data [i]); do_refresh (); mc_refresh (); diff --git a/src/boxes.c b/src/boxes.c index 173908d86..c0351f864 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -235,11 +235,11 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n panel->user_status_format[i] = mhl_str_dup (DEFAULT_USER_FORMAT); section = g_strconcat ("Temporal:", p, (char *) NULL); if (!profile_has_section (section, profile_name)) { - mhl_mem_free (section); + g_free (section); section = mhl_str_dup (p); } panel_load_setup (panel, section); - mhl_mem_free (section); + g_free (section); } current_mode = panel->list_type; @@ -251,10 +251,10 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n result = -1; if (section) { - mhl_mem_free (panel->user_format); + g_free (panel->user_format); for (i = 0; i < LIST_TYPES; i++) - mhl_mem_free (panel->user_status_format [i]); - mhl_mem_free (panel); + g_free (panel->user_status_format [i]); + g_free (panel); } if (dd->ret_value != B_CANCEL){ @@ -784,19 +784,19 @@ configure_vfs (void) if (quick_dialog (&confvfs_dlg) != B_CANCEL) { vfs_timeout = atoi (ret_timeout); - mhl_mem_free (ret_timeout); + g_free (ret_timeout); if (vfs_timeout < 0 || vfs_timeout > 10000) vfs_timeout = 10; #if defined(USE_NETCODE) - mhl_mem_free (ftpfs_anonymous_passwd); + g_free (ftpfs_anonymous_passwd); ftpfs_anonymous_passwd = ret_passwd; - mhl_mem_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; ftpfs_use_passive_connections = ret_ftpfs_use_passive_connections; ftpfs_use_passive_connections_over_proxy = ret_ftpfs_use_passive_connections_over_proxy; - mhl_mem_free (ret_directory_timeout); + g_free (ret_directory_timeout); #endif } } @@ -907,7 +907,7 @@ jobs_fill_listbox (void) s = g_strconcat (state_str [tl->state], " ", tl->info, (char *) NULL); listbox_add_item (bg_list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl); - mhl_mem_free (s); + g_free (s); tl = tl->next; } } @@ -1085,7 +1085,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL, "[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE); - mhl_mem_free (title); + g_free (title); in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT); add_widget (auth_dlg, in_user); diff --git a/src/charsets.c b/src/charsets.c index 2b0c05aed..cb45a52dd 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -53,10 +53,10 @@ load_codepages_list (void) fname = mhl_str_dir_plus_file (mc_home, CHARSETS_INDEX); if (!(f = fopen (fname, "r"))) { fprintf (stderr, _("Warning: file %s not found\n"), fname); - mhl_mem_free (fname); + g_free (fname); return -1; } - mhl_mem_free (fname); + g_free (fname); for (n_codepages = 0; fgets (buf, sizeof (buf), f);) if (buf[0] != '\n' && buf[0] != '\0' && buf[0] != '#') @@ -99,7 +99,7 @@ load_codepages_list (void) if (default_codepage) { display_codepage = get_codepage_index (default_codepage); - mhl_mem_free (default_codepage); + g_free (default_codepage); } result = n_codepages; @@ -114,11 +114,11 @@ free_codepages_list (void) if (n_codepages > 0) { int i; for (i = 0; i < n_codepages; i++) { - mhl_mem_free (codepages[i].id); - mhl_mem_free (codepages[i].name); + g_free (codepages[i].id); + g_free (codepages[i].name); } n_codepages = 0; - mhl_mem_free (codepages); + g_free (codepages); codepages = 0; } } diff --git a/src/cmd.c b/src/cmd.c index 373cacc47..4f00f03b9 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -23,6 +23,7 @@ #include #include #include + #include #include #ifdef HAVE_MMAP @@ -241,7 +242,7 @@ view_file_cmd (void) return; view_file (filename, 0, use_internal_view); - mhl_mem_free (filename); + g_free (filename); } /* Run plain internal viewer on the currently selected file */ @@ -266,7 +267,7 @@ filtered_view_cmd (void) mc_internal_viewer (command, "", NULL, 0); - mhl_mem_free (command); + g_free (command); } void do_edit_at_line (const char *what, int start_line) @@ -384,8 +385,8 @@ mkdir_cmd (void) message (D_ERROR, MSG_ERROR, " %s ", unix_error_string (errno)); } - mhl_mem_free (absdir); - mhl_mem_free (dir); + g_free (absdir); + g_free (dir); } void delete_cmd (void) @@ -417,13 +418,13 @@ void find_cmd (void) static void set_panel_filter_to (WPanel *p, char *allocated_filter_string) { - mhl_mem_free (p->filter); + g_free (p->filter); p->filter = 0; if (!(allocated_filter_string [0] == '*' && allocated_filter_string [1] == 0)) p->filter = allocated_filter_string; else - mhl_mem_free (allocated_filter_string); + g_free (allocated_filter_string); reread_cmd (); } @@ -495,7 +496,7 @@ select_unselect_cmd (const char *title, const char *history_name, int cmd) if (!reg_exp) return; if (!*reg_exp) { - mhl_mem_free (reg_exp); + g_free (reg_exp); return; } @@ -525,14 +526,14 @@ select_unselect_cmd (const char *title, const char *history_name, int cmd) match_file); if (c == -1) { message (D_ERROR, MSG_ERROR, _(" Malformed regular expression ")); - mhl_mem_free (reg_exp); + g_free (reg_exp); return; } if (c) { do_file_mark (current_panel, i, cmd); } } - mhl_mem_free (reg_exp); + g_free (reg_exp); } void select_cmd (void) @@ -585,11 +586,11 @@ void ext_cmd (void) buffer = mhl_str_dir_plus_file (home_dir, MC_USER_EXT); check_for_default (extdir, buffer); do_edit (buffer); - mhl_mem_free (buffer); + g_free (buffer); } else if (dir == 1) do_edit (extdir); - mhl_mem_free (extdir); + g_free (extdir); flush_extension_file (); } @@ -627,14 +628,14 @@ menu_edit_cmd (int where) break; default: - mhl_mem_free (menufile); + g_free (menufile); return; } do_edit (buffer); if (dir == 0) chmod(buffer, 0600); - mhl_mem_free (buffer); - mhl_mem_free (menufile); + g_free (buffer); + g_free (menufile); } void quick_chdir_cmd (void) @@ -650,7 +651,7 @@ void quick_chdir_cmd (void) else if (!do_cd (target, cd_exact)) message (D_ERROR, MSG_ERROR, _("Cannot change directory") ); - mhl_mem_free (target); + g_free (target); } /* edit file menu for mc */ @@ -688,11 +689,11 @@ edit_syntax_cmd (void) buffer = mhl_str_dir_plus_file (home_dir, SYNTAX_FILE); check_for_default (extdir, buffer); do_edit (buffer); - mhl_mem_free (buffer); + g_free (buffer); } else if (dir == 1) do_edit (extdir); - mhl_mem_free (extdir); + g_free (extdir); } #endif @@ -707,7 +708,7 @@ void reselect_vfs (void) if (!do_cd (target, cd_exact)) message (D_ERROR, MSG_ERROR, _("Cannot change directory") ); - mhl_mem_free (target); + g_free (target); } #endif /* USE_VFS */ @@ -820,8 +821,8 @@ compare_dir (WPanel *panel, WPanel *other, enum CompareMode mode) dst_name = mhl_str_dir_plus_file (other->cwd, target->fname); if (compare_files (src_name, dst_name, source->st.st_size)) do_file_mark (panel, i, 1); - mhl_mem_free (src_name); - mhl_mem_free (dst_name); + g_free (src_name); + g_free (dst_name); } } /* for (i ...) */ } @@ -880,7 +881,7 @@ history_cmd (void) else current = listbox->list->current->data; destroy_dlg (listbox->dlg); - mhl_mem_free (listbox); + g_free (listbox); if (!current) return; @@ -940,8 +941,8 @@ do_link (int symbolic_link, const char *fname) } symlink_dialog (s, d, &dest, &src); - mhl_mem_free (d); - mhl_mem_free (s); + g_free (d); + g_free (s); if (!dest || !*dest || !src || !*src) goto cleanup; @@ -954,8 +955,8 @@ do_link (int symbolic_link, const char *fname) repaint_screen (); cleanup: - mhl_mem_free (src); - mhl_mem_free (dest); + g_free (src); + g_free (dest); } void link_cmd (void) @@ -1003,10 +1004,10 @@ void edit_symlink_cmd (void) update_panels (UP_OPTIMIZE, UP_KEEPSEL); repaint_screen (); } - mhl_mem_free (dest); + g_free (dest); } } - mhl_mem_free (q); + g_free (q); } else { message (D_ERROR, MSG_ERROR, _("`%s' is not a symbolic link"), selection (current_panel)->fname); @@ -1025,7 +1026,7 @@ user_file_menu_cmd (void) } /* partly taken from dcigettext.c, returns "" for default locale */ -/* value should be freed by calling function mhl_mem_free() */ +/* value should be freed by calling function g_free() */ char *guess_message_value (void) { static const char * const var[] = { @@ -1095,7 +1096,7 @@ get_random_hint (int force) if (eol) *eol = 0; result = mhl_str_dup (&data[start]); - mhl_mem_free (data); + g_free (data); return result; } @@ -1126,8 +1127,8 @@ nice_cd (const char *text, const char *xtext, const char *help, directory_history_add (MENU_PANEL, (MENU_PANEL)->cwd); else message (D_ERROR, MSG_ERROR, _(" Cannot chdir to %s "), cd_path); - mhl_mem_free (cd_path); - mhl_mem_free (machine); + g_free (cd_path); + g_free (machine); } #endif /* USE_NETCODE || USE_EXT2FSLIB */ @@ -1187,9 +1188,9 @@ void quick_cd_cmd (void) char *q = g_strconcat ("cd ", p, (char *) NULL); do_cd_command (q); - mhl_mem_free (q); + g_free (q); } - mhl_mem_free (p); + g_free (p); } void @@ -1255,17 +1256,17 @@ configure_panel_listing (WPanel *p, int view_type, int use_msformat, char *user, p->list_type = view_type; if (view_type == list_user || use_msformat){ - mhl_mem_free (p->user_format); + g_free (p->user_format); p->user_format = user; - mhl_mem_free (p->user_status_format [view_type]); + g_free (p->user_status_format [view_type]); p->user_status_format [view_type] = status; set_panel_formats (p); } else { - mhl_mem_free (user); - mhl_mem_free (status); + g_free (user); + g_free (status); } set_panel_formats (p); diff --git a/src/color.c b/src/color.c index a98b58834..295159f9e 100644 --- a/src/color.c +++ b/src/color.c @@ -255,7 +255,7 @@ static void configure_colors_string (const char *the_color_string) color_string++; } } - mhl_mem_free (p); + g_free (p); } static void configure_colors (void) @@ -467,9 +467,9 @@ done_colors (void) for (p = c.next; p; p = next) { next = p->next; - mhl_mem_free (p->fg); - mhl_mem_free (p->bg); - mhl_mem_free (p); + g_free (p->fg); + g_free (p->bg); + g_free (p); } c.next = NULL; } diff --git a/src/command.c b/src/command.c index 536c14dac..e720dc2ac 100644 --- a/src/command.c +++ b/src/command.c @@ -130,15 +130,15 @@ examine_cd (char *path) if (*p) { r = mhl_str_dir_plus_file (p, q); result = do_cd (r, cd_parse_command); - mhl_mem_free (r); + g_free (r); } *s = c; p = s + 1; } - mhl_mem_free (cdpath); + g_free (cdpath); } - mhl_mem_free (q); - mhl_mem_free (path_tilde); + g_free (q); + g_free (path_tilde); return result; } @@ -182,14 +182,14 @@ void do_cd_command (char *cmd) char *new; new = mhl_str_dir_plus_file (old, cmd+3); sync_tree (new); - mhl_mem_free (new); + g_free (new); } } else if (!examine_cd (&cmd [3])) { char *d = strip_password (mhl_str_dup (&cmd [3]), 1); message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "), d, unix_error_string (errno)); - mhl_mem_free (d); + g_free (d); return; } } @@ -243,7 +243,7 @@ enter (WInput *cmdline) s = expand_format (NULL, cmd[i], 1); command = g_realloc (command, j + strlen (s) + cmd_len - i + 1); strcpy (command + j, s); - mhl_mem_free (s); + g_free (s); j = strlen (command); } else { command[j] = cmd[i]; @@ -253,7 +253,7 @@ enter (WInput *cmdline) } new_input (cmdline); shell_execute (command, 0); - mhl_mem_free (command); + g_free (command); #ifdef HAVE_SUBSHELL_SUPPORT if (quit & SUBSHELL_EXIT) { @@ -315,6 +315,6 @@ command_insert (WInput * in, const char *text, int insert_extra_space) quoted_text = name_quote (text, 1); stuff (in, quoted_text, insert_extra_space); - mhl_mem_free (quoted_text); + g_free (quoted_text); } diff --git a/src/complete.c b/src/complete.c index 2c483d2ad..d5023cca0 100644 --- a/src/complete.c +++ b/src/complete.c @@ -92,9 +92,9 @@ filename_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) if (!state){ const char *temp; - mhl_mem_free (dirname); - mhl_mem_free (filename); - mhl_mem_free (users_dirname); + g_free (dirname); + g_free (filename); + g_free (users_dirname); if ((*text) && (temp = strrchr (text, PATH_SEP))){ filename = mhl_str_dup (++temp); @@ -159,7 +159,7 @@ filename_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) isexec = 1; } } - mhl_mem_free (tmp); + g_free (tmp); } if ((flags & INPUT_COMPLETE_COMMANDS) && (isexec || isdir)) @@ -177,11 +177,11 @@ filename_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) mc_closedir (directory); directory = NULL; } - mhl_mem_free (dirname); + g_free (dirname); dirname = NULL; - mhl_mem_free (filename); + g_free (filename); filename = NULL; - mhl_mem_free (users_dirname); + g_free (users_dirname); users_dirname = NULL; return NULL; } else { @@ -207,7 +207,7 @@ filename_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) if (temp && (flags & INPUT_COMPLETE_SHELL_ESC)) { SHELL_ESCAPED_STR e_temp = mhl_shell_escape_dup(temp); - mhl_mem_free (temp); + g_free (temp); temp = e_temp.s; } return temp; @@ -368,7 +368,7 @@ static void fetch_hosts (const char *filename) *(hosts_p++) = name; *hosts_p = NULL; } else - mhl_mem_free (name); + g_free (name); } } } @@ -388,8 +388,8 @@ hostname_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) if (hosts != NULL){ for (host_p = hosts; *host_p; host_p++) - mhl_mem_free (*host_p); - mhl_mem_free (hosts); + g_free (*host_p); + g_free (hosts); } hosts = g_new (char *, (hosts_alloclen = 30) + 1); *hosts = NULL; @@ -410,8 +410,8 @@ hostname_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) if (!*host_p){ for (host_p = hosts; *host_p; host_p++) - mhl_mem_free (*host_p); - mhl_mem_free (hosts); + g_free (*host_p); + g_free (hosts); hosts = NULL; return NULL; } else { @@ -487,7 +487,7 @@ command_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) if (!p) return 0; SHELL_ESCAPED_STR e_p = mhl_shell_escape_dup(p); - mhl_mem_free(p); + g_free(p); return e_p.s; } @@ -521,7 +521,7 @@ command_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) break; expanded = tilde_expand (*cur_path ? cur_path : "."); cur_word = mhl_str_dir_plus_file (expanded, text); - mhl_mem_free (expanded); + g_free (expanded); canonicalize_pathname (cur_word); cur_path = strchr (cur_path, 0) + 1; init_state = state; @@ -530,21 +530,21 @@ command_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) filename_completion_function (cur_word, state - init_state, flags); if (!found) { - mhl_mem_free (cur_word); + g_free (cur_word); cur_word = NULL; } } } if (!found) { - mhl_mem_free (path); + g_free (path); path = NULL; return NULL; } if ((p = strrchr (found, PATH_SEP)) != NULL) { p++; SHELL_ESCAPED_STR e_p = mhl_shell_escape_dup(p); - mhl_mem_free(found); + g_free(found); return e_p.s; } return found; @@ -617,7 +617,7 @@ completion_matches (char *text, CompletionFunction entry_function, INPUT_COMPLET if (c1 != c2) break; if (!c1 && !match_list [j][si]){ /* Two equal strings */ - mhl_mem_free (match_list [j]); + g_free (match_list [j]); j++; if (j > matches) break; @@ -633,7 +633,7 @@ completion_matches (char *text, CompletionFunction entry_function, INPUT_COMPLET match_list[0] = g_strndup(match_list[1], low); } } else { /* There were no matches. */ - mhl_mem_free (match_list); + g_free (match_list); match_list = NULL; } return match_list; @@ -817,17 +817,17 @@ try_complete (char *text, int *start, int *end, INPUT_COMPLETE_FLAGS flags) r = mhl_str_dir_plus_file (cdpath, word); SHOW_C_CTX("try_complete:filename_subst_2"); matches = completion_matches (r, filename_completion_function, flags); - mhl_mem_free (r); + g_free (r); } *s = c; cdpath = s + 1; } - mhl_mem_free (cdpath_ref); + g_free (cdpath_ref); } } } - mhl_mem_free (word); + g_free (word); return matches; } @@ -839,8 +839,8 @@ void free_completions (WInput *in) if (!in->completions) return; for (p=in->completions; *p; p++) - mhl_mem_free (*p); - mhl_mem_free (in->completions); + g_free (*p); + g_free (in->completions); in->completions = NULL; } diff --git a/src/cons.handler.c b/src/cons.handler.c index 21a11fec7..1fe35b0b3 100644 --- a/src/cons.handler.c +++ b/src/cons.handler.c @@ -267,7 +267,7 @@ console_shutdown (void) if (!console_flag) return; - mhl_mem_free (screen_shot.buf); + g_free (screen_shot.buf); console_flag = 0; } diff --git a/src/dialog.c b/src/dialog.c index 043f7debf..37c6903a4 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -221,7 +221,7 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set, char *t; t = g_strstrip (mhl_str_dup (title)); new_d->title = g_strconcat (" ", t, " ", (char *) NULL); - mhl_mem_free (t); + g_free (t); } return (new_d); @@ -816,11 +816,11 @@ destroy_dlg (Dlg_head *h) c = h->current; for (i = 0; i < h->count; i++) { c = c->next; - mhl_mem_free (h->current); + g_free (h->current); h->current = c; } - mhl_mem_free (h->title); - mhl_mem_free (h); + g_free (h->title); + g_free (h); do_refresh (); } diff --git a/src/dir.c b/src/dir.c index 597d0c1be..48aa58606 100644 --- a/src/dir.c +++ b/src/dir.c @@ -256,7 +256,7 @@ clean_dir (dir_list *list, int count) int i; for (i = 0; i < count; i++){ - mhl_mem_free (list->list [i].fname); + g_free (list->list [i].fname); list->list [i].fname = 0; } } @@ -473,9 +473,9 @@ alloc_dir_copy (int size) if (dir_copy.list){ for (i = 0; i < dir_copy.size; i++) { - mhl_mem_free (dir_copy.list [i].fname); + g_free (dir_copy.list [i].fname); } - mhl_mem_free (dir_copy.list); + g_free (dir_copy.list); dir_copy.list = 0; } diff --git a/src/ecs-test.c b/src/ecs-test.c index 963a63bf2..e7f64e5db 100644 --- a/src/ecs-test.c +++ b/src/ecs-test.c @@ -77,12 +77,12 @@ test_locale_en_US_UTF_8(void) valid = ecs_mbstr_to_str(&ecs, teststr_mb); assert(valid); assert(ecs_strlen(ecs) == 10); - mhl_mem_free(ecs); + g_free(ecs); valid = ecs_str_to_mbstr(&mbs, teststr_ecs); assert(valid); assert(strlen(mbs) == 11); - mhl_mem_free(mbs); + g_free(mbs); } #endif diff --git a/src/ecs.c b/src/ecs.c index a38c54e93..3fa3da63c 100644 --- a/src/ecs.c +++ b/src/ecs.c @@ -48,7 +48,7 @@ extern bool ecs_mbstr_to_str(ecs_char **ret_str, const char *s) str = g_new(ecs_char, maxlen + 1); len = mbstowcs(str, s, maxlen + 1); if (len == (size_t) -1) { - mhl_mem_free(str); + g_free(str); return FALSE; } @@ -72,7 +72,7 @@ extern bool ecs_str_to_mbstr(char **ret_str, const ecs_char *s) str = g_new(char, maxlen + 1); len = wcstombs(str, s, maxlen + 1); if (len == (size_t) -1) { - mhl_mem_free(str); + g_free(str); return FALSE; } diff --git a/src/ecs.h b/src/ecs.h index 98e9a9a92..9ba672cf7 100644 --- a/src/ecs.h +++ b/src/ecs.h @@ -49,7 +49,7 @@ typedef char ecs_char; /* * String conversion functions between the wide character encoding and * the multibyte encoding. The returned strings should be freed using - * mhl_mem_free after use. The return value is TRUE if the string is valid + * g_free after use. The return value is TRUE if the string is valid * and has been converted, FALSE otherwise. */ diff --git a/src/execute.c b/src/execute.c index ee56d81d5..c07c08453 100644 --- a/src/execute.c +++ b/src/execute.c @@ -164,7 +164,7 @@ do_execute (const char *shell, const char *command, int flags) #ifdef USE_VFS if (old_vfs_dir) { mc_chdir (old_vfs_dir); - mhl_mem_free (old_vfs_dir); + g_free (old_vfs_dir); } #endif /* USE_VFS */ @@ -198,7 +198,7 @@ shell_execute (const char *command, int flags) #endif /* HAVE_SUBSHELL_SUPPORT */ do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL); - mhl_mem_free (cmd); + g_free (cmd); } @@ -371,6 +371,6 @@ execute_with_vfs_arg (const char *command, const char *filename) do_execute (command, localcopy, EXECUTE_INTERNAL); mc_stat (localcopy, &st); mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime); - mhl_mem_free (localcopy); - mhl_mem_free (fn); + g_free (localcopy); + g_free (fn); } diff --git a/src/ext.c b/src/ext.c index 134411a02..ca63d06e7 100644 --- a/src/ext.c +++ b/src/ext.c @@ -54,7 +54,7 @@ static char *data = NULL; void flush_extension_file (void) { - mhl_mem_free (data); + g_free (data); data = NULL; } @@ -123,14 +123,14 @@ exec_extension (const char *filename, const char *data, int *move_dir, unlink (file_name); if (localcopy) { mc_ungetlocalcopy (filename, localcopy, 0); - mhl_mem_free (localcopy); + g_free (localcopy); } - mhl_mem_free (file_name); + g_free (file_name); return; } fputs (parameter, cmd_file); written_nonspace = 1; - mhl_mem_free (parameter); + g_free (parameter); } else { size_t len = strlen (prompt); @@ -158,7 +158,7 @@ exec_extension (const char *filename, const char *data, int *move_dir, data += i - 1; } else if ((i = check_format_var (data, &v)) > 0 && v) { fputs (v, cmd_file); - mhl_mem_free (v); + g_free (v); data += i; } else { char *text; @@ -169,7 +169,7 @@ exec_extension (const char *filename, const char *data, int *move_dir, if (localcopy == NULL) { fclose (cmd_file); unlink (file_name); - mhl_mem_free (file_name); + g_free (file_name); return; } mc_stat (localcopy, &mystat); @@ -186,7 +186,7 @@ exec_extension (const char *filename, const char *data, int *move_dir, strcpy (p, text); p = strchr (p, 0); } - mhl_mem_free (text); + g_free (text); written_nonspace = 1; } } @@ -217,7 +217,7 @@ exec_extension (const char *filename, const char *data, int *move_dir, if ((run_view && !written_nonspace) || is_cd) { unlink (file_name); - mhl_mem_free (file_name); + g_free (file_name); file_name = NULL; } else { /* Set executable flag on the command file ... */ @@ -276,14 +276,14 @@ exec_extension (const char *filename, const char *data, int *move_dir, } } - mhl_mem_free (file_name); - mhl_mem_free (cmd); + g_free (file_name); + g_free (cmd); if (localcopy) { mc_stat (localcopy, &mystat); mc_ungetlocalcopy (filename, localcopy, localmtime != mystat.st_mtime); - mhl_mem_free (localcopy); + g_free (localcopy); } } @@ -306,8 +306,8 @@ get_file_type_local (const char *filename, char *buf, int buflen) char *command = g_strconcat (FILE_CMD, tmp, " 2>/dev/null", (char *) 0); FILE *f = popen (command, "r"); - mhl_mem_free (tmp); - mhl_mem_free (command); + g_free (tmp); + g_free (command); if (f != NULL) { #ifdef __QNXNTO__ if (setvbuf (f, NULL, _IOFBF, 0) != 0) { @@ -388,7 +388,7 @@ regex_check_type (const char *filename, const char *ptr, int *have_type) /* No data */ content_string[0] = 0; } - mhl_mem_free (realname); + g_free (realname); } if (got_data == -1) { @@ -444,20 +444,20 @@ regex_command (const char *filename, const char *action, int *move_dir) extension_file = mhl_str_dir_plus_file (home_dir, MC_USER_EXT); if (!exist_file (extension_file)) { - mhl_mem_free (extension_file); + g_free (extension_file); check_stock_mc_ext: extension_file = mhl_str_dir_plus_file (mc_home, MC_LIB_EXT); mc_user_ext = 0; } data = load_file (extension_file); - mhl_mem_free (extension_file); + g_free (extension_file); if (data == NULL) return 0; if (!strstr (data, "default/")) { if (!strstr (data, "regex/") && !strstr (data, "shell/") && !strstr (data, "type/")) { - mhl_mem_free (data); + g_free (data); data = NULL; if (mc_user_ext) { home_error = 1; @@ -471,7 +471,7 @@ regex_command (const char *filename, const char *action, int *move_dir) "the installation failed. Please fetch a fresh " "copy from the Midnight Commander package."), mc_home); - mhl_mem_free (title); + g_free (title); return 0; } } @@ -483,7 +483,7 @@ regex_command (const char *filename, const char *action, int *move_dir) "changed with version 3.0. You may either want to copy " "it from %smc.ext or use that file as an example of how " "to write it."), MC_USER_EXT, mc_home); - mhl_mem_free (title); + g_free (title); } } mc_stat (filename, &mystat); @@ -596,7 +596,7 @@ regex_command (const char *filename, const char *action, int *move_dir) exec_extension (filename_copy, r + 1, move_dir, view_at_line_number); - mhl_mem_free (filename_copy); + g_free (filename_copy); ret = 1; } diff --git a/src/file.c b/src/file.c index 1a367eaf1..0b0a5038d 100644 --- a/src/file.c +++ b/src/file.c @@ -256,7 +256,7 @@ transform_source (FileOpContext *ctx, const char *source) *q = ' '; } p = do_transform_source (ctx, s); - mhl_mem_free (s); + g_free (s); return p; } @@ -267,7 +267,7 @@ free_linklist (struct link **linklist) for (lp = *linklist; lp != NULL; lp = lp2) { lp2 = lp->next; - mhl_mem_free (lp); + g_free (lp); } *linklist = NULL; } @@ -399,17 +399,17 @@ make_symlink (FileOpContext *ctx, const char *src_path, const char *dst_path) if (s) { s[1] = 0; s = g_strconcat (p, link_target, (char *) NULL); - mhl_mem_free (p); + g_free (p); g_strlcpy (link_target, s, sizeof (link_target)); - mhl_mem_free (s); + g_free (s); s = diff_two_paths (q, link_target); if (s) { g_strlcpy (link_target, s, sizeof (link_target)); - mhl_mem_free (s); + g_free (s); } } else - mhl_mem_free (p); - mhl_mem_free (q); + g_free (p); + g_free (q); } } retry_dst_symlink: @@ -760,7 +760,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: - mhl_mem_free (buf); + g_free (buf); while (src_desc != -1 && mc_close (src_desc) < 0) { temp_status = file_error ( @@ -898,7 +898,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, if (move_over) { if (mc_rename (s, d) == 0) { - mhl_mem_free (parent_dirs); + g_free (parent_dirs); return FILE_CONT; } } @@ -917,7 +917,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, _(" Destination \"%s\" must be a directory \n %s "), d); if (return_status == FILE_RETRY) goto retry_dst_stat; - mhl_mem_free (parent_dirs); + g_free (parent_dirs); return return_status; } /* Dive into subdir if exists */ @@ -981,12 +981,12 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, */ return_status = copy_dir_dir (ctx, path, mdpath, 0, 0, delete, parent_dirs, progress_count, progress_bytes); - mhl_mem_free (mdpath); + g_free (mdpath); } else { dest_file = mhl_str_dir_plus_file (dest_dir, x_basename (path)); return_status = copy_file_file (ctx, path, dest_file, 1, progress_count, progress_bytes, 0); - mhl_mem_free (dest_file); + g_free (dest_file); } if (delete && return_status == FILE_CONT) { if (ctx->erase_at_end) { @@ -1007,7 +1007,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, return_status = erase_file (ctx, path, 0, 0, 0); } } - mhl_mem_free (path); + g_free (path); } mc_closedir (reading); @@ -1019,8 +1019,8 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, } ret: - mhl_mem_free (dest_dir); - mhl_mem_free (parent_dirs); + g_free (dest_dir); + g_free (parent_dirs); return return_status; } @@ -1215,7 +1215,7 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d, if (return_status == FILE_RETRY) goto retry_dst_stat; } - mhl_mem_free (destdir); + g_free (destdir); return return_status; } @@ -1258,17 +1258,17 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d, erase_file (ctx, erase_list->name, 0, 0, 0); lp = erase_list; erase_list = erase_list->next; - mhl_mem_free (lp); + g_free (lp); } } erase_dir_iff_empty (ctx, s); ret: - mhl_mem_free (destdir); + g_free (destdir); while (erase_list) { lp = erase_list; erase_list = erase_list->next; - mhl_mem_free (lp); + g_free (lp); } return return_status; } @@ -1332,7 +1332,7 @@ recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count, continue; path = mhl_str_dir_plus_file (s, next->d_name); if (mc_lstat (path, &buf)) { - mhl_mem_free (path); + g_free (path); mc_closedir (reading); return 1; } @@ -1344,7 +1344,7 @@ recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count, else return_status = erase_file (ctx, path, progress_count, progress_bytes, 0); - mhl_mem_free (path); + g_free (path); } mc_closedir (reading); if (return_status != FILE_CONT) @@ -1526,7 +1526,7 @@ compute_dir_size (const char *dirname, off_t *ret_marked, double *ret_total) res = mc_lstat (fullname, &s); if (res != 0) { - mhl_mem_free (fullname); + g_free (fullname); continue; } @@ -1542,7 +1542,7 @@ compute_dir_size (const char *dirname, off_t *ret_marked, double *ret_total) (*ret_marked)++; *ret_total += s.st_size; } - mhl_mem_free (fullname); + g_free (fullname); } mc_closedir (dir); @@ -1583,7 +1583,7 @@ panel_compute_totals (WPanel *panel, off_t *ret_marked, double *ret_total) *ret_marked += subdir_count; *ret_total += subdir_bytes; - mhl_mem_free (dir_name); + g_free (dir_name); } else { (*ret_marked)++; *ret_total += s->st_size; @@ -1821,7 +1821,7 @@ panel_operate (void *source_panel, FileOperation operation, dest = file_mask_dialog (ctx, operation, cmd_buf, dest_dir_, single_entry, &do_bg); - mhl_mem_free(dest_dir_); + g_free(dest_dir_); if (!dest) { file_op_context_destroy (ctx); @@ -1829,7 +1829,7 @@ panel_operate (void *source_panel, FileOperation operation, } if (!*dest) { file_op_context_destroy (ctx); - mhl_mem_free (dest); + g_free (dest); return 0; } } @@ -1902,7 +1902,7 @@ panel_operate (void *source_panel, FileOperation operation, value = transform_error; } else { char *temp2 = mhl_str_dir_plus_file (dest, temp); - mhl_mem_free (dest); + g_free (dest); dest = temp2; temp = NULL; @@ -1978,7 +1978,7 @@ panel_operate (void *source_panel, FileOperation operation, src_stat = panel->dir.list[i].st; #ifdef WITH_FULL_PATHS - mhl_mem_free (source_with_path); + g_free (source_with_path); source_with_path = mhl_str_dir_plus_file (panel->cwd, source); #endif /* WITH_FULL_PATHS */ @@ -2033,7 +2033,7 @@ panel_operate (void *source_panel, FileOperation operation, /* Unknown file operation */ abort (); } - mhl_mem_free (temp2); + g_free (temp2); } } /* Copy or move operation */ @@ -2065,20 +2065,20 @@ panel_operate (void *source_panel, FileOperation operation, if (save_cwd) { mc_setctl (save_cwd, VFS_SETCTL_STALE_DATA, NULL); - mhl_mem_free (save_cwd); + g_free (save_cwd); } if (save_dest) { mc_setctl (save_dest, VFS_SETCTL_STALE_DATA, NULL); - mhl_mem_free (save_dest); + g_free (save_dest); } free_linklist (&linklist); free_linklist (&dest_dirs); #ifdef WITH_FULL_PATHS - mhl_mem_free (source_with_path); + g_free (source_with_path); #endif /* WITH_FULL_PATHS */ - mhl_mem_free (dest); - mhl_mem_free (ctx->dest_mask); + g_free (dest); + g_free (ctx->dest_mask); ctx->dest_mask = NULL; #ifdef WITH_BACKGROUND /* Let our parent know we are saying bye bye */ @@ -2172,7 +2172,7 @@ real_query_recursive (FileOpContext *ctx, enum OperationMode mode, const char *s if (ctx->recursive_result != RECURSIVE_ABORT) do_refresh (); - mhl_mem_free (text); + g_free (text); } switch (ctx->recursive_result) { diff --git a/src/filegui.c b/src/filegui.c index e7814aca0..40ed226d9 100644 --- a/src/filegui.c +++ b/src/filegui.c @@ -258,7 +258,7 @@ file_op_context_destroy_ui (FileOpContext *ctx) dlg_run_done (ui->op_dlg); destroy_dlg (ui->op_dlg); - mhl_mem_free (ui); + g_free (ui); } the_hint->widget.y = last_hint_line; @@ -906,10 +906,10 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, ask_file_mask: if ((val = quick_dialog_skip (&Quick_input, SKIP)) == B_CANCEL) { - mhl_mem_free (def_text_secure); + g_free (def_text_secure); return 0; } - mhl_mem_free (def_text_secure); + g_free (def_text_secure); if (ctx->follow_links) ctx->stat_func = mc_stat; @@ -930,7 +930,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, orig_mask = source_mask; if (!dest_dir || !*dest_dir) { - mhl_mem_free (source_mask); + g_free (source_mask); return dest_dir; } if (source_easy_patterns) { @@ -941,7 +941,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx); - mhl_mem_free (source_mask); + g_free (source_mask); } else error = re_compile_pattern (source_mask, strlen (source_mask), @@ -950,14 +950,14 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, if (error) { message (D_ERROR, MSG_ERROR, _("Invalid source pattern `%s' \n %s "), orig_mask, error); - mhl_mem_free (orig_mask); + g_free (orig_mask); goto ask_file_mask; } - mhl_mem_free (orig_mask); + g_free (orig_mask); tmpdest = dest_dir; dest_dir = tilde_expand(tmpdest); - mhl_mem_free(tmpdest); + g_free(tmpdest); ctx->dest_mask = strrchr (dest_dir, PATH_SEP); if (ctx->dest_mask == NULL) @@ -979,7 +979,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, *orig_mask = 0; } if (!*dest_dir) { - mhl_mem_free (dest_dir); + g_free (dest_dir); dest_dir = mhl_str_dup ("./"); } if (val == B_USER) diff --git a/src/filenot.c b/src/filenot.c index c3c2e949c..5cd6959f9 100644 --- a/src/filenot.c +++ b/src/filenot.c @@ -65,12 +65,12 @@ my_mkdir_rec (char *s, mode_t mode) p = mhl_str_dir_plus_file (s, ".."); q = vfs_canon (p); - mhl_mem_free (p); + g_free (p); if (!(result = my_mkdir_rec (q, mode))) result = mc_mkdir (s, mode); - mhl_mem_free (q); + g_free (q); return result; } @@ -85,7 +85,7 @@ my_mkdir (const char *s, mode_t mode) char *p = vfs_canon (s); result = my_mkdir_rec (p, mode); - mhl_mem_free (p); + g_free (p); } if (result == 0) { my_s = get_absolute_name (s); @@ -94,7 +94,7 @@ my_mkdir (const char *s, mode_t mode) tree_add_entry (tree, my_s); #endif - mhl_mem_free (my_s); + g_free (my_s); } return result; } @@ -117,7 +117,7 @@ my_rmdir (const char *s) tree_remove_entry (tree, my_s); #endif - mhl_mem_free (my_s); + g_free (my_s); } return result; } diff --git a/src/fileopctx.c b/src/fileopctx.c index cffda15a8..ad02cf4ae 100644 --- a/src/fileopctx.c +++ b/src/fileopctx.c @@ -25,8 +25,6 @@ #include -#include - #include "global.h" #include "fileopctx.h" @@ -79,5 +77,5 @@ file_op_context_destroy (FileOpContext *ctx) /* FIXME: do we need to free ctx->dest_mask? */ - mhl_mem_free (ctx); + g_free (ctx); } diff --git a/src/find.c b/src/find.c index bf95b7f35..023fc6862 100644 --- a/src/find.c +++ b/src/find.c @@ -309,14 +309,14 @@ find_parameters (char **start_dir, char **pattern, char **content) find_regex_flag = find_regex_cbox->state & C_BOOL; find_recursively = recursively_cbox->state & C_BOOL; destroy_dlg (find_dlg); - mhl_mem_free (in_start_dir); + g_free (in_start_dir); if (strcmp (temp_dir, ".") == 0) { - mhl_mem_free (temp_dir); + g_free (temp_dir); temp_dir = mhl_str_dup (current_panel->cwd); } in_start_dir = tree_box (temp_dir); if (in_start_dir) - mhl_mem_free (temp_dir); + g_free (temp_dir); else in_start_dir = temp_dir; /* Warning: Dreadful goto */ @@ -324,7 +324,7 @@ find_parameters (char **start_dir, char **pattern, char **content) break; default: - mhl_mem_free (in_contents); + g_free (in_contents); if (in_with->buffer[0]) { *content = mhl_str_dup (in_with->buffer); in_contents = mhl_str_dup (*content); @@ -340,9 +340,9 @@ find_parameters (char **start_dir, char **pattern, char **content) *start_dir = mhl_str_dup (in_start->buffer); *pattern = mhl_str_dup (in_name->buffer); - mhl_mem_free (in_start_dir); + g_free (in_start_dir); in_start_dir = mhl_str_dup (*start_dir); - mhl_mem_free (in_start_name); + g_free (in_start_name); in_start_name = mhl_str_dup (*pattern); } @@ -371,7 +371,7 @@ pop_directory (void) if (dir_stack_base){ name = dir_stack_base->name; next = dir_stack_base->prev; - mhl_mem_free (dir_stack_base); + g_free (dir_stack_base); dir_stack_base = next; return name; } else @@ -389,7 +389,7 @@ insert_file (const char *dir, const char *file) if (old_dir){ if (strcmp (old_dir, dir)){ - mhl_mem_free (old_dir); + g_free (old_dir); old_dir = mhl_str_dup (dir); dirname = add_to_list (dir, NULL); } @@ -400,7 +400,7 @@ insert_file (const char *dir, const char *file) tmp_name = g_strconcat (" ", file, (char *) NULL); add_to_list (tmp_name, dirname); - mhl_mem_free (tmp_name); + g_free (tmp_name); } static void @@ -522,12 +522,12 @@ search_content (Dlg_head *h, const char *directory, const char *filename) fname = mhl_str_dir_plus_file (directory, filename); if (mc_stat (fname, &s) != 0 || !S_ISREG (s.st_mode)){ - mhl_mem_free (fname); + g_free (fname); return 0; } file_fd = mc_open (fname, O_RDONLY); - mhl_mem_free (fname); + g_free (fname); if (file_fd == -1) return 0; @@ -563,7 +563,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename) if (found == 0){ /* Search in binary line once */ if (find_regex_flag) { if (regexec (r, p, 1, 0, 0) == 0){ - mhl_mem_free (p); + g_free (p); p = g_strdup_printf ("%d:%s", line, filename); find_add_match (h, directory, p); found = 1; @@ -580,7 +580,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename) line++; found = 0; } - mhl_mem_free (p); + g_free (p); if ((line & 0xff) == 0) { FindProgressStatus res; @@ -623,7 +623,7 @@ do_search (struct Dlg_head *h) mc_closedir (dirp); dirp = 0; } - mhl_mem_free (directory); + g_free (directory); directory = NULL; dp = 0; return 1; @@ -653,16 +653,16 @@ do_search (struct Dlg_head *h) char *temp_dir = g_strconcat (":", tmp, ":", (char *) NULL); found = strstr (find_ignore_dirs, temp_dir) != 0; - mhl_mem_free (temp_dir); + g_free (temp_dir); if (found) - mhl_mem_free (tmp); + g_free (tmp); else break; } else break; } - mhl_mem_free (directory); + g_free (directory); directory = tmp; if (verbose){ @@ -701,7 +701,7 @@ do_search (struct Dlg_head *h) push_directory (tmp_name); subdirs_left--; } - mhl_mem_free (tmp_name); + g_free (tmp_name); } if (regexp_match (find_pattern, dp->d_name, match_file)){ @@ -738,14 +738,14 @@ init_find_vars (void) { char *dir; - mhl_mem_free (old_dir); + g_free (old_dir); old_dir = 0; count = 0; matches = 0; /* Remove all the items in the stack */ while ((dir = pop_directory ()) != NULL) - mhl_mem_free (dir); + g_free (dir); } static char * @@ -779,7 +779,7 @@ find_do_view_edit (int unparsed_view, int edit, char *dir, char *file) do_edit_at_line (fullname, line); else view_file_at_line (fullname, unparsed_view, use_internal_view, line); - mhl_mem_free (fullname); + g_free (fullname); } static int @@ -979,7 +979,7 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname, /* Remove all the items in the stack */ while ((dir = pop_directory ()) != NULL) - mhl_mem_free (dir); + g_free (dir); get_list_info (&file_tmp, &dir_tmp); @@ -1014,18 +1014,18 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname, handle_path (list, name, &st, next_free, &link_to_dir, &stale_link); if (status == 0) { - mhl_mem_free (name); + g_free (name); continue; } if (status == -1) { - mhl_mem_free (name); + g_free (name); break; } /* don't add files more than once to the panel */ if (content_pattern && next_free > 0) { if (strcmp (list->list[next_free - 1].fname, name) == 0) { - mhl_mem_free (name); + g_free (name); continue; } } @@ -1062,7 +1062,7 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname, kill_gui (); do_search (0); /* force do_search to release resources */ - mhl_mem_free (old_dir); + g_free (old_dir); old_dir = 0; return return_value; @@ -1081,8 +1081,8 @@ do_find (void) dirname = filename = NULL; is_start = 0; v = find_file (start_dir, pattern, content, &dirname, &filename); - mhl_mem_free (start_dir); - mhl_mem_free (pattern); + g_free (start_dir); + g_free (pattern); if (find_regex_flag && r) regfree (r); @@ -1097,14 +1097,14 @@ do_find (void) do_cd (filename, cd_exact); select_item (current_panel); } - mhl_mem_free (dirname); - mhl_mem_free (filename); + g_free (dirname); + g_free (filename); break; } - mhl_mem_free (content); + g_free (content); dir_and_file_set = dirname && filename; - mhl_mem_free (dirname); - mhl_mem_free (filename); + g_free (dirname); + g_free (filename); if (v == B_CANCEL) break; diff --git a/src/help.c b/src/help.c index efdf220d9..f27c503b6 100644 --- a/src/help.c +++ b/src/help.c @@ -129,7 +129,7 @@ search_string (const char *start, const char *text) } } cleanup: - mhl_mem_free (local_text); + g_free (local_text); return result; } @@ -329,7 +329,7 @@ static void clear_link_areas (void) while (link_area){ current = link_area; link_area = current -> next; - mhl_mem_free (current); + g_free (current); } inside_link_area = 0; } @@ -755,7 +755,7 @@ static void interactive_display_finish (void) { clear_link_areas (); - mhl_mem_free (data); + g_free (data); } void @@ -776,7 +776,7 @@ interactive_display (const char *filename, const char *node) } if (!filename) - mhl_mem_free (hlpfile); + g_free (hlpfile); if (!data) return; diff --git a/src/hotlist.c b/src/hotlist.c index a54a0b5c5..d80f489fe 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -201,7 +201,7 @@ update_path_name (void) else label_set_text (movelist_group, name_trunc (p, dlg->cols - (UX * 2 + 4))); - mhl_mem_free (p); + g_free (p); dlg_redraw (dlg); } @@ -211,7 +211,7 @@ do { \ int i; \ \ if ((i = strlen (current->label) + 3) > buflen) { \ - mhl_mem_free (buf); \ + g_free (buf); \ buf = g_malloc (buflen = 1024 * (i/1024 + 1)); \ } \ buf[0] = '\0'; \ @@ -465,7 +465,7 @@ hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm) char *tmp = g_strconcat ("cd ", hlp->directory, (char *) NULL); stuff (cmdline, tmp, 0); - mhl_mem_free (tmp); + g_free (tmp); dlg_stop (h); h->ret_value = B_CANCEL; return MSG_HANDLED; @@ -688,7 +688,7 @@ init_movelist (int list_type, struct hotlist *item) movelist_dlg = create_dlg (0, 0, LINES - 6, movelist_cols, dialog_colors, hotlist_callback, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE); - mhl_mem_free (hdr); + g_free (hdr); for (i = 0; i < BUTTONS; i++) { if (hotlist_but[i].type & list_type) @@ -813,7 +813,7 @@ add2hotlist (char *label, char *directory, enum HotListType type, int pos) char *lbl = g_strconcat ("->", new->label, (char *) NULL); listbox_add_item (l_hotlist, pos, 0, lbl, new); - mhl_mem_free (lbl); + g_free (lbl); } else listbox_add_item (l_hotlist, pos, 0, new->label, new); listbox_select_entry (l_hotlist, l_hotlist->current); @@ -939,13 +939,13 @@ static void add_new_entry_cmd (void) ret = add_new_entry_input (_("New hotlist entry"), _("Directory label"), _("Directory path"), "[Hotlist]", &title, &url); - mhl_mem_free (to_free); + g_free (to_free); if (!ret) return; if (!title || !*title || !url || !*url) { - mhl_mem_free (title); - mhl_mem_free (url); + g_free (title); + g_free (url); return; } @@ -1046,11 +1046,11 @@ void add2hotlist_cmd (void) prompt = g_strdup_printf (cp, path_trunc (current_panel->cwd, COLS-2*UX-(l+8))); label = input_dialog (_(" Add to hotlist "), prompt, MC_HISTORY_HOTLIST_ADD, label_string); - mhl_mem_free (prompt); + g_free (prompt); if (!label || !*label) { - mhl_mem_free (label_string); - mhl_mem_free (label); + g_free (label_string); + g_free (label); return; } add2hotlist (label, label_string, HL_TYPE_ENTRY, 0); @@ -1067,9 +1067,9 @@ static void remove_group (struct hotlist *grp) if (current->type == HL_TYPE_GROUP) remove_group (current); - mhl_mem_free (current->label); - mhl_mem_free (current->directory); - mhl_mem_free (current); + g_free (current->label); + g_free (current->directory); + g_free (current); current = next; } @@ -1096,7 +1096,7 @@ static void remove_from_hotlist (struct hotlist *entry) _("\n Are you sure you want to remove this entry?"), D_ERROR, 2, _("&Yes"), _("&No")); - mhl_mem_free (title); + g_free (title); if (result != 0) return; @@ -1114,7 +1114,7 @@ static void remove_from_hotlist (struct hotlist *entry) result = query_dialog (header, _("\n Group not empty.\n Remove it?"), D_ERROR, 2, _("&Yes"), _("&No")); - mhl_mem_free (header); + g_free (header); if (result != 0) return; @@ -1125,9 +1125,9 @@ static void remove_from_hotlist (struct hotlist *entry) unlink_entry (entry); - mhl_mem_free (entry->label); - mhl_mem_free (entry->directory); - mhl_mem_free (entry); + g_free (entry->label); + g_free (entry->directory); + g_free (entry); /* now remove list entry from screen */ listbox_remove_current (l_hotlist, 1); hotlist_state.modified = 1; @@ -1185,7 +1185,7 @@ load_group (struct hotlist *grp) profile_keys = profile_iterator_next (profile_keys, &key, &value); add2hotlist (mhl_str_dup (value), mhl_str_dup (key), HL_TYPE_GROUP, 0); } - mhl_mem_free (group_section); + g_free (group_section); profile_keys = profile_init_iterator (grp->directory, profile_name); @@ -1429,7 +1429,7 @@ clean_up_hotlist_groups (const char *section) } profile_clean_section (grp_section, profile_name); } - mhl_mem_free (grp_section); + g_free (grp_section); } @@ -1574,7 +1574,7 @@ int save_hotlist (void) hotlist_state.modified = 0; } else rename (fbak, hotlist_file_name); - mhl_mem_free (fbak); + g_free (fbak); } return saved; @@ -1588,20 +1588,20 @@ void done_hotlist (void) { if (hotlist){ remove_group (hotlist); - mhl_mem_free (hotlist->label); - mhl_mem_free (hotlist->directory); - mhl_mem_free (hotlist); + g_free (hotlist->label); + g_free (hotlist->directory); + g_free (hotlist); hotlist = 0; } hotlist_state.loaded = 0; - mhl_mem_free (hotlist_file_name); + g_free (hotlist_file_name); hotlist_file_name = 0; l_hotlist = 0; current_group = 0; if (tkn_buf){ - mhl_mem_free (tkn_buf); + g_free (tkn_buf); tkn_buf_length = 0; tkn_length = 0; tkn_buf = NULL; diff --git a/src/key.c b/src/key.c index 1434fa7dd..f2b6bf3b1 100644 --- a/src/key.c +++ b/src/key.c @@ -155,7 +155,7 @@ void delete_select_channel (int fd) else select_list = p_next; - mhl_mem_free (p); + g_free (p); p = p_next; continue; } @@ -1398,7 +1398,7 @@ static void k_dispose (key_def *k) return; k_dispose (k->child); k_dispose (k->next); - mhl_mem_free (k); + g_free (k); } static void s_dispose (SelectList *sel) @@ -1407,7 +1407,7 @@ static void s_dispose (SelectList *sel) return; s_dispose (sel->next); - mhl_mem_free (sel); + g_free (sel); } void done_key () diff --git a/src/layout.c b/src/layout.c index 33f58cc26..8e1d10d38 100644 --- a/src/layout.c +++ b/src/layout.c @@ -26,6 +26,7 @@ #include #include #include + #include #include @@ -1053,13 +1054,13 @@ void swap_panels () if (panels [0].type == view_listing) { if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) { - mhl_mem_free (panel1->panel_name); + g_free (panel1->panel_name); panel1->panel_name = mhl_str_dup (get_nth_panel_name (1)); } } if (panels [1].type == view_listing) { if (!strcmp (panel2->panel_name, get_nth_panel_name (1))) { - mhl_mem_free (panel2->panel_name); + g_free (panel2->panel_name); panel2->panel_name = mhl_str_dup (get_nth_panel_name (0)); } } diff --git a/src/learn.c b/src/learn.c index 2be4b8c12..93208834f 100644 --- a/src/learn.c +++ b/src/learn.c @@ -25,12 +25,11 @@ #include #include #include + #include #include #include -#include - #include "global.h" #include "tty.h" #include "win.h" @@ -89,7 +88,7 @@ _("Please press the %s\n" _(key_name_conv_tab [action - B_USER].longname)); mc_refresh (); if (learnkeys [action - B_USER].sequence != NULL) { - mhl_mem_free (learnkeys [action - B_USER].sequence); + g_free (learnkeys [action - B_USER].sequence); learnkeys [action - B_USER].sequence = NULL; } seq = learn_key (); @@ -118,7 +117,7 @@ _("Please press the %s\n" _(" You have entered \"%s\""), seq); } - mhl_mem_free (seq); + g_free (seq); } dlg_run_done (d); @@ -328,7 +327,7 @@ learn_save (void) if (profile_changed) sync_profiles (); - mhl_mem_free (section); + g_free (section); } void learn_keys (void) diff --git a/src/listmode.c b/src/listmode.c index 0cfcbf6c6..84af11321 100644 --- a/src/listmode.c +++ b/src/listmode.c @@ -290,7 +290,7 @@ listmode_edit (char *oldlistformat) s = mhl_str_dup (oldlistformat); listmode_dlg = init_listmode (s); - mhl_mem_free (s); + g_free (s); if (run_dlg (listmode_dlg) == B_ENTER) { newformat = collect_new_format (); diff --git a/src/logging.c b/src/logging.c index a48dcfb79..6dc80948a 100644 --- a/src/logging.c +++ b/src/logging.c @@ -46,7 +46,7 @@ is_logging_enabled(void) mc_ini = g_strdup_printf("%s/%s", home_dir, PROFILE_NAME); logging_enabled = get_int(mc_ini, "development.enable_logging", FALSE); - mhl_mem_free(mc_ini); + g_free(mc_ini); logging_initialized = TRUE; } return logging_enabled; @@ -68,6 +68,6 @@ mc_log(const char *fmt, ...) (void)vfprintf(f, fmt, args); (void)fclose(f); } - mhl_mem_free(logfilename); + g_free(logfilename); } } diff --git a/src/main.c b/src/main.c index a04d2915b..138c0357c 100644 --- a/src/main.c +++ b/src/main.c @@ -302,7 +302,7 @@ reload_panelized (WPanel *panel) do_file_mark (panel, i, 0); } if (mc_lstat (list->list[i].fname, &list->list[i].st)) { - mhl_mem_free (list->list[i].fname); + g_free (list->list[i].fname); continue; } if (list->list[i].f.marked) @@ -350,7 +350,7 @@ update_one_panel_widget (WPanel *panel, int force_update, panel->dirty = 1; if (free_pointer) - mhl_mem_free (my_current_file); + g_free (my_current_file); } void @@ -590,11 +590,11 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type) if (mc_chdir (directory) == -1) { strcpy (panel->cwd, olddir); - mhl_mem_free (olddir); - mhl_mem_free (translated_url); + g_free (olddir); + g_free (translated_url); return 0; } - mhl_mem_free (translated_url); + g_free (translated_url); /* Success: save previous directory, shutdown status of previous dir */ strcpy (panel->lwd, olddir); @@ -617,7 +617,7 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type) panel->dirty = 1; update_xterm_title_path (); - mhl_mem_free (olddir); + g_free (olddir); return 1; } @@ -688,7 +688,7 @@ directory_history_list (WPanel *panel) directory_history_add (panel, panel->cwd); else message (D_ERROR, MSG_ERROR, _("Cannot change directory")); - mhl_mem_free (s); + g_free (s); } #ifdef HAVE_SUBSHELL_SUPPORT @@ -777,7 +777,7 @@ treebox_cmd (void) sel_dir = tree_box (selection (current_panel)->fname); if (sel_dir) { do_cd (sel_dir, cd_exact); - mhl_mem_free (sel_dir); + g_free (sel_dir); } } @@ -794,7 +794,7 @@ listmode_cmd (void) if (!newmode) return; - mhl_mem_free (current_panel->user_format); + g_free (current_panel->user_format); current_panel->list_type = list_user; current_panel->user_format = newmode; set_panel_formats (current_panel); @@ -1036,7 +1036,7 @@ translated_mc_chdir (char *dir) newdir = vfs_translate_url (dir); mc_chdir (newdir); - mhl_mem_free (newdir); + g_free (newdir); } static void @@ -1142,7 +1142,7 @@ copy_readlink (WPanel *panel) int i; i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1); - mhl_mem_free (p); + g_free (p); if (i > 0) { buffer[i] = 0; command_insert (cmdline, buffer, 1); @@ -1622,7 +1622,7 @@ update_xterm_title_path (void) numeric_keypad_mode (); fprintf (stdout, "\33]0;mc - %s\7", p); fflush (stdout); - mhl_mem_free (p); + g_free (p); } } @@ -1646,7 +1646,7 @@ load_hint (int force) if ((hint = get_random_hint (force))) { if (*hint) set_hintbar (hint); - mhl_mem_free (hint); + g_free (hint); } else { char text[BUF_SMALL]; @@ -1714,7 +1714,7 @@ mc_maybe_editor_or_viewer (void) char *path = NULL; path = prepend_cwd_on_local (view_one_file); view_file (path, 0, 1); - mhl_mem_free (path); + g_free (path); } #ifdef USE_INTERNAL_EDIT else { @@ -2079,7 +2079,7 @@ handle_args (int argc, char *argv[]) edit_one_file = fname; edit_one_file_start_line = atoi (p); } else { - mhl_mem_free (fname); + g_free (fname); goto try_plus_filename; } } else { @@ -2248,15 +2248,15 @@ main (int argc, char *argv[]) close (last_wd_fd); } } - mhl_mem_free (last_wd_string); + g_free (last_wd_string); - mhl_mem_free (mc_home); + g_free (mc_home); done_key (); #ifdef HAVE_CHARSET free_codepages_list (); #endif - mhl_mem_free (this_dir); - mhl_mem_free (other_dir); + g_free (this_dir); + g_free (other_dir); return 0; } diff --git a/src/menu.c b/src/menu.c index 09e91e3d3..16ad77333 100644 --- a/src/menu.c +++ b/src/menu.c @@ -533,9 +533,9 @@ menubar_arrange(WMenu* menubar) void destroy_menu (Menu *menu) { - mhl_mem_free (menu->name); - mhl_mem_free (menu->help_node); - mhl_mem_free (menu); + g_free (menu->name); + g_free (menu->help_node); + g_free (menu); } WMenu * diff --git a/src/panelize.c b/src/panelize.c index b2902d283..7cb8c4e9f 100644 --- a/src/panelize.c +++ b/src/panelize.c @@ -234,7 +234,7 @@ add2panelize_cmd (void) if (!label) return; if (!*label) { - mhl_mem_free (label); + g_free (label); return; } @@ -256,9 +256,9 @@ static void remove_from_panelize (struct panelize *entry) } } - mhl_mem_free (entry->label); - mhl_mem_free (entry->command); - mhl_mem_free (entry); + g_free (entry->label); + g_free (entry->command); + g_free (entry); } } @@ -298,7 +298,7 @@ external_panelize (void) char *cmd = mhl_str_dup (target); destroy_dlg (panelize_dlg); do_external_panelize (cmd); - mhl_mem_free (cmd); + g_free (cmd); repaint_screen (); return; } @@ -352,9 +352,9 @@ void done_panelize (void) for (; current; current = next){ next = current->next; - mhl_mem_free (current->label); - mhl_mem_free (current->command); - mhl_mem_free (current); + g_free (current->label); + g_free (current->command); + g_free (current); } } diff --git a/src/profile.c b/src/profile.c index 7ae367b16..2877ebbc0 100644 --- a/src/profile.c +++ b/src/profile.c @@ -250,7 +250,7 @@ static TSecHeader *load (const char *file) break; case OnSecHeader: { /* Broken initialization file */ TSecHeader *link = SecHeader->link; - mhl_mem_free (SecHeader); + g_free (SecHeader); SecHeader = link; fprintf (stderr, "Warning: Corrupted initialization file `%s'\n", file); @@ -300,7 +300,7 @@ GetSetProfileChar (int set, const char *AppName, const char *KeyName, if ( g_strcasecmp (key->KeyName, KeyName)) continue; if (set){ - mhl_mem_free (key->Value); + g_free (key->Value); key->Value = mhl_str_dup (Default); } return key->Value; @@ -384,7 +384,7 @@ static void dump_keys (FILE * profile, TKeys * p) dump_keys (profile, p->link); t = str_untranslate_newline_dup (p->Value); fprintf (profile, "%s=%s\n", p->KeyName, t); - mhl_mem_free (t); + g_free (t); } static void dump_sections (FILE *profile, TSecHeader *p) @@ -427,9 +427,9 @@ static void free_keys (TKeys *p) if (!p) return; free_keys (p->link); - mhl_mem_free (p->KeyName); - mhl_mem_free (p->Value); - mhl_mem_free (p); + g_free (p->KeyName); + g_free (p->Value); + g_free (p); } static void free_sections (TSecHeader *p) @@ -438,10 +438,10 @@ static void free_sections (TSecHeader *p) return; free_sections (p->link); free_keys (p->Keys); - mhl_mem_free (p->AppName); + g_free (p->AppName); p->link = 0; p->Keys = 0; - mhl_mem_free (p); + g_free (p); } static void free_profile (TProfile *p) @@ -450,8 +450,8 @@ static void free_profile (TProfile *p) return; free_profile (p->link); free_sections (p->Section); - mhl_mem_free (p->FileName); - mhl_mem_free (p); + g_free (p->FileName); + g_free (p); } void free_profile_name (const char *s) diff --git a/src/rxvt.c b/src/rxvt.c index d75ba0519..da658f2e5 100644 --- a/src/rxvt.c +++ b/src/rxvt.c @@ -21,11 +21,10 @@ #include #include #include + #include #include -#include - #include "global.h" #include "tty.h" /* move, addch */ #include "cons.saver.h" @@ -114,6 +113,6 @@ void show_rxvt_contents (int starty, unsigned char y1, unsigned char y2) move (starty + (i / cols), 0); addch (is_printable (k[i]) ? k[i] : ' '); } - mhl_mem_free (k); + g_free (k); } diff --git a/src/screen.c b/src/screen.c index b2d569793..c52d292ce 100644 --- a/src/screen.c +++ b/src/screen.c @@ -133,7 +133,7 @@ delete_format (format_e *format) while (format){ next = format->next; - mhl_mem_free (format); + g_free (format); format = next; } } @@ -713,7 +713,7 @@ display_mini_info (WPanel *panel) link = mhl_str_dir_plus_file (panel->cwd, panel->dir.list [panel->selected].fname); len = mc_readlink (link, link_target, MC_MAXPATHLEN - 1); - mhl_mem_free (link); + g_free (link); if (len > 0){ link_target[len] = 0; tty_printf ("-> %-*s", panel->widget.cols - 5, @@ -798,7 +798,7 @@ show_dir (WPanel *panel) trim (strip_home_and_password (panel->cwd), tmp, max (panel->widget.cols - 9, 0)); addstr (tmp); - mhl_mem_free (tmp); + g_free (tmp); addch (' '); widget_move (&panel->widget, 0, 1); @@ -894,7 +894,7 @@ do_try_to_select (WPanel *panel, const char *name) for (i = 0; i < panel->count; i++){ if (strcmp (subdir, panel->dir.list [i].fname) == 0) { do_select (panel, i); - mhl_mem_free (subdir); + g_free (subdir); return; } } @@ -902,7 +902,7 @@ do_try_to_select (WPanel *panel, const char *name) /* Try to select a file near the file that is missing */ if (panel->selected >= panel->count) do_select (panel, panel->count-1); - mhl_mem_free (subdir); + g_free (subdir); } void @@ -966,21 +966,21 @@ panel_destroy (WPanel *p) history_put (p->hist_name, p->dir_history); p->dir_history = g_list_first (p->dir_history); - g_list_foreach (p->dir_history, (GFunc) mhl_mem_free, NULL); + g_list_foreach (p->dir_history, (GFunc) g_free, NULL); g_list_free (p->dir_history); } - mhl_mem_free (p->hist_name); + g_free (p->hist_name); delete_format (p->format); delete_format (p->status_format); - mhl_mem_free (p->user_format); + g_free (p->user_format); for (i = 0; i < LIST_TYPES; i++) - mhl_mem_free (p->user_status_format[i]); - mhl_mem_free (p->dir.list); - mhl_mem_free (p->panel_name); - mhl_mem_free (name); + g_free (p->user_status_format[i]); + g_free (p->dir.list); + g_free (p->panel_name); + g_free (name); } static void @@ -1041,11 +1041,11 @@ panel_new (const char *panel_name) panel->frame_size = frame_half; section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL); if (!profile_has_section (section, profile_name)) { - mhl_mem_free (section); + g_free (section); section = mhl_str_dup (panel->panel_name); } panel_load_setup (panel, section); - mhl_mem_free (section); + g_free (section); /* Load format strings */ err = set_panel_formats (panel); @@ -1328,7 +1328,7 @@ parse_display_format (WPanel *panel, const char *format, char **error, int issta delete_format (home); tmp_format [pos] = 0; *error = g_strconcat (_("Unknown tag on display format: "), tmp_format, (char *) NULL); - mhl_mem_free (tmp_format); + g_free (tmp_format); return 0; } total_cols += darr->requested_field_len; @@ -1417,7 +1417,7 @@ set_panel_formats (WPanel *p) form = use_display_format (p, panel_format (p), &err, 0); if (err){ - mhl_mem_free (err); + g_free (err); retcode = 1; } else { @@ -1432,7 +1432,7 @@ set_panel_formats (WPanel *p) form = use_display_format (p, mini_status_format (p), &err, 1); if (err){ - mhl_mem_free (err); + g_free (err); retcode += 2; } else { @@ -1449,11 +1449,11 @@ set_panel_formats (WPanel *p) if (retcode) message( 1, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) ); if (retcode & 0x01){ - mhl_mem_free (p->user_format); + g_free (p->user_format); p->user_format = mhl_str_dup (DEFAULT_USER_FORMAT); } if (retcode & 0x02){ - mhl_mem_free (p->user_status_format [p->list_type]); + g_free (p->user_status_format [p->list_type]); p->user_status_format [p->list_type] = mhl_str_dup (DEFAULT_USER_FORMAT); } @@ -1978,10 +1978,10 @@ do_enter_on_file_entry (file_entry *fe) /* Check if the file is executable */ full_name = mhl_str_dir_plus_file (current_panel->cwd, fe->fname); if (!is_exe (fe->st.st_mode) || !if_link_is_exe (full_name, fe)) { - mhl_mem_free (full_name); + g_free (full_name); return 0; } - mhl_mem_free (full_name); + g_free (full_name); if (confirm_execute) { if (query_dialog @@ -1997,7 +1997,7 @@ do_enter_on_file_entry (file_entry *fe) tmp = mhl_str_dir_plus_file (vfs_get_current_dir (), fe->fname); ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL); - mhl_mem_free (tmp); + g_free (tmp); /* We took action only if the dialog was shown or the execution * was successful */ return confirm_execute || (ret == 0); @@ -2007,9 +2007,9 @@ do_enter_on_file_entry (file_entry *fe) { char *tmp = name_quote (fe->fname, 0); char *cmd = g_strconcat (".", PATH_SEP_STR, tmp, (char *) NULL); - mhl_mem_free (tmp); + g_free (tmp); shell_execute (cmd, 0); - mhl_mem_free (cmd); + g_free (cmd); } return 1; @@ -2045,7 +2045,7 @@ chdir_other_panel (WPanel *panel) move_down (panel); - mhl_mem_free (new_dir); + g_free (new_dir); } /* @@ -2109,7 +2109,7 @@ chdir_to_readlink (WPanel *panel) move_down (panel); - mhl_mem_free (new_dir); + g_free (new_dir); } } @@ -2256,7 +2256,7 @@ panel_callback (Widget *w, widget_msg_t msg, int parm) char *cwd = strip_password (mhl_str_dup (panel->cwd), 1); message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "), cwd, unix_error_string (errno)); - mhl_mem_free(cwd); + g_free(cwd); } else subshell_chdir (panel->cwd); @@ -2476,7 +2476,7 @@ panel_re_sort (WPanel *panel) break; } } - mhl_mem_free (filename); + g_free (filename); panel->top_file = panel->selected - ITEMS (panel)/2; if (panel->top_file < 0) panel->top_file = 0; @@ -2499,7 +2499,7 @@ panel_set_sort_order (WPanel *panel, sortfn *sort_order) current_file = mhl_str_dup (panel->dir.list [panel->selected].fname); panel_reload (panel); try_to_select (panel, current_file); - mhl_mem_free (current_file); + g_free (current_file); } panel_re_sort (panel); } diff --git a/src/setup.c b/src/setup.c index eaa86a7d7..221bd8836 100644 --- a/src/setup.c +++ b/src/setup.c @@ -294,7 +294,7 @@ save_layout (void) save_string ("Layout", layout [i].opt_name, buffer, profile); } - mhl_mem_free (profile); + g_free (profile); } void @@ -314,7 +314,7 @@ save_configure (void) set_config_string (profile, str_options[i].opt_name, *str_options[i].opt_addr); - mhl_mem_free (profile); + g_free (profile); } static void @@ -381,7 +381,7 @@ save_setup (void) get_codepage_id( display_codepage ), profile_name ); #endif /* HAVE_CHARSET */ - mhl_mem_free (profile); + g_free (profile); saving_setup = 0; } @@ -414,12 +414,12 @@ panel_load_setup (WPanel *panel, const char *section) } /* User formats */ - mhl_mem_free (panel->user_format); + g_free (panel->user_format); panel->user_format = mhl_str_dup (get_profile_string (section, "user_format", DEFAULT_USER_FORMAT, profile_name)); for (i = 0; i < LIST_TYPES; i++){ - mhl_mem_free (panel->user_status_format [i]); + g_free (panel->user_status_format [i]); snprintf (buffer, sizeof (buffer), "user_status%d", i); panel->user_status_format [i] = mhl_str_dup (get_profile_string (section, buffer, @@ -472,7 +472,7 @@ do_load_string (const char *s, const char *ss, const char *def) load_string (s, ss, def, buffer, BUF_SMALL); p = mhl_str_dup (buffer); - mhl_mem_free (buffer); + g_free (buffer); return p; } #endif /* !USE_NETCODE */ @@ -490,10 +490,10 @@ setup_init (void) if (!exist_file (profile)){ inifile = mhl_str_dir_plus_file (mc_home, "mc.ini"); if (exist_file (inifile)){ - mhl_mem_free (profile); + g_free (profile); profile = inifile; } else - mhl_mem_free (inifile); + g_free (inifile); } profile_name = profile; @@ -543,7 +543,7 @@ load_setup (void) if (vfs_file_is_local (buffer)) other_dir = buffer; else - mhl_mem_free (buffer); + g_free (buffer); } boot_current_is_left = @@ -604,8 +604,8 @@ load_anon_passwd () void done_setup (void) { - mhl_mem_free (profile_name); - mhl_mem_free (global_profile_name); + g_free (profile_name); + g_free (global_profile_name); done_hotlist (); done_panelize (); /* directory_history_free (); */ @@ -624,7 +624,7 @@ load_keys_from_section (const char *terminal, const char *profile_name) section_name = g_strconcat ("terminal:", terminal, (char *) NULL); profile_keys = profile_init_iterator (section_name, profile_name); - mhl_mem_free (section_name); + g_free (section_name); while (profile_keys){ profile_keys = profile_iterator_next (profile_keys, &key, &value); @@ -638,7 +638,7 @@ load_keys_from_section (const char *terminal, const char *profile_name) if (key_code){ valcopy = convert_controls (value); define_sequence (key_code, valcopy, MCKEY_NOACTION); - mhl_mem_free (valcopy); + g_free (valcopy); } } } diff --git a/src/subshell.c b/src/subshell.c index 2f2f9bfa0..c6015e504 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -673,8 +673,8 @@ exit_subshell (void) tcsh_fifo, unix_error_string (errno)); } - mhl_mem_free (subshell_prompt); - mhl_mem_free (pty_buffer); + g_free (subshell_prompt); + g_free (pty_buffer); subshell_prompt = NULL; pty_buffer = NULL; } @@ -765,7 +765,7 @@ do_subshell_chdir (const char *directory, int do_update, int reset_prompt) char *temp = subshell_name_quote (directory); if (temp) { write_all (subshell_pty, temp, strlen (temp)); - mhl_mem_free (temp); + g_free (temp); } else { /* Should not happen unless the directory name is so long that we don't have memory to quote it. */ @@ -801,7 +801,7 @@ do_subshell_chdir (const char *directory, int do_update, int reset_prompt) if (bPathNotEq && strcmp (current_panel->cwd, ".")) { char *cwd = strip_password (mhl_str_dup (current_panel->cwd), 1); fprintf (stderr, _("Warning: Cannot change to %s.\n"), cwd); - mhl_mem_free (cwd); + g_free (cwd); } } diff --git a/src/tree.c b/src/tree.c index 8ff94ef15..580cfc4a1 100644 --- a/src/tree.c +++ b/src/tree.c @@ -33,8 +33,6 @@ #include #include -#include - #include "global.h" #include "tty.h" #include "color.h" @@ -128,7 +126,7 @@ static void tree_destroy (WTree *tree) tree_store_remove_entry_remove_hook (remove_callback); save_tree (tree); - mhl_mem_free (tree->tree_shown); + g_free (tree->tree_shown); tree->tree_shown = 0; tree->selected_ptr = NULL; } @@ -208,7 +206,7 @@ static void show_tree (WTree *tree) x = y = 1; } - mhl_mem_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++) @@ -607,7 +605,7 @@ static void tree_copy (WTree *tree, const char *default_dest) return; if (!*dest){ - mhl_mem_free (dest); + g_free (dest); return; } @@ -616,7 +614,7 @@ static void tree_copy (WTree *tree, const char *default_dest) copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes); file_op_context_destroy (ctx); - mhl_mem_free (dest); + g_free (dest); } static void @@ -648,19 +646,19 @@ static void tree_move (WTree *tree, const char *default_dest) if (!dest) return; if (!*dest){ - mhl_mem_free (dest); + g_free (dest); return; } if (stat (dest, &buf)){ message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "), unix_error_string (errno)); - mhl_mem_free (dest); + g_free (dest); return; } if (!S_ISDIR (buf.st_mode)){ file_error (_(" Destination \"%s\" must be a directory \n %s "), dest); - mhl_mem_free (dest); + g_free (dest); return; } @@ -669,7 +667,7 @@ static void tree_move (WTree *tree, const char *default_dest) move_dir_dir (ctx, tree->selected_ptr->name, dest, &count, &bytes); file_op_context_destroy (ctx); - mhl_mem_free (dest); + g_free (dest); } static void @@ -718,7 +716,7 @@ tree_rmdir_cmd (WTree *tree) tree->selected_ptr->name); result = query_dialog (_(" Delete "), buf, D_ERROR, 2, _("&Yes"), _("&No")); - mhl_mem_free (buf); + g_free (buf); if (result != 0) return; } diff --git a/src/treestore.c b/src/treestore.c index cb08cb2db..64c4323a4 100644 --- a/src/treestore.c +++ b/src/treestore.c @@ -239,7 +239,7 @@ tree_store_load_from(char *name) } strcpy(oldname, name); } - mhl_mem_free(name); + g_free(name); } fclose(file); } @@ -270,7 +270,7 @@ tree_store_load(void) name = mhl_str_dir_plus_file(home_dir, MC_TREE); retval = tree_store_load_from(name); - mhl_mem_free(name); + g_free(name); return retval; } @@ -337,12 +337,12 @@ tree_store_save_to(char *name) i = fprintf(file, "%d:%d %s\n", current->scanned, common, encoded); - mhl_mem_free(encoded); + g_free(encoded); } else { char *encoded = encode(current->name); i = fprintf(file, "%d:%s\n", current->scanned, encoded); - mhl_mem_free(encoded); + g_free(encoded); } if (i == EOF) { @@ -378,15 +378,15 @@ tree_store_save(void) retval = tree_store_save_to(tmp); if (retval) { - mhl_mem_free(tmp); + g_free(tmp); return retval; } name = mhl_str_dir_plus_file(home_dir, MC_TREE); retval = rename(tmp, name); - mhl_mem_free(tmp); - mhl_mem_free(name); + g_free(tmp); + g_free(name); if (retval) return errno; @@ -484,7 +484,7 @@ tree_store_add_entry(const char *name) break; } } - mhl_mem_free(parent); + g_free(parent); } tree_store_dirty(TRUE); @@ -549,8 +549,8 @@ remove_entry(tree_entry * entry) ts.tree_last = entry->prev; /* Free the memory used by the entry */ - mhl_mem_free(entry->name); - mhl_mem_free(entry); + g_free(entry->name); + g_free(entry); return ret; } @@ -620,7 +620,7 @@ tree_store_mark_checked(const char *subname) current = tree_store_add_entry(name); ts.add_queue = g_list_prepend(ts.add_queue, mhl_str_dup(name)); } - mhl_mem_free(name); + g_free(name); /* Clear the deletion mark from the subdirectory and its children */ base = current; @@ -719,11 +719,11 @@ tree_store_end_check(void) ts.add_queue = g_list_reverse(ts.add_queue); the_queue = ts.add_queue; ts.add_queue = NULL; - mhl_mem_free(ts.check_name); + g_free(ts.check_name); ts.check_name = NULL; for (l = the_queue; l; l = l->next) { - mhl_mem_free(l->data); + g_free(l->data); } g_list_free(the_queue); @@ -743,7 +743,7 @@ process_special_dirs(GList ** special_dirs, char *file) *special_dirs = g_list_prepend(*special_dirs, mhl_str_dup(token)); s = NULL; } - mhl_mem_free(buffer); + g_free(buffer); } static bool @@ -803,7 +803,7 @@ tree_store_rescan(const char *dir) if (S_ISDIR(buf.st_mode)) tree_store_mark_checked(dp->d_name); } - mhl_mem_free(full_name); + g_free(full_name); } mc_closedir(dirp); } diff --git a/src/user.c b/src/user.c index 8f670eaab..e0a551c1d 100644 --- a/src/user.c +++ b/src/user.c @@ -145,7 +145,7 @@ int check_format_var (const char *p, char **v) var_name = g_strndup (p + 4, dots-2 - (p+3)); value = getenv (var_name); - mhl_mem_free (var_name); + g_free (var_name); if (value){ *v = mhl_str_dup (value); return q-p; @@ -224,7 +224,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) qstr = (*quote_func) (cwd, 0); - mhl_mem_free (cwd); + g_free (cwd); return qstr; } @@ -241,7 +241,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) if (edit_widget) { char *file = g_strconcat (home_dir, PATH_SEP_STR BLOCK_FILE, (char *) NULL); fname = (*quote_func) (file, 0); - mhl_mem_free (file); + g_free (file); return fname; } else if (c_lc == 'b') { return strip_ext ((*quote_func) (fname, 0)); @@ -281,7 +281,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) if (panel->dir.list[i].f.marked) { strcat (block, tmp = (*quote_func) (panel->dir.list[i].fname, 0)); - mhl_mem_free (tmp); + g_free (tmp); strcat (block, " "); if (c_lc == 'u') do_file_mark (panel, i, 0); @@ -471,7 +471,7 @@ debug_out (char *start, char *end, int cond) } debug_flag = 0; - mhl_mem_free (msg); + g_free (msg); msg = NULL; } else { const char *type; @@ -495,7 +495,7 @@ debug_out (char *start, char *end, int cond) else p = g_strdup_printf ("%s%s%.*s \n", msg ? msg : "", type, (int) (end - start), start); - mhl_mem_free (msg); + g_free (msg); msg = p; } } @@ -613,15 +613,15 @@ execute_menu_command (WEdit *edit_widget, const char *commands) /* User canceled */ fclose (cmd_file); unlink (file_name); - mhl_mem_free (file_name); + g_free (file_name); return; } if (do_quote) { fputs (tmp = name_quote (parameter, 0), cmd_file); - mhl_mem_free (tmp); + g_free (tmp); } else fputs (parameter, cmd_file); - mhl_mem_free (parameter); + g_free (parameter); parameter = 0; } else { if (parameter < &prompt [sizeof (prompt) - 1]) { @@ -640,7 +640,7 @@ execute_menu_command (WEdit *edit_widget, const char *commands) else{ char *text = expand_format (edit_widget, *commands, do_quote); fputs (text, cmd_file); - mhl_mem_free (text); + g_free (text); } } else { if (*commands == '%') { @@ -666,10 +666,10 @@ execute_menu_command (WEdit *edit_widget, const char *commands) * on no-exec filesystems. */ char *cmd = g_strconcat("/bin/sh ", file_name, (char *)NULL); shell_execute (cmd, EXECUTE_HIDE); - mhl_mem_free(cmd); + g_free(cmd); } unlink (file_name); - mhl_mem_free (file_name); + g_free (file_name); } /* @@ -723,11 +723,11 @@ user_menu_cmd (struct WEdit *edit_widget) menu = mhl_str_dup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU); if (!exist_file (menu) || !menu_file_own (menu)){ - mhl_mem_free (menu); + g_free (menu); menu = mhl_str_dir_plus_file \ (home_dir, edit_widget ? CEDIT_HOME_MENU : MC_HOME_MENU); if (!exist_file (menu)){ - mhl_mem_free (menu); + g_free (menu); menu = mhl_str_dir_plus_file \ (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); } @@ -736,7 +736,7 @@ user_menu_cmd (struct WEdit *edit_widget) if ((data = load_file (menu)) == NULL){ message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "), menu, unix_error_string (errno)); - mhl_mem_free (menu); + g_free (menu); menu = NULL; return; } @@ -841,9 +841,9 @@ user_menu_cmd (struct WEdit *edit_widget) } easy_patterns = old_patterns; - mhl_mem_free (menu); + g_free (menu); menu = NULL; - mhl_mem_free (entries); - mhl_mem_free (data); + g_free (entries); + g_free (data); } diff --git a/src/util.c b/src/util.c index dc0346813..5e8a79cdc 100644 --- a/src/util.c +++ b/src/util.c @@ -271,7 +271,7 @@ path_trunc (const char *path, size_t trunc_len) { char *secure_path = strip_password (mhl_str_dup (path), 1); ret = name_trunc (secure_path, trunc_len); - mhl_mem_free (secure_path); + g_free (secure_path); return ret; } @@ -602,12 +602,12 @@ regexp_match (const char *pattern, const char *string, int match_type) if (!old_pattern || STRCOMP (old_pattern, pattern) || old_type != match_type){ if (old_pattern){ regfree (&r); - mhl_mem_free (old_pattern); + g_free (old_pattern); old_pattern = NULL; } my_pattern = convert_pattern (pattern, match_type, 0); if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS)) { - mhl_mem_free (my_pattern); + g_free (my_pattern); return -1; } old_pattern = my_pattern; @@ -682,7 +682,7 @@ load_file (const char *filename) if (read_size > 0) return data; else { - mhl_mem_free (data); + g_free (data); return 0; } } @@ -701,7 +701,7 @@ load_mc_home_file (const char *filename, char **allocated_filename) data = load_file (hintfile); if (!data) { - mhl_mem_free (hintfile); + g_free (hintfile); /* Fall back to the two-letter language code */ if (lang[0] && lang[1]) lang[2] = 0; @@ -709,21 +709,21 @@ load_mc_home_file (const char *filename, char **allocated_filename) data = load_file (hintfile); if (!data) { - mhl_mem_free (hintfile); + g_free (hintfile); hintfile = hintfile_base; data = load_file (hintfile_base); } } - mhl_mem_free (lang); + g_free (lang); if (hintfile != hintfile_base) - mhl_mem_free (hintfile_base); + g_free (hintfile_base); if (allocated_filename) *allocated_filename = hintfile; else - mhl_mem_free (hintfile); + g_free (hintfile); return data; } @@ -853,7 +853,7 @@ unix_error_string (int error_num) strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, NULL, NULL, NULL); snprintf (buffer, sizeof (buffer), "%s (%d)", strerror_currentlocale, error_num); - mhl_mem_free(strerror_currentlocale); + g_free(strerror_currentlocale); #else snprintf (buffer, sizeof (buffer), "%s (%d)", g_strerror (error_num), error_num); @@ -938,12 +938,12 @@ get_current_wd (char *buffer, int size) len = strlen(p) + 1; if (len > size) { - mhl_mem_free (p); + g_free (p); return NULL; } memcpy (buffer, p, len); - mhl_mem_free (p); + g_free (p); return buffer; } @@ -1049,7 +1049,7 @@ execute_hooks (Hook *hook_list) for (hook_list = p; hook_list;){ p = hook_list; hook_list = hook_list->next; - mhl_mem_free (p); + g_free (p); } } @@ -1063,7 +1063,7 @@ delete_hook (Hook **hook_list, void (*hook_fn)(void *)) for (current = *hook_list; current; current = next){ next = current->next; if (current->hook_fn == hook_fn) - mhl_mem_free (current); + g_free (current); else add_hook (&new_list, current->hook_fn, current->hook_data); } @@ -1090,7 +1090,7 @@ wipe_password (char *passwd) return; for (;*p ; p++) *p = 0; - mhl_mem_free (passwd); + g_free (passwd); } /* Convert "\E" -> esc character and ^x to control-x key and ^^ to ^ key */ @@ -1155,8 +1155,8 @@ resolve_symlinks (const char *path) c = *q; *q = 0; if (mc_lstat (path, &mybuf) < 0) { - mhl_mem_free (buf); - mhl_mem_free (buf2); + g_free (buf); + g_free (buf2); *q = c; return NULL; } @@ -1165,8 +1165,8 @@ resolve_symlinks (const char *path) else { len = mc_readlink (path, buf2, MC_MAXPATHLEN - 1); if (len < 0) { - mhl_mem_free (buf); - mhl_mem_free (buf2); + g_free (buf); + g_free (buf2); *q = c; return NULL; } @@ -1191,7 +1191,7 @@ resolve_symlinks (const char *path) strcpy (buf, PATH_SEP_STR); else if (*(r - 1) == PATH_SEP && r != buf + 1) *(r - 1) = 0; - mhl_mem_free (buf2); + g_free (buf2); return buf; } @@ -1209,7 +1209,7 @@ diff_two_paths (const char *first, const char *second) return NULL; my_second = resolve_symlinks (second); if (my_second == NULL) { - mhl_mem_free (my_first); + g_free (my_first); return NULL; } for (j = 0; j < 2; j++) { @@ -1235,10 +1235,10 @@ diff_two_paths (const char *first, const char *second) currlen = (i + 1) * 3 + strlen (q) + 1; if (j) { if (currlen < prevlen) - mhl_mem_free (buf); + g_free (buf); else { - mhl_mem_free (my_first); - mhl_mem_free (my_second); + g_free (my_first); + g_free (my_second); return buf; } } @@ -1248,8 +1248,8 @@ diff_two_paths (const char *first, const char *second) strcpy (p, "../"); strcpy (p, q); } - mhl_mem_free (my_first); - mhl_mem_free (my_second); + g_free (my_first); + g_free (my_second); return buf; } @@ -1271,7 +1271,7 @@ list_append_unique (GList *list, char *text) while (link) { newlink = g_list_previous (link); if (!strcmp ((char *) link->data, text)) { - mhl_mem_free (link->data); + g_free (link->data); g_list_remove_link (list, link); g_list_free_1 (link); } @@ -1290,7 +1290,7 @@ list_append_unique (GList *list, char *text) /* * Arguments: - * pname (output) - pointer to the name of the temp file (needs mhl_mem_free). + * pname (output) - pointer to the name of the temp file (needs g_free). * NULL if the function fails. * prefix - part of the filename before the random part. * Prepend $TMPDIR or /tmp if there are no path separators. @@ -1321,7 +1321,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix) tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, (char *) NULL); *pname = tmpname; XXXXXX = &tmpname[strlen (tmpbase)]; - mhl_mem_free (tmpbase); + g_free (tmpbase); /* Get some more or less random data. */ gettimeofday (&tv, NULL); @@ -1358,7 +1358,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix) } /* Unsuccessful. Free the filename. */ - mhl_mem_free (tmpname); + g_free (tmpname); *pname = NULL; return -1; @@ -1383,7 +1383,7 @@ load_file_position (const char *filename, long *line, long *column) /* open file with positions */ fn = mhl_str_dir_plus_file (home_dir, MC_FILEPOS); f = fopen (fn, "r"); - mhl_mem_free (fn); + g_free (fn); if (!f) return; @@ -1434,8 +1434,8 @@ save_file_position (const char *filename, long line, long column) /* open temporary file */ t = fopen (tmp, "w"); if (!t) { - mhl_mem_free (tmp); - mhl_mem_free (fn); + g_free (tmp); + g_free (fn); return; } @@ -1462,8 +1462,8 @@ save_file_position (const char *filename, long line, long column) fclose (t); rename (tmp, fn); - mhl_mem_free (tmp); - mhl_mem_free (fn); + g_free (tmp); + g_free (fn); } extern const char * diff --git a/src/utilunix.c b/src/utilunix.c index 5dfa18ece..c322ef09a 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -75,7 +75,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) { - mhl_mem_free (cache [*last].string); + g_free (cache [*last].string); cache [*last].string = mhl_str_dup (text); cache [*last].index = id; *last = ((*last)+1) % size; @@ -206,7 +206,7 @@ tilde_expand (const char *directory) name = g_strndup (p, q - p); passwd = getpwnam (name); q++; - mhl_mem_free (name); + g_free (name); } } @@ -296,7 +296,7 @@ mc_tmpdir (void) /* Test if sys_tmp is suitable for temporary files */ fallback_prefix = g_strdup_printf ("%s/mctest", sys_tmp); test_fd = mc_mkstemps (&test_fn, fallback_prefix, NULL); - mhl_mem_free (fallback_prefix); + g_free (fallback_prefix); if (test_fd != -1) { close (test_fd); test_fd = open (test_fn, O_RDONLY); diff --git a/src/view.c b/src/view.c index dcd35596c..cd255cf18 100644 --- a/src/view.c +++ b/src/view.c @@ -349,7 +349,7 @@ view_hexedit_free_change_list (WView *view) for (curr = view->change_list; curr != NULL; curr = next) { next = curr->next; - mhl_mem_free (curr); + g_free (curr); } view->change_list = NULL; view->dirty++; @@ -375,8 +375,8 @@ view_growbuf_free (WView *view) assert (view->growbuf_in_use); for (i = 0; i < view->growbuf_blocks; i++) - mhl_mem_free (view->growbuf_blockptr[i]); - mhl_mem_free (view->growbuf_blockptr); + g_free (view->growbuf_blockptr[i]); + g_free (view->growbuf_blockptr); view->growbuf_blockptr = NULL; view->growbuf_in_use = FALSE; } @@ -416,12 +416,12 @@ view_growbuf_read_until (WView *view, offset_type ofs) byte *newblock = g_try_malloc (VIEW_PAGE_SIZE); byte **newblocks = g_try_malloc (sizeof (*newblocks) * (view->growbuf_blocks + 1)); if (!newblock || !newblocks) { - mhl_mem_free (newblock); - mhl_mem_free (newblocks); + g_free (newblock); + g_free (newblocks); return; } memcpy (newblocks, view->growbuf_blockptr, sizeof (*newblocks) * view->growbuf_blocks); - mhl_mem_free (view->growbuf_blockptr); + g_free (view->growbuf_blockptr); view->growbuf_blockptr = newblocks; view->growbuf_blockptr[view->growbuf_blocks++] = newblock; view->growbuf_lastindex = 0; @@ -708,11 +708,11 @@ view_close_datasource (WView *view) case DS_FILE: (void) mc_close (view->ds_file_fd); view->ds_file_fd = -1; - mhl_mem_free (view->ds_file_data); + g_free (view->ds_file_data); view->ds_file_data = NULL; break; case DS_STRING: - mhl_mem_free (view->ds_string_data); + g_free (view->ds_string_data); view->ds_string_data = NULL; break; default: @@ -1400,8 +1400,8 @@ view_toggle_magic_mode (WView *view) view_done (view); view_load (view, command, filename, 0); - mhl_mem_free (filename); - mhl_mem_free (command); + g_free (filename); + g_free (command); view->dpy_bbar_dirty = TRUE; view->dirty++; } @@ -1419,7 +1419,7 @@ view_done (WView *view) canon_fname = vfs_canon (view->filename); view_offset_to_coord (view, &line, &col, view->dpy_start); save_file_position (canon_fname, line + 1, col); - mhl_mem_free (canon_fname); + g_free (canon_fname); } /* Write back the global viewer mode */ @@ -1432,8 +1432,8 @@ view_done (WView *view) /* view->widget needs no destructor */ - mhl_mem_free (view->filename), view->filename = NULL; - mhl_mem_free (view->command), view->command = NULL; + g_free (view->filename), view->filename = NULL; + g_free (view->command), view->command = NULL; view_close_datasource (view); /* the growing buffer is freed with the datasource */ @@ -1547,7 +1547,7 @@ view_load (WView *view, const char *command, const char *file, type = get_compression_type (fd); if (view->magic_mode && (type != COMPRESSION_NONE)) { - mhl_mem_free (view->filename); + g_free (view->filename); view->filename = g_strconcat (file, decompress_extension (type), (char *) NULL); } view_set_datasource_file (view, fd, &st); @@ -1570,7 +1570,7 @@ view_load (WView *view, const char *command, const char *file, canon_fname = vfs_canon (file); load_file_position (file, &line, &col); - mhl_mem_free (canon_fname); + g_free (canon_fname); view_moveto (view, offset_doz(line, 1), col); } else if (start_line > 0) { view_moveto (view, start_line - 1, 0); @@ -2166,7 +2166,7 @@ view_hexedit_save_changes (WView *view) view->change_list = next; view->dirty++; view_set_byte (view, curr->offset, curr->value); - mhl_mem_free (curr); + g_free (curr); } if (mc_close (fp) == -1) { @@ -2174,7 +2174,7 @@ view_hexedit_save_changes (WView *view) message (D_ERROR, _(" Save file "), _(" Error while closing the file: \n %s \n" " Data may have been written or not. "), error); - mhl_mem_free (error); + g_free (error); } view_update (view); return TRUE; @@ -2182,12 +2182,12 @@ view_hexedit_save_changes (WView *view) save_error: error = mhl_str_dup (strerror (errno)); text = g_strdup_printf (_(" Cannot save file: \n %s "), error); - mhl_mem_free (error); + g_free (error); (void) mc_close (fp); answer = query_dialog (_(" Save file "), text, D_ERROR, 2, _("&Retry"), _("&Cancel")); - mhl_mem_free (text); + g_free (text); if (answer == 0) goto retry_save; @@ -2392,7 +2392,7 @@ search (WView *view, char *text, view->update_activate = 0; enable_interrupt_key (); - for (;; mhl_mem_free (s)) { + for (;; g_free (s)) { if (p >= view->update_activate) { view->update_activate += view->update_steps; if (verbose) { @@ -2411,7 +2411,7 @@ search (WView *view, char *text, search_status = (*search) (view, text, s + 1, match_normal); if (search_status < 0) { - mhl_mem_free (s); + g_free (s); break; } @@ -2439,7 +2439,7 @@ search (WView *view, char *text, view->dpy_start = t; } - mhl_mem_free (s); + g_free (s); break; } disable_interrupt_key (); @@ -2600,7 +2600,7 @@ hex_search (WView *view, const char *text) /* No valid bytes in the user input */ if (block_len <= 0 || parse_error) { message (D_NORMAL, _("Search"), _("Invalid hex search expression")); - mhl_mem_free (buffer); + g_free (buffer); view->search_length = 0; return; } @@ -2608,7 +2608,7 @@ hex_search (WView *view, const char *text) /* Then start the search */ pos = block_search (view, buffer, block_len); - mhl_mem_free (buffer); + g_free (buffer); if (pos == INVALID_OFFSET) { message (D_NORMAL, _("Search"), _(" Search string not found ")); @@ -2640,7 +2640,7 @@ regexp_view_search (WView *view, char *pattern, char *string, || old_type != match_type) { if (old_pattern != NULL) { regfree (&r); - mhl_mem_free (old_pattern); + g_free (old_pattern); old_pattern = 0; } for (i = 0; pattern[i] != '\0'; i++) { @@ -2744,7 +2744,7 @@ view_moveto_line_cmd (WView *view) if (*answer_end == '\0' && errno == 0 && line >= 1) view_moveto (view, line - 1, 0); } - mhl_mem_free (answer); + g_free (answer); view->dirty++; view_update (view); } @@ -2768,7 +2768,7 @@ view_moveto_addr_cmd (WView *view) message (D_ERROR, _("Warning"), _(" Invalid address ")); } } - mhl_mem_free (line); + g_free (line); } view->dirty++; view_update (view); @@ -2793,11 +2793,11 @@ regexp_search (WView *view, int direction) regexp = input_dialog (_("Search"), _(" Enter regexp:"), MC_HISTORY_VIEW_SEARCH_REGEX, defval); if (regexp == NULL || regexp[0] == '\0') { - mhl_mem_free (regexp); + g_free (regexp); return; } - mhl_mem_free (last_regexp); + g_free (last_regexp); view->search_exp = last_regexp = regexp; view->direction = direction; @@ -2866,7 +2866,7 @@ view_normal_search_cmd (WView *view) convert_from_input (exp); - mhl_mem_free (last_search_string); + g_free (last_search_string); view->search_exp = last_search_string = exp; exp = NULL; @@ -2875,8 +2875,8 @@ view_normal_search_cmd (WView *view) view->last_search = do_normal_search; cleanup: - mhl_mem_free (exp); - mhl_mem_free (defval); + g_free (exp); + g_free (defval); } static void diff --git a/src/widget.c b/src/widget.c index 31afab692..9a6eb191b 100644 --- a/src/widget.c +++ b/src/widget.c @@ -190,7 +190,7 @@ button_callback (Widget *w, widget_msg_t msg, int parm) return MSG_HANDLED; case WIDGET_DESTROY: - mhl_mem_free (b->text); + g_free (b->text); return MSG_HANDLED; default: @@ -283,7 +283,7 @@ button_get_text (WButton *b) void button_set_text (WButton *b, const char *text) { - mhl_mem_free (b->text); + g_free (b->text); b->text = mhl_str_dup (text); b->widget.cols = button_len (text, b->flags); button_scan_hotkey(b); @@ -476,7 +476,7 @@ check_callback (Widget *w, widget_msg_t msg, int parm) return MSG_HANDLED; case WIDGET_DESTROY: - mhl_mem_free (c->text); + g_free (c->text); return MSG_HANDLED; default: @@ -588,7 +588,7 @@ label_callback (Widget *w, widget_msg_t msg, int parm) } case WIDGET_DESTROY: - mhl_mem_free (l->text); + g_free (l->text); return MSG_HANDLED; default: @@ -604,7 +604,7 @@ label_set_text (WLabel *label, const char *text) if (label->text && text && !strcmp (label->text, text)) return; /* Flickering is not nice */ - mhl_mem_free (label->text); + g_free (label->text); if (text){ label->text = mhl_str_dup (text); @@ -880,7 +880,7 @@ history_get (const char *input_name) hist = list_append_unique (hist, mhl_str_dup (this_entry)); } - mhl_mem_free (profile); + g_free (profile); /* return pointer to the last entry in the list */ hist = g_list_last (hist); @@ -913,7 +913,7 @@ history_put (const char *input_name, GList *h) /* Make sure the history is only readable by the user */ if (chmod (profile, S_IRUSR | S_IWUSR) == -1 && errno != ENOENT) { - mhl_mem_free (profile); + g_free (profile); return; } @@ -942,7 +942,7 @@ history_put (const char *input_name, GList *h) } } - mhl_mem_free (profile); + g_free (profile); } /* }}} history saving and loading */ @@ -1053,7 +1053,7 @@ static void do_show_hist (WInput * in) r = show_hist (in->history, in->widget.x, in->widget.y); if (r) { assign_text (in, r); - mhl_mem_free (r); + g_free (r); } } @@ -1074,13 +1074,13 @@ input_destroy (WInput *in) history_put (in->history_name, in->history); in->history = g_list_first (in->history); - g_list_foreach (in->history, (GFunc) mhl_mem_free, NULL); + g_list_foreach (in->history, (GFunc) g_free, NULL); g_list_free (in->history); } - mhl_mem_free (in->buffer); + g_free (in->buffer); free_completions (in); - mhl_mem_free (in->history_name); + g_free (in->history_name); } void @@ -1301,7 +1301,7 @@ copy_region (WInput *in, int x_first, int x_last) if (last == first) return; - mhl_mem_free (kill_buffer); + g_free (kill_buffer); kill_buffer = g_strndup(in->buffer+first,last-first); } @@ -1382,7 +1382,7 @@ yank (WInput *in) static void kill_line (WInput *in) { - mhl_mem_free (kill_buffer); + g_free (kill_buffer); kill_buffer = mhl_str_dup (&in->buffer [in->point]); in->buffer [in->point] = 0; } @@ -1391,7 +1391,7 @@ void assign_text (WInput *in, const char *text) { free_completions (in); - mhl_mem_free (in->buffer); + g_free (in->buffer); in->buffer = mhl_str_dup (text); /* was in->buffer->text */ in->current_max_len = strlen (in->buffer) + 1; in->point = strlen (in->buffer); @@ -1857,8 +1857,8 @@ listbox_remove_list (WListbox *l) while (l->count--) { q = p->next; - mhl_mem_free (p->text); - mhl_mem_free (p); + g_free (p->text); + g_free (p); p = q; } l->pos = l->count = 0; @@ -1899,8 +1899,8 @@ listbox_remove_current (WListbox *l, int force) l->list = l->top = l->current = 0; } - mhl_mem_free (p->text); - mhl_mem_free (p); + g_free (p->text); + g_free (p); } /* Makes *e the selected entry (sets current and pos) */ @@ -2022,8 +2022,8 @@ listbox_destroy (WListbox *l) for (i = 0; i < l->count; i++){ n = p->next; - mhl_mem_free (p->text); - mhl_mem_free (p); + g_free (p->text); + g_free (p); p = n; } } @@ -2338,7 +2338,7 @@ buttonbar_callback (Widget *w, widget_msg_t msg, int parm) case WIDGET_DESTROY: for (i = 0; i < 10; i++) - mhl_mem_free (bb->labels[i].text); + g_free (bb->labels[i].text); return MSG_HANDLED; default: @@ -2385,7 +2385,7 @@ buttonbar_new (int visible) static void set_label_text (WButtonBar * bb, int index, const char *text) { - mhl_mem_free (bb->labels[index - 1].text); + g_free (bb->labels[index - 1].text); bb->labels[index - 1].text = mhl_str_dup (text); } @@ -2484,7 +2484,7 @@ groupbox_callback (Widget *w, widget_msg_t msg, int parm) return MSG_HANDLED; case WIDGET_DESTROY: - mhl_mem_free (g->title); + g_free (g->title); return MSG_HANDLED; default: @@ -2507,7 +2507,7 @@ groupbox_new (int x, int y, int width, int height, const char *title) char *t; t = g_strstrip (mhl_str_dup (title)); g->title = g_strconcat (" ", t, " ", (char *) NULL); - mhl_mem_free (t); + g_free (t); } return g; diff --git a/src/wtools.c b/src/wtools.c index 099066988..295adfab1 100644 --- a/src/wtools.c +++ b/src/wtools.c @@ -89,7 +89,7 @@ int run_listbox (Listbox *l) else val = l->list->pos; destroy_dlg (l->dlg); - mhl_mem_free (l); + g_free (l); return val; } @@ -209,7 +209,7 @@ do_create_message (int flags, const char *title, const char *text) query_dialog (title, p, flags, 0); d = last_query_dlg; init_dlg (d); - mhl_mem_free (p); + g_free (p); return d; } @@ -231,7 +231,7 @@ create_message (int flags, const char *title, const char *text, ...) va_end (args); d = do_create_message (flags, title, p); - mhl_mem_free (p); + g_free (p); return d; } @@ -261,7 +261,7 @@ bg_message (int dummy, int *flags, char *title, const char *text) (void) dummy; title = g_strconcat (_("Background process:"), " ", title, (char *) NULL); fg_message (*flags, title, text); - mhl_mem_free (title); + g_free (title); } #endif /* WITH_BACKGROUND */ @@ -288,7 +288,7 @@ message (int flags, const char *title, const char *text, ...) #endif /* WITH_BACKGROUND */ fg_message (flags, title, p); - mhl_mem_free (p); + g_free (p); } @@ -415,7 +415,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip) } return_val = dd->ret_value; destroy_dlg (dd); - mhl_mem_free (widgets); + g_free (widgets); return return_val; } @@ -516,7 +516,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help, Quick_input.widgets = quick_widgets; ret = quick_dialog (&Quick_input); - mhl_mem_free (p_text); + g_free (p_text); if (ret != B_CANCEL) { return my_str; @@ -563,7 +563,7 @@ input_expand_dialog (const char *header, const char *text, result = input_dialog (header, text, history_name, def_text); if (result) { expanded = tilde_expand (result); - mhl_mem_free (result); + g_free (result); return expanded; } return result; diff --git a/src/x11conn.c b/src/x11conn.c index 85059321a..09a135f84 100644 --- a/src/x11conn.c +++ b/src/x11conn.c @@ -35,9 +35,8 @@ typedef int dummy; /* C99 forbids empty compilation unit */ #else #include -#include -#include +#include #include "../src/global.h" @@ -135,7 +134,7 @@ static bool x11_available(void) if (x11_module == NULL) x11_module = g_module_open ("libX11.so.6", G_MODULE_BIND_LAZY); - mhl_mem_free (x11_module_fname); + g_free (x11_module_fname); if (x11_module == NULL) return FALSE; diff --git a/vfs/cpio.c b/vfs/cpio.c index deccfd895..ee1a7daf7 100644 --- a/vfs/cpio.c +++ b/vfs/cpio.c @@ -147,7 +147,7 @@ static void cpio_free_archive(struct vfs_class *me, struct vfs_s_super *super) super->u.arch.fd = -1; for (l = super->u.arch.deferred; l; l = lnext) { lnext = l->next; - mhl_mem_free (l); + g_free (l); } super->u.arch.deferred = NULL; } @@ -178,10 +178,10 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, s = g_strconcat (name, decompress_extension (type), (char *) NULL); if ((fd = mc_open (s, O_RDONLY)) == -1) { message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s); - mhl_mem_free (s); + g_free (s); return -1; } - mhl_mem_free (s); + g_free (s); } super->u.arch.fd = fd; @@ -294,7 +294,7 @@ static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe } name = g_malloc(u.buf.c_namesize); if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) { - mhl_mem_free(name); + g_free(name); return STATUS_EOF; } name[u.buf.c_namesize - 1] = '\0'; @@ -302,7 +302,7 @@ static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe cpio_skip_padding(super); if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */ - mhl_mem_free(name); + g_free(name); return STATUS_TRAIL; } @@ -353,7 +353,7 @@ static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup name = g_malloc(hd.c_namesize); if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 || (unsigned long) len < hd.c_namesize) { - mhl_mem_free (name); + g_free (name); return STATUS_EOF; } name[hd.c_namesize - 1] = '\0'; @@ -361,7 +361,7 @@ static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup cpio_skip_padding(super); if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */ - mhl_mem_free(name); + g_free(name); return STATUS_TRAIL; } @@ -418,7 +418,7 @@ static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *supe name = g_malloc(hd.c_namesize); if((len = mc_read (super->u.arch.fd, name, hd.c_namesize)) == -1 || (unsigned long) len < hd.c_namesize) { - mhl_mem_free (name); + g_free (name); return STATUS_EOF; } name[hd.c_namesize - 1] = '\0'; @@ -426,7 +426,7 @@ static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *supe cpio_skip_padding(super); if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */ - mhl_mem_free(name); + g_free(name); return STATUS_TRAIL; } @@ -549,7 +549,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, if (mc_read (super->u.arch.fd, inode->linkname, st->st_size) < st->st_size) { inode->linkname[0] = 0; - mhl_mem_free (name); + g_free (name); return STATUS_EOF; } inode->linkname[st->st_size] = 0; /* Linkname stored without terminating \0 !!! */ @@ -561,7 +561,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, } /* !entry */ - mhl_mem_free (name); + g_free (name); return STATUS_OK; } diff --git a/vfs/direntry.c b/vfs/direntry.c index e49616677..6c4c55a91 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -99,14 +99,14 @@ vfs_s_free_inode (struct vfs_class *me, struct vfs_s_inode *ino) } CALL (free_inode) (me, ino); - mhl_mem_free (ino->linkname); + g_free (ino->linkname); if (ino->localname){ unlink (ino->localname); - mhl_mem_free(ino->localname); + g_free(ino->localname); } total_inodes--; ino->super->ino_usage--; - mhl_mem_free(ino); + g_free(ino); } else ino->st.st_nlink--; } @@ -119,7 +119,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent) ent->next->prevp = ent->prevp; } - mhl_mem_free (ent->name); + g_free (ent->name); ent->name = NULL; if (ent->ino){ @@ -129,7 +129,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent) } total_entries--; - mhl_mem_free(ent); + g_free(ent); } void @@ -231,14 +231,14 @@ vfs_s_resolve_symlink (struct vfs_class *me, struct vfs_s_entry *entry, if (fullpath) { fullname = g_strconcat (fullpath, "/", linkname, NULL); linkname = fullname; - mhl_mem_free (fullpath); + g_free (fullpath); } } target = (MEDATA->find_entry) (me, entry->dir->super->root, linkname, follow - 1, 0); - mhl_mem_free (fullname); + g_free (fullname); return target; } @@ -262,7 +262,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root, path++; if (!path[0]) { - mhl_mem_free (pathref); + g_free (pathref); return ent; } @@ -293,7 +293,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root, root = ent->ino; } cleanup: - mhl_mem_free (pathref); + g_free (pathref); return NULL; } @@ -340,7 +340,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root, if (save) *save = PATH_SEP; retval = vfs_s_find_entry_tree (me, ino, name, follow, flags); - mhl_mem_free (path); + g_free (path); return retval; } @@ -365,7 +365,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root, ent = vfs_s_new_entry (me, path, ino); if ((MEDATA->dir_load) (me, ino, path) == -1) { vfs_s_free_entry (me, ent); - mhl_mem_free (path); + g_free (path); return NULL; } vfs_s_insert_entry (me, root, ent); @@ -379,11 +379,11 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root, #if 0 if (!vfs_s_resolve_symlink (me, ent, follow)) { - mhl_mem_free (path); + g_free (path); return NULL; } #endif - mhl_mem_free (path); + g_free (path); return ent; } @@ -450,8 +450,8 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super) } CALL (free_archive) (me, super); - mhl_mem_free (super->name); - mhl_mem_free(super); + g_free (super->name); + g_free(super); } @@ -525,7 +525,7 @@ vfs_s_get_path (struct vfs_class *me, const char *inname, buf = mhl_str_dup (inname); retval = mhl_str_dup (vfs_s_get_path_mangle (me, buf, archive, flags)); - mhl_mem_free (buf); + g_free (buf); return retval; } @@ -553,7 +553,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino) if (ino == ino->super->root) break; newpath = g_strconcat (ino->ent->name, "/", path, (char *) NULL); - mhl_mem_free (path); + g_free (path); path = newpath; } return path; @@ -591,7 +591,7 @@ vfs_s_inode_from_path (struct vfs_class *me, const char *name, int flags) flags & FL_FOLLOW ? LINK_FOLLOW : LINK_NO_FOLLOW, FL_DIR | (flags & ~FL_FOLLOW)); - mhl_mem_free (q); + g_free (q); return ino; } @@ -652,7 +652,7 @@ vfs_s_closedir (void *data) struct vfs_s_inode *dir = info->dir; vfs_s_free_inode (dir->super->me, dir); - mhl_mem_free (data); + g_free (data); return 0; } @@ -735,7 +735,7 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode) return NULL; ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE); if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) { - mhl_mem_free (q); + g_free (q); ERRNOR (EEXIST, NULL); } if (!ino) { @@ -746,7 +746,7 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode) /* If the filesystem is read-only, disable file creation */ if (!(flags & O_CREAT) || !(me->write)) { - mhl_mem_free (q); + g_free (q); return NULL; } @@ -760,14 +760,14 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode) vfs_s_insert_entry (me, dir, ent); tmp_handle = vfs_mkstemps (&ino->localname, me->name, name); if (tmp_handle == -1) { - mhl_mem_free (q); + g_free (q); return NULL; } close (tmp_handle); was_changed = 1; } - mhl_mem_free (q); + g_free (q); if (S_ISDIR (ino->st.st_mode)) ERRNOR (EISDIR, NULL); @@ -786,14 +786,14 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode) } } else if ((MEDATA->fh_open) && (MEDATA->fh_open (me, fh, flags, mode))) { - mhl_mem_free (fh); + g_free (fh); return NULL; } if (fh->ino->localname) { fh->handle = open (fh->ino->localname, NO_LINEAR (flags), mode); if (fh->handle == -1) { - mhl_mem_free (fh); + g_free (fh); ERRNOR (errno, NULL); } } @@ -902,7 +902,7 @@ vfs_s_close (void *fh) res = -1; else { res = MEDATA->file_store (me, fh, s, FH->ino->localname); - mhl_mem_free (s); + g_free (s); } vfs_s_invalidate (me, FH_SUPER); } @@ -910,7 +910,7 @@ vfs_s_close (void *fh) close (FH->handle); vfs_s_free_inode (me, FH->ino); - mhl_mem_free (fh); + g_free (fh); return res; } @@ -996,7 +996,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino) close (handle); unlink (ino->localname); error_4: - mhl_mem_free (ino->localname); + g_free (ino->localname); ino->localname = NULL; return -1; } @@ -1012,7 +1012,7 @@ vfs_s_fill_names (struct vfs_class *me, fill_names_f func) while (a){ name = g_strconcat ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL); (*func)(name); - mhl_mem_free (name); + g_free (name); a = a->next; } } @@ -1096,7 +1096,7 @@ vfs_s_getid (struct vfs_class *me, const char *path) if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN))) return NULL; - mhl_mem_free(p); + g_free(p); return (vfsid) archive; } diff --git a/vfs/extfs.c b/vfs/extfs.c index 0cb8bd754..f966b8280 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -126,7 +126,7 @@ extfs_fill_names (struct vfs_class *me, fill_names_f func) g_strconcat (a->name ? a->name : "", "#", extfs_prefixes[a->fstype], (char *) NULL); (*func) (name); - mhl_mem_free (name); + g_free (name); a = a->next; } } @@ -219,10 +219,10 @@ static void extfs_free_archive (struct archive *archive) mc_stat (archive->local_name, &my); mc_ungetlocalcopy (archive->name, archive->local_name, archive->local_stat.st_mtime != my.st_mtime); - mhl_mem_free(archive->local_name); + g_free(archive->local_name); } - mhl_mem_free (archive->name); - mhl_mem_free (archive); + g_free (archive->name); + g_free (archive); } static FILE * @@ -254,16 +254,16 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc) cmd = g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ", local_name ? local_name : tmp, (char *) NULL); - mhl_mem_free (tmp); - mhl_mem_free (mc_extfsdir); + g_free (tmp); + g_free (mc_extfsdir); open_error_pipe (); result = popen (cmd, "r"); - mhl_mem_free (cmd); + g_free (cmd); if (result == NULL) { close_error_pipe (D_ERROR, NULL); if (local_name) { mc_ungetlocalcopy (name, local_name, 0); - mhl_mem_free(local_name); + g_free(local_name); } return NULL; } @@ -356,7 +356,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc) 0); if (pent == NULL) { /* FIXME: Should clean everything one day */ - mhl_mem_free (buffer); + g_free (buffer); pclose (extfsd); close_error_pipe (D_ERROR, _("Inconsistent extfs archive")); return -1; @@ -375,7 +375,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc) current_link_name, 0, 0); if (pent == NULL) { /* FIXME: Should clean everything one day */ - mhl_mem_free (buffer); + g_free (buffer); pclose (extfsd); close_error_pipe (D_ERROR, _("Inconsistent extfs archive")); @@ -420,11 +420,11 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc) } } read_extfs_continue: - mhl_mem_free (current_file_name); - mhl_mem_free (current_link_name); + g_free (current_file_name); + g_free (current_link_name); } } - mhl_mem_free (buffer); + g_free (buffer); /* Check if extfs 'list' returned 0 */ if (pclose (extfsd) != 0) { @@ -499,7 +499,7 @@ extfs_get_path (struct vfs_class *me, const char *inname, struct archive **archi char *res2 = NULL; if (res) res2 = mhl_str_dup (res); - mhl_mem_free (buf); + g_free (buf); return res2; } @@ -533,7 +533,7 @@ static char *extfs_get_path_from_entry (struct entry *entry) strcat (localpath, "/"); p = head; head = head->next; - mhl_mem_free (p); + g_free (p); } return (localpath); } @@ -568,7 +568,7 @@ extfs_resolve_symlinks_int (struct entry *entry, looping->entry = entry; looping->next = list; pent = extfs_find_entry_int (entry->dir, entry->inode->linkname, looping, 0, 0); - mhl_mem_free (looping); + g_free (looping); if (pent == NULL) my_errno = ENOENT; return pent; @@ -621,7 +621,7 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive, file = extfs_get_path_from_entry (entry); quoted_file = name_quote (file, 0); - mhl_mem_free (file); + g_free (file); archive_name = name_quote (extfs_get_archive_name (archive), 0); quoted_localname = name_quote (localname, 0); @@ -629,14 +629,14 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive, cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], extfs_cmd, archive_name, " ", quoted_file, " ", quoted_localname, (char *) NULL); - mhl_mem_free (quoted_file); - mhl_mem_free (quoted_localname); - mhl_mem_free (mc_extfsdir); - mhl_mem_free (archive_name); + g_free (quoted_file); + g_free (quoted_localname); + g_free (mc_extfsdir); + g_free (archive_name); open_error_pipe (); retval = my_system (EXECUTE_AS_SHELL, shell, cmd); - mhl_mem_free (cmd); + g_free (cmd); close_error_pipe (D_ERROR, NULL); return retval; } @@ -651,17 +651,17 @@ extfs_run (struct vfs_class *me, const char *file) if ((p = extfs_get_path (me, file, &archive, 0)) == NULL) return; q = name_quote (p, 0); - mhl_mem_free (p); + g_free (p); archive_name = name_quote (extfs_get_archive_name (archive), 0); mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR); cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], " run ", archive_name, " ", q, (char *) NULL); - mhl_mem_free (mc_extfsdir); - mhl_mem_free (archive_name); - mhl_mem_free (q); + g_free (mc_extfsdir); + g_free (archive_name); + g_free (q); shell_execute (cmd, 0); - mhl_mem_free (cmd); + g_free (cmd); } static void * @@ -683,7 +683,7 @@ extfs_open (struct vfs_class *me, const char *file, int flags, int mode) created = (entry != NULL); } - mhl_mem_free (q); + g_free (q); if (entry == NULL) return NULL; if ((entry = extfs_resolve_symlinks (entry)) == NULL) @@ -766,7 +766,7 @@ extfs_close (void *data) if (!file->archive->fd_usage) vfs_stamp_create (&vfs_extfs_ops, file->archive); - mhl_mem_free (data); + g_free (data); if (errno_code) ERRNOR (EIO, -1); return 0; @@ -882,7 +882,7 @@ static void * extfs_opendir (struct vfs_class *me, const char *dirname) if ((q = extfs_get_path (me, dirname, &archive, 0)) == NULL) return NULL; entry = extfs_find_entry (archive->root_entry, q, 0, 0); - mhl_mem_free (q); + g_free (q); if (entry == NULL) return NULL; if ((entry = extfs_resolve_symlinks (entry)) == NULL) @@ -914,7 +914,7 @@ static void * extfs_readdir(void *data) static int extfs_closedir (void *data) { - mhl_mem_free (data); + g_free (data); return 0; } @@ -961,7 +961,7 @@ extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, extfs_stat_move (buf, entry->inode); result = 0; cleanup: - mhl_mem_free (path2); + g_free (path2); return result; } @@ -1008,7 +1008,7 @@ extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) /* readlink() does not append a NUL character to buf */ memcpy (buf, entry->inode->linkname, result = len); cleanup: - mhl_mem_free (mpath); + g_free (mpath); return result; } @@ -1053,7 +1053,7 @@ static int extfs_unlink (struct vfs_class *me, const char *file) extfs_remove_entry (entry); result = 0; cleanup: - mhl_mem_free (mpath); + g_free (mpath); return result; } @@ -1090,7 +1090,7 @@ static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) } result = 0; cleanup: - mhl_mem_free (mpath); + g_free (mpath); return result; } @@ -1120,7 +1120,7 @@ static int extfs_rmdir (struct vfs_class *me, const char *path) extfs_remove_entry (entry); result = 0; cleanup: - mhl_mem_free (mpath); + g_free (mpath); return result; } @@ -1135,7 +1135,7 @@ extfs_chdir (struct vfs_class *me, const char *path) if ((q = extfs_get_path (me, path, &archive, 0)) == NULL) return -1; entry = extfs_find_entry (archive->root_entry, q, 0, 0); - mhl_mem_free (q); + g_free (q); if (!entry) return -1; entry = extfs_resolve_symlinks (entry); @@ -1160,7 +1160,7 @@ extfs_getid (struct vfs_class *me, const char *path) if (!(p = extfs_get_path (me, path, &archive, 1))) return NULL; - mhl_mem_free (p); + g_free (p); return (vfsid) archive; } @@ -1202,12 +1202,12 @@ static void extfs_remove_entry (struct entry *e) unlink (e->inode->local_filename); free (e->inode->local_filename); } - mhl_mem_free (e->inode->linkname); - mhl_mem_free (e->inode); + g_free (e->inode->linkname); + g_free (e->inode); } - mhl_mem_free (e->name); - mhl_mem_free (e); + g_free (e->name); + g_free (e); } static void extfs_free_entry (struct entry *e) @@ -1224,13 +1224,13 @@ static void extfs_free_entry (struct entry *e) unlink (e->inode->local_filename); free (e->inode->local_filename); } - mhl_mem_free (e->inode->linkname); - mhl_mem_free (e->inode); + g_free (e->inode->linkname); + g_free (e->inode); } if (e->next_in_dir != NULL) extfs_free_entry (e->next_in_dir); - mhl_mem_free (e->name); - mhl_mem_free (e); + g_free (e->name); + g_free (e); } static void extfs_free (vfsid id) @@ -1307,7 +1307,7 @@ static int extfs_init (struct vfs_class *me) * appear on screen. */ if (!cfg) { fprintf (stderr, _("Warning: file %s not found\n"), mc_extfsini); - mhl_mem_free (mc_extfsini); + g_free (mc_extfsini); return 0; } @@ -1323,7 +1323,7 @@ static int extfs_init (struct vfs_class *me) fprintf(stderr, "Warning: You need to update your %s file.\n", mc_extfsini); fclose(cfg); - mhl_mem_free (mc_extfsini); + g_free (mc_extfsini); return 0; } if (*key == '#' || *key == '\n') @@ -1343,7 +1343,7 @@ static int extfs_init (struct vfs_class *me) extfs_prefixes [extfs_no++] = mhl_str_dup (key); } fclose(cfg); - mhl_mem_free (mc_extfsini); + g_free (mc_extfsini); return 1; } @@ -1372,7 +1372,7 @@ static void extfs_done (struct vfs_class *me) } for (i = 0; i < extfs_no; i++ ) - mhl_mem_free (extfs_prefixes [i]); + g_free (extfs_prefixes [i]); extfs_no = 0; } diff --git a/vfs/fish.c b/vfs/fish.c index 1d53230d6..8eb387ea0 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -147,7 +147,7 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, enable_interrupt_key (); status = write (SUP.sockw, str, strlen (str)); - mhl_mem_free (str); + g_free (str); disable_interrupt_key (); if (status < 0) @@ -171,10 +171,10 @@ fish_free_archive (struct vfs_class *me, struct vfs_s_super *super) close (SUP.sockr); SUP.sockw = SUP.sockr = -1; } - mhl_mem_free (SUP.host); - mhl_mem_free (SUP.user); - mhl_mem_free (SUP.cwdir); - mhl_mem_free (SUP.password); + g_free (SUP.host); + g_free (SUP.user); + g_free (SUP.cwdir); + g_free (SUP.password); } static void @@ -263,7 +263,7 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super) p = g_strconcat (_(" fish: Password required for "), SUP.user, " ", (char *) NULL); op = vfs_get_password (p); - mhl_mem_free (p); + g_free (p); if (op == NULL) ERRNOR (EPERM, -1); SUP.password = op; @@ -326,7 +326,7 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super, p = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags, &password, 0, URL_NOSLASH); - mhl_mem_free (p); + g_free (p); SUP.host = host; SUP.user = user; @@ -353,12 +353,12 @@ fish_archive_same (struct vfs_class *me, struct vfs_s_super *super, op = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags, 0, 0, URL_NOSLASH); - mhl_mem_free (op); + g_free (op); flags = ((strcmp (host, SUP.host) == 0) && (strcmp (user, SUP.user) == 0) && (flags == SUP.flags)); - mhl_mem_free (host); - mhl_mem_free (user); + g_free (host); + g_free (user); return flags; } @@ -466,7 +466,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path) "echo '### 500'\n" "fi\n", quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s); - mhl_mem_free (quoted_path.s); + g_free (quoted_path.s); ent = vfs_s_generate_entry(me, NULL, dir, 0); while (1) { int res = vfs_s_get_line_interruptible (me, buffer, sizeof (buffer), SUP.sockr); @@ -597,7 +597,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path) vfs_s_free_entry (me, ent); reply_code = fish_decode_reply(buffer + 4, 0); if (reply_code == COMPLETE) { - mhl_mem_free (SUP.cwdir); + g_free (SUP.cwdir); SUP.cwdir = mhl_str_dup (remote_path); print_vfs_message (_("%s: done."), me->name); return 0; @@ -738,14 +738,14 @@ fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *loc (unsigned long) s.st_size); } close(h); - mhl_mem_free(quoted_name.s); + g_free(quoted_name.s); if ((fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE) || was_error) ERRNOR (E_REMOTE, -1); return 0; error_return: close(h); fish_get_reply(me, SUP.sockr, NULL, 0); - mhl_mem_free(quoted_name.s); + g_free(quoted_name.s); return -1; } @@ -783,7 +783,7 @@ fish_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset) "echo '### 500'\n" "fi\n", quoted_name.s, quoted_name.s, quoted_name.s, quoted_name.s ); - mhl_mem_free (quoted_name.s); + g_free (quoted_name.s); if (offset != PRELIM) ERRNOR (E_REMOTE, 0); fh->linear = LS_LINEAR_OPEN; fh->u.fish.got = 0; @@ -896,14 +896,14 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super *super, const char *c SHELL_ESCAPED_STR rpath; \ struct vfs_s_super *super; \ if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \ - mhl_mem_free (mpath); \ + g_free (mpath); \ return -1; \ } \ rpath = mhl_shell_escape_dup(crpath); \ - mhl_mem_free (mpath); + g_free (mpath); #define POSTFIX(flags) \ - mhl_mem_free (rpath.s); \ + g_free (rpath.s); \ return fish_send_command(me, super, buf, flags); static int @@ -926,20 +926,20 @@ static int fish_##name (struct vfs_class *me, const char *path1, const char *pat char *mpath1, *mpath2; \ struct vfs_s_super *super1, *super2; \ if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = mhl_str_dup(path1), &super1, 0))) { \ - mhl_mem_free (mpath1); \ + g_free (mpath1); \ return -1; \ } \ if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = mhl_str_dup(path2), &super2, 0))) { \ - mhl_mem_free (mpath1); \ - mhl_mem_free (mpath2); \ + g_free (mpath1); \ + g_free (mpath2); \ } \ SHELL_ESCAPED_STR rpath1 = mhl_shell_escape_dup (crpath1); \ - mhl_mem_free (mpath1); \ + g_free (mpath1); \ SHELL_ESCAPED_STR rpath2 = mhl_shell_escape_dup (crpath2); \ - mhl_mem_free (mpath2); \ + g_free (mpath2); \ snprintf(buf, sizeof(buf), string "\n", rpath1.s, rpath2.s, rpath1.s, rpath2.s); \ - mhl_mem_free (rpath1.s); \ - mhl_mem_free (rpath2.s); \ + g_free (rpath1.s); \ + g_free (rpath2.s); \ return fish_send_command(me, super2, buf, OPT_FLUSH); \ } @@ -960,7 +960,7 @@ static int fish_symlink (struct vfs_class *me, const char *setto, const char *pa "ln -s %s /%s 2>/dev/null\n" "echo '### 000'\n", qsetto.s, rpath.s, qsetto.s, rpath.s); - mhl_mem_free (qsetto.s); + g_free (qsetto.s); POSTFIX(OPT_FLUSH); } @@ -1096,7 +1096,7 @@ fish_fill_names (struct vfs_class *me, fill_names_f func) name = g_strconcat ("/#sh:", SUP.user, "@", SUP.host, flags, "/", SUP.cwdir, (char *) NULL); (*func)(name); - mhl_mem_free (name); + g_free (name); super = super->next; } } diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 2c0900011..183e2771d 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -45,7 +45,7 @@ What to do with this? if (f || !strncmp( remote_path, "/~/", 3 )) { char *s; s = mhl_str_dir_plus_file( qhome (*bucket), remote_path +3-f ); - mhl_mem_free (remote_path); + g_free (remote_path); remote_path = s; } } @@ -56,7 +56,6 @@ What to do with this? /* Namespace pollution: horrible */ #include - #include /* POSIX-required by sys/socket.h and netdb.h */ #include /* struct hostent */ #include /* AF_INET */ @@ -248,14 +247,14 @@ ftpfs_split_url(char *path, char **host, char **user, int *port, char **pass) /* If user is different, remove password */ if (new_user && strcmp (*user, new_user)) { - mhl_mem_free (*pass); + g_free (*pass); *pass = NULL; } - mhl_mem_free (new_user); + g_free (new_user); } - mhl_mem_free (p); + g_free (p); } /* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */ @@ -312,7 +311,7 @@ ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super) if (!cwdir) return 1; sock = ftpfs_chdir_internal (me, super, cwdir); - mhl_mem_free (cwdir); + g_free (cwdir); return sock == COMPLETE; } SUP.cwdir = cwdir; @@ -366,7 +365,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, } got_sigpipe = 1; } - mhl_mem_free (cmdstr); + g_free (cmdstr); disable_interrupt_key (); return TRANSIENT; } @@ -390,10 +389,10 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, } } retry = 0; - mhl_mem_free (cmdstr); + g_free (cmdstr); return status; } - mhl_mem_free (cmdstr); + g_free (cmdstr); return COMPLETE; } @@ -405,10 +404,10 @@ ftpfs_free_archive (struct vfs_class *me, struct vfs_s_super *super) ftpfs_command(me, super, NONE, "QUIT"); close(SUP.sock); } - mhl_mem_free (SUP.host); - mhl_mem_free (SUP.user); - mhl_mem_free (SUP.cwdir); - mhl_mem_free (SUP.password); + g_free (SUP.host); + g_free (SUP.user); + g_free (SUP.cwdir); + g_free (SUP.password); } /* some defines only used by ftpfs_changetype */ @@ -459,7 +458,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, p = g_strconcat (_(" FTP: Password required for "), SUP.user, " ", NULL); op = vfs_get_password (p); - mhl_mem_free (p); + g_free (p); if (op == NULL) ERRNOR (EPERM, 0); SUP.password = mhl_str_dup (op); @@ -505,13 +504,13 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, ("FTP: Account required for user %s"), SUP.user); op = input_dialog (p, _("Account:"), MC_HISTORY_FTPFS_ACCOUNT, ""); - mhl_mem_free (p); + g_free (p); if (op == NULL) ERRNOR (EPERM, 0); print_vfs_message (_("ftpfs: sending user account")); code = ftpfs_command (me, super, WAIT_REPLY, "ACCT %s", op); - mhl_mem_free (op); + g_free (op); } if (code != COMPLETE) break; @@ -520,7 +519,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, case COMPLETE: print_vfs_message (_("ftpfs: logged in")); wipe_password (pass); - mhl_mem_free (name); + g_free (name); return 1; default: @@ -536,7 +535,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, SUP.user); login_fail: wipe_password (pass); - mhl_mem_free (name); + g_free (name); ERRNOR (EPERM, 0); } @@ -586,7 +585,7 @@ ftpfs_load_no_proxy_list (void) fclose (npf); } - mhl_mem_free (mc_file); + g_free (mc_file); } /* Return 1 if FTP proxy should be used for this host, 0 otherwise */ @@ -638,8 +637,8 @@ ftpfs_get_proxy_host_and_port (const char *proxy, char **host, int *port) dir = vfs_split_url (proxy, host, &user, port, 0, FTP_COMMAND_PORT, URL_ALLOW_ANON); - mhl_mem_free (user); - mhl_mem_free (dir); + g_free (user); + g_free (dir); } static int @@ -682,7 +681,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) print_vfs_message (_("ftpfs: Invalid host address.")); ftpfs_errno = EINVAL; if (free_host) - mhl_mem_free (host); + g_free (host); return -1; } server_address.sin_family = hp->h_addrtype; @@ -698,13 +697,13 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) disable_interrupt_key(); ftpfs_errno = errno; if (free_host) - mhl_mem_free (host); + g_free (host); return -1; } print_vfs_message (_("ftpfs: making connection to %s"), host); if (free_host) - mhl_mem_free (host); + g_free (host); if (connect (my_socket, (struct sockaddr *) &server_address, sizeof (server_address)) < 0){ @@ -819,8 +818,8 @@ ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super, port = ((strcmp (host, SUP.host) == 0) && (strcmp (user, SUP.user) == 0) && (port == SUP.port)); - mhl_mem_free (host); - mhl_mem_free (user); + g_free (host); + g_free (user); return port; } @@ -971,7 +970,7 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con j = ftpfs_command (me, super, WAIT_REPLY, "%s /%s", cmd, /* WarFtpD can't STORE //filename */ (*remote_path == '/') ? remote_path + 1 : remote_path); - mhl_mem_free (remote_path); + g_free (remote_path); } else j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd); if (j != PRELIM) @@ -1157,7 +1156,7 @@ resolve_symlink_with_ls_options(struct vfs_class *me, struct vfs_s_super *super, vfs_die("This code should be commented out\n"); if (vfs_parse_ls_lga (buffer, &s, &filename, NULL)) { int r = strcmp(fe->name, filename); - mhl_mem_free(filename); + g_free(filename); if (r == 0) { if (S_ISLNK (s.st_mode)) { /* This server doesn't understand LIST -lLa */ @@ -1238,7 +1237,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path sock = ftpfs_open_data_connection (me, super, "LIST -la", path, TYPE_ASCII, 0); - mhl_mem_free (path); + g_free (path); } if (sock == -1) @@ -1411,7 +1410,7 @@ ftpfs_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset) if (!name) return 0; FH_SOCK = ftpfs_open_data_connection(me, FH_SUPER, "RETR", name, TYPE_BINARY, offset); - mhl_mem_free (name); + g_free (name); if (FH_SOCK == -1) ERRNOR (EACCES, 0); fh->linear = LS_LINEAR_OPEN; @@ -1487,23 +1486,23 @@ ftpfs_send_command(struct vfs_class *me, const char *filename, const char *cmd, int flush_directory_cache = (flags & OPT_FLUSH); if (!(rpath = vfs_s_get_path_mangle(me, mpath, &super, 0))) { - mhl_mem_free(mpath); + g_free(mpath); return -1; } p = ftpfs_translate_path (me, super, rpath); r = ftpfs_command (me, super, WAIT_REPLY, cmd, p); - mhl_mem_free (p); + g_free (p); vfs_stamp_create (&vfs_ftpfs_ops, super); if (flags & OPT_IGNORE_ERROR) r = COMPLETE; if (r != COMPLETE) { me->verrno = EPERM; - mhl_mem_free (mpath); + g_free (mpath); return -1; } if (flush_directory_cache) vfs_s_invalidate(me, super); - mhl_mem_free(mpath); + g_free(mpath); return 0; } @@ -1579,12 +1578,12 @@ ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, const cha p = ftpfs_translate_path (me, super, remote_path); r = ftpfs_command (me, super, WAIT_REPLY, "CWD /%s", p); - mhl_mem_free (p); + g_free (p); if (r != COMPLETE) { ftpfs_errno = EIO; } else { - mhl_mem_free(SUP.cwdir); + g_free(SUP.cwdir); SUP.cwdir = mhl_str_dup (remote_path); SUP.cwd_deferred = 0; } @@ -1647,7 +1646,7 @@ ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, ftpfs_open_data_connection (me, fh->ino->super, (flags & O_APPEND) ? "APPE" : "STOR", name, TYPE_BINARY, 0); - mhl_mem_free (name); + g_free (name); if (fh->handle < 0) return -1; @@ -1659,7 +1658,7 @@ ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, if (fh->ino->localname) { unlink (fh->ino->localname); - mhl_mem_free (fh->ino->localname); + g_free (fh->ino->localname); fh->ino->localname = NULL; } return 0; @@ -1698,12 +1697,12 @@ ftpfs_done (struct vfs_class *me) while (no_proxy) { np = no_proxy->next; - mhl_mem_free (no_proxy->domain); - mhl_mem_free (no_proxy); + g_free (no_proxy->domain); + g_free (no_proxy); no_proxy = np; } - mhl_mem_free (ftpfs_anonymous_passwd); - mhl_mem_free (ftpfs_proxy_host); + g_free (ftpfs_anonymous_passwd); + g_free (ftpfs_proxy_host); } static void @@ -1715,7 +1714,7 @@ ftpfs_fill_names (struct vfs_class *me, fill_names_f func) while (super){ name = g_strconcat ("/#ftp:", SUP.user, "@", SUP.host, "/", SUP.cwdir, (char *) NULL); (*func)(name); - mhl_mem_free (name); + g_free (name); super = super->next; } } @@ -1893,7 +1892,7 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) netrcname = mhl_str_dir_plus_file (home_dir, ".netrc"); netrcp = netrc = load_file (netrcname); if (netrc == NULL) { - mhl_mem_free (netrcname); + g_free (netrcname); return 0; } @@ -1968,8 +1967,8 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) break; } - mhl_mem_free (netrc); - mhl_mem_free (netrcname); + g_free (netrc); + g_free (netrcname); rupp = g_new (struct rupcache, 1); rupp->host = mhl_str_dup (host); diff --git a/vfs/gc.c b/vfs/gc.c index 70d0e651c..961d7f8b4 100644 --- a/vfs/gc.c +++ b/vfs/gc.c @@ -110,7 +110,7 @@ vfs_rmstamp (struct vfs_class *v, vfsid id) } else { st1->next = stamp->next; } - mhl_mem_free (stamp); + g_free (stamp); return; } @@ -129,7 +129,7 @@ vfs_getid (struct vfs_class *vclass, const char *dir) if (vclass->getid) id = (*vclass->getid) (vclass, dir1); - mhl_mem_free (dir1); + g_free (dir1); return id; } @@ -298,7 +298,7 @@ vfs_gc_done (void) if (stamp->v->free) (*stamp->v->free) (stamp->id); st = stamp->next; - mhl_mem_free (stamp); + g_free (stamp); stamp = st; } diff --git a/vfs/local.c b/vfs/local.c index 96ba885c2..015037bb4 100644 --- a/vfs/local.c +++ b/vfs/local.c @@ -70,7 +70,7 @@ local_close (void *data) return -1; fd = *(int *) data; - mhl_mem_free (data); + g_free (data); return close (fd); } @@ -111,7 +111,7 @@ local_closedir (void *data) int i; i = closedir (* (DIR **) data); - mhl_mem_free (data); + g_free (data); return i; } diff --git a/vfs/mcfs.c b/vfs/mcfs.c index 293e59dcd..dde1b45fd 100644 --- a/vfs/mcfs.c +++ b/vfs/mcfs.c @@ -114,7 +114,7 @@ mcfs_fill_names (struct vfs_class *me, fill_names_f func) name = g_strconcat ("/#mc:", mcfs_connections[i].user, "@", mcfs_connections[i].host, (char *) NULL); (*func) (name); - mhl_mem_free (name); + g_free (name); } } @@ -392,11 +392,11 @@ mcfs_get_path (mcfs_connection **mc, const char *path) if ((remote_path = mcfs_get_host_and_username (path, &host, &user, &port, &pass))) if (!(*mc = mcfs_open_link (host, user, &port, pass))) { - mhl_mem_free (remote_path); + g_free (remote_path); remote_path = NULL; } - mhl_mem_free (host); - mhl_mem_free (user); + g_free (host); + g_free (user); if (pass) wipe_password (pass); @@ -410,7 +410,7 @@ mcfs_get_path (mcfs_connection **mc, const char *path) char *s; s = mhl_str_dir_plus_file (mcfs_gethome (*mc), remote_path + 3 - f); - mhl_mem_free (remote_path); + g_free (remote_path); remote_path = s; } } @@ -444,14 +444,14 @@ mcfs_rpc_two_paths (int command, const char *s1, const char *s2) return -1; if ((r2 = mcfs_get_path (&mc, s2)) == 0) { - mhl_mem_free (r1); + g_free (r1); return -1; } rpc_send (mc->sock, RPC_INT, command, RPC_STRING, r1, RPC_STRING, r2, RPC_END); - mhl_mem_free (r1); - mhl_mem_free (r2); + g_free (r1); + g_free (r2); return mcfs_handle_simple_error (mc->sock, 0); } @@ -467,7 +467,7 @@ mcfs_rpc_path (int command, const char *path) rpc_send (mc->sock, RPC_INT, command, RPC_STRING, remote_file, RPC_END); - mhl_mem_free (remote_file); + g_free (remote_file); return mcfs_handle_simple_error (mc->sock, 0); } @@ -484,7 +484,7 @@ mcfs_rpc_path_int (int command, const char *path, int data) RPC_INT, command, RPC_STRING, remote_file, RPC_INT, data, RPC_END); - mhl_mem_free (remote_file); + g_free (remote_file); return mcfs_handle_simple_error (mc->sock, 0); } @@ -501,7 +501,7 @@ mcfs_rpc_path_int_int (int command, const char *path, int n1, int n2) RPC_INT, command, RPC_STRING, remote_file, RPC_INT, n1, RPC_INT, n2, RPC_END); - mhl_mem_free (remote_file); + g_free (remote_file); return mcfs_handle_simple_error (mc->sock, 0); } @@ -537,7 +537,7 @@ mcfs_open (struct vfs_class *me, const char *file, int flags, int mode) rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT, flags, RPC_INT, mode, RPC_END); - mhl_mem_free (remote_file); + g_free (remote_file); if (0 == rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END)) @@ -619,7 +619,7 @@ mcfs_close (void *data) mcfs_is_error (result, error); - mhl_mem_free (data); + g_free (data); return result; } @@ -661,7 +661,7 @@ mcfs_opendir (struct vfs_class *me, const char *dirname) rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir, RPC_END); - mhl_mem_free (remote_dir); + g_free (remote_dir); if (0 == rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END)) @@ -744,8 +744,8 @@ mcfs_free_dir (dir_entry *de) if (!de) return; mcfs_free_dir (de->next); - mhl_mem_free (de->text); - mhl_mem_free (de); + g_free (de->text); + g_free (de); } static union vfs_dirent mcfs_readdir_data; @@ -795,10 +795,10 @@ mcfs_closedir (void *info) for (p = mcfs_info->entries; p;) { q = p; p = p->next; - mhl_mem_free (q->text); - mhl_mem_free (q); + g_free (q->text); + g_free (q); } - mhl_mem_free (info); + g_free (info); return 0; } @@ -826,7 +826,7 @@ mcfs_get_time (mcfs_connection *mc) rpc_get (sock, RPC_STRING, &buf, RPC_END); sscanf (buf, "%lx", &tm); - mhl_mem_free (buf); + g_free (buf); return (time_t) tm; } @@ -879,7 +879,7 @@ mcfs_stat_cmd (int cmd, const char *path, struct stat *buf) return -1; rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END); - mhl_mem_free (remote_file); + g_free (remote_file); if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) return mcfs_set_error (-1, errno); @@ -986,7 +986,7 @@ mcfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times) status = mcfs_handle_simple_error (mc->sock, 0); } - mhl_mem_free (file); + g_free (file); return (status); } @@ -1005,7 +1005,7 @@ mcfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file, RPC_END); - mhl_mem_free (remote_file); + g_free (remote_file); if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) return mcfs_set_error (-1, EIO); @@ -1020,7 +1020,7 @@ mcfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) size = len; /* readlink() does not append a NUL character to buf */ memcpy (buf, stat_str, size); - mhl_mem_free (stat_str); + g_free (stat_str); return size; } @@ -1062,7 +1062,7 @@ mcfs_chdir (struct vfs_class *me, const char *path) rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir, RPC_END); - mhl_mem_free (remote_dir); + g_free (remote_dir); if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) return mcfs_set_error (-1, EIO); @@ -1138,8 +1138,8 @@ mcfs_forget (const char *path) if ((p = mcfs_get_host_and_username (path, &host, &user, &port, &pass)) == 0) { - mhl_mem_free (host); - mhl_mem_free (user); + g_free (host); + g_free (user); if (pass) wipe_password (pass); return; @@ -1157,9 +1157,9 @@ mcfs_forget (const char *path) mcfs_open_tcp_link (host, user, &port, pass, &vers); } } - mhl_mem_free (p); - mhl_mem_free (host); - mhl_mem_free (user); + g_free (p); + g_free (host); + g_free (user); if (pass) wipe_password (pass); } @@ -1215,9 +1215,9 @@ init_mcfs (void) static void mcfs_free_bucket (int bucket) { - mhl_mem_free (mcfs_connections[bucket].host); - mhl_mem_free (mcfs_connections[bucket].user); - mhl_mem_free (mcfs_connections[bucket].home); + g_free (mcfs_connections[bucket].host); + g_free (mcfs_connections[bucket].user); + g_free (mcfs_connections[bucket].home); /* Set all the fields to zero */ mcfs_connections[bucket].host = diff --git a/vfs/mcserv.c b/vfs/mcserv.c index 83e6795c2..d79c6f355 100644 --- a/vfs/mcserv.c +++ b/vfs/mcserv.c @@ -124,6 +124,10 @@ # define INADDR_NONE (0xffffffffU) #endif +/* replacement for g_free() from glib */ +#undef g_free +#define g_free(x) do {if (x) free (x);} while (0) + /* We don't care about SIGPIPE */ int got_sigpipe = 0; @@ -210,7 +214,7 @@ do_open (void) handle = open (arg, flags, mode); send_status (handle, errno); - mhl_mem_free (arg); + g_free (arg); } static void @@ -237,7 +241,7 @@ do_read (void) send_status (n, 0); rpc_send (msock, RPC_BLOCK, n, data, RPC_END); - mhl_mem_free (data); + g_free (data); } static void @@ -377,7 +381,7 @@ do_lstat (void) send_status (n, errno); if (n >= 0) send_stat_info (&st); - mhl_mem_free (file); + g_free (file); } static void @@ -409,7 +413,7 @@ do_stat (void) send_status (n, errno); if (n >= 0) send_stat_info (&st); - mhl_mem_free (file); + g_free (file); } /* }}} */ @@ -429,7 +433,7 @@ close_handle (int handle) mcfs_DIR.used--; if (mcfs_DIR.dirs[handle]) closedir (mcfs_DIR.dirs[handle]); - mhl_mem_free (mcfs_DIR.names[handle]); + g_free (mcfs_DIR.names[handle]); mcfs_DIR.dirs[handle] = 0; mcfs_DIR.names[handle] = 0; } @@ -445,7 +449,7 @@ do_opendir (void) if (mcfs_DIR.used == OPENDIR_HANDLES) { send_status (-1, ENFILE); /* Error */ - mhl_mem_free (arg); + g_free (arg); return; } @@ -459,7 +463,7 @@ do_opendir (void) if (handle == -1) { send_status (-1, EMFILE); - mhl_mem_free (arg); + g_free (arg); if (!inetd_started) fprintf (stderr, "OOPS! you have found a bug in mc - do_opendir()!\n"); @@ -479,7 +483,7 @@ do_opendir (void) } else { send_status (-1, errno); - mhl_mem_free (arg); + g_free (arg); } } @@ -514,7 +518,7 @@ do_readdir (void) snprintf (fname, fname_len, "%s/%s", mcfs_DIR.names[handle], dirent->d_name); n = lstat (fname, &st); - mhl_mem_free (fname); + g_free (fname); send_status (n, errno); if (n >= 0) send_stat_info (&st); @@ -545,7 +549,7 @@ do_chdir (void) status = chdir (file); send_status (status, errno); - mhl_mem_free (file); + g_free (file); } static void @@ -558,7 +562,7 @@ do_rmdir (void) status = rmdir (file); send_status (status, errno); - mhl_mem_free (file); + g_free (file); } static void @@ -571,7 +575,7 @@ do_mkdir (void) status = mkdir (file, mode); send_status (status, errno); - mhl_mem_free (file); + g_free (file); } static void @@ -585,7 +589,7 @@ do_mknod (void) status = mknod (file, mode, dev); send_status (status, errno); - mhl_mem_free (file); + g_free (file); } static void @@ -602,7 +606,7 @@ do_readlink (void) buffer[n] = 0; rpc_send (msock, RPC_STRING, buffer, RPC_END); } - mhl_mem_free (file); + g_free (file); } static void @@ -614,7 +618,7 @@ do_unlink (void) rpc_get (msock, RPC_STRING, &file, RPC_END); status = unlink (file); send_status (status, errno); - mhl_mem_free (file); + g_free (file); } static void @@ -626,8 +630,8 @@ do_rename (void) rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); status = rename (f1, f2); send_status (status, errno); - mhl_mem_free (f1); - mhl_mem_free (f2); + g_free (f1); + g_free (f2); } static void @@ -639,8 +643,8 @@ do_symlink (void) rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); status = symlink (f1, f2); send_status (status, errno); - mhl_mem_free (f1); - mhl_mem_free (f2); + g_free (f1); + g_free (f2); } static void @@ -652,8 +656,8 @@ do_link (void) rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); status = link (f1, f2); send_status (status, errno); - mhl_mem_free (f1); - mhl_mem_free (f2); + g_free (f1); + g_free (f2); } @@ -682,7 +686,7 @@ do_chmod (void) rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_END); status = chmod (file, mode); send_status (status, errno); - mhl_mem_free (file); + g_free (file); } static void @@ -695,7 +699,7 @@ do_chown (void) RPC_END); status = chown (file, owner, group); send_status (status, errno); - mhl_mem_free (file); + g_free (file); } static void @@ -716,13 +720,13 @@ do_utime (void) if (verbose) printf ("Got a = %s, m = %s, comp a = %ld, m = %ld\n", as, ms, atime, mtime); - mhl_mem_free (as); - mhl_mem_free (ms); + g_free (as); + g_free (ms); times.actime = (time_t) atime; times.modtime = (time_t) mtime; status = utime (file, ×); send_status (status, errno); - mhl_mem_free (file); + g_free (file); } static void diff --git a/vfs/sfs.c b/vfs/sfs.c index 705de5d6f..b9df1ad4c 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -83,7 +83,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache) vfs_die ("This cannot happen... Hopefully.\n"); if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) { - mhl_mem_free (pname); + g_free (pname); return -1; } @@ -91,19 +91,19 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache) if (!(sfs_flags[w] & F_NOLOCALCOPY)) { s = mc_getlocalcopy (pname); if (!s) { - mhl_mem_free (pname); + g_free (pname); return -1; } pqname = name_quote (s, 0); - mhl_mem_free (s); + g_free (s); } else { pqname = name_quote (pname, 0); } - mhl_mem_free (pname); + g_free (pname); #define COPY_CHAR \ if ((size_t) (t-pad) > sizeof(pad)) { \ - mhl_mem_free (pqname); \ + g_free (pqname); \ return -1; \ } \ else \ @@ -111,7 +111,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache) #define COPY_STRING(a) \ if ((t-pad)+strlen(a)>sizeof(pad)) { \ - mhl_mem_free (pqname); \ + g_free (pqname); \ return -1; \ } else { \ strcpy (t, a); \ @@ -147,7 +147,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache) } } - mhl_mem_free (pqname); + g_free (pqname); open_error_pipe (); if (my_system (EXECUTE_AS_SHELL, "/bin/sh", pad)) { close_error_pipe (D_ERROR, NULL); @@ -194,7 +194,7 @@ sfs_redirect (struct vfs_class *me, const char *name) } unlink (cache); - mhl_mem_free (cache); + g_free (cache); return "/I_MUST_NOT_EXIST"; } @@ -288,9 +288,9 @@ static void sfs_free (vfsid id) else head = cur->next; - mhl_mem_free (cur->cache); - mhl_mem_free (cur->name); - mhl_mem_free (cur); + g_free (cur->cache); + g_free (cur->name); + g_free (cur); } static void sfs_fill_names (struct vfs_class *me, fill_names_f func) @@ -344,10 +344,10 @@ static int sfs_init (struct vfs_class *me) if (!cfg){ fprintf (stderr, _("Warning: file %s not found\n"), mc_sfsini); - mhl_mem_free (mc_sfsini); + g_free (mc_sfsini); return 0; } - mhl_mem_free (mc_sfsini); + g_free (mc_sfsini); sfs_no = 0; while (sfs_no < MAXFS && fgets (key, sizeof (key), cfg)) { @@ -409,8 +409,8 @@ sfs_done (struct vfs_class *me) (void) me; for (i = 0; i < sfs_no; i++){ - mhl_mem_free (sfs_prefix [i]); - mhl_mem_free (sfs_command [i]); + g_free (sfs_prefix [i]); + g_free (sfs_command [i]); sfs_prefix [i] = sfs_command [i] = NULL; } sfs_no = 0; diff --git a/vfs/smbfs.c b/vfs/smbfs.c index db0d94525..a4e50505e 100644 --- a/vfs/smbfs.c +++ b/vfs/smbfs.c @@ -118,7 +118,7 @@ static GSList *auth_list; static inline char * free_after (char *result, char *string_to_free) { - mhl_mem_free(string_to_free); + g_free(string_to_free); return result; } @@ -126,10 +126,10 @@ free_after (char *result, char *string_to_free) static void smbfs_auth_free (struct smb_authinfo const *a) { - mhl_mem_free (a->host); - mhl_mem_free (a->share); - mhl_mem_free (a->domain); - mhl_mem_free (a->user); + g_free (a->host); + g_free (a->share); + g_free (a->domain); + g_free (a->user); wipe_password (a->password); } @@ -203,8 +203,8 @@ smbfs_auth_remove (const char *host, const char *share) list = g_slist_find_custom (auth_list, &data, smbfs_auth_cmp_host_and_share); - mhl_mem_free (data.host); - mhl_mem_free (data.share); + g_free (data.host); + g_free (data.share); if (!list) return; auth = list->data; @@ -225,9 +225,9 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket, GSList *list; if (domain && user && pass) { - mhl_mem_free (bucket->domain); - mhl_mem_free (bucket->user); - mhl_mem_free (bucket->password); + g_free (bucket->domain); + g_free (bucket->user); + g_free (bucket->password); bucket->domain = mhl_str_dup (domain); bucket->user = mhl_str_dup (user); bucket->password = mhl_str_dup (pass); @@ -262,9 +262,9 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket, (domain ? domain : lp_workgroup ()), user); if (auth) { - mhl_mem_free (bucket->domain); - mhl_mem_free (bucket->user); - mhl_mem_free (bucket->password); + g_free (bucket->domain); + g_free (bucket->user); + g_free (bucket->password); bucket->domain = mhl_str_dup (auth->domain); bucket->user = mhl_str_dup (auth->user); bucket->password = mhl_str_dup (auth->password); @@ -363,7 +363,7 @@ smbfs_fill_names (struct vfs_class *me, fill_names_f func) "/", smbfs_connections[i].service, NULL); (*func)(path); - mhl_mem_free (path); + g_free (path); } } } @@ -612,10 +612,10 @@ smbfs_reconnect(smbfs_connection *conn, int *retries) if (!(conn->cli = smbfs_do_connect(host, conn->service))) { message (D_ERROR, MSG_ERROR, _(" reconnect to %s failed\n "), conn->host); - mhl_mem_free(host); + g_free(host); return False; } - mhl_mem_free(host); + g_free(host); if (++(*retries) == 2) return False; return True; @@ -783,12 +783,12 @@ smbfs_loaddir (opendir_info *smbfs_info) smbfs_loaddir_helper, NULL) < 0) { /* cli_list returns -1 if directory empty or cannot read socket */ my_errno = cli_error (smbfs_info->conn->cli, NULL, &err, NULL); - mhl_mem_free (my_dirname); + g_free (my_dirname); return 0; } if (*(my_dirname) == 0) smbfs_info->dirname = smbfs_info->conn->service; - mhl_mem_free (my_dirname); + g_free (my_dirname); /* do_dskattr(); */ done: @@ -805,8 +805,8 @@ smbfs_free_dir (dir_entry *de) if (!de) return; smbfs_free_dir (de->next); - mhl_mem_free (de->text); - mhl_mem_free (de); + g_free (de->text); + g_free (de); } #endif @@ -855,10 +855,10 @@ smbfs_closedir (void *info) /* for (p = smbfs_info->entries; p;){ q = p; p = p->next; - mhl_mem_free (q->text); - mhl_mem_free (q); + g_free (q->text); + g_free (q); } - mhl_mem_free (info); */ + g_free (info); */ return 0; } @@ -1043,12 +1043,12 @@ smbfs_get_master_browser(char **host) static void smbfs_free_bucket (smbfs_connection *bucket) { - mhl_mem_free (bucket->host); - mhl_mem_free (bucket->service); - mhl_mem_free (bucket->domain); - mhl_mem_free (bucket->user); + g_free (bucket->host); + g_free (bucket->service); + g_free (bucket->domain); + g_free (bucket->user); wipe_password (bucket->password); - mhl_mem_free (bucket->home); + g_free (bucket->home); memset (bucket, 0, sizeof (smbfs_connection)); } @@ -1154,7 +1154,7 @@ smbfs_open_link (char *host, char *path, const char *user, int *port, if (!(*host)) { /* if blank host name, browse for servers */ if (!smbfs_get_master_browser (&host)) /* set host to ip of master browser */ return 0; /* could not find master browser? */ - mhl_mem_free (host); + g_free (host); bucket->host = mhl_str_dup (""); /* blank host means master browser */ } else bucket->host = mhl_str_dup (host); @@ -1201,11 +1201,11 @@ smbfs_get_path (smbfs_connection ** sc, const char *path) smbfs_get_host_and_username (&path, &host, &user, &port, &pass))) if ((*sc = smbfs_open_link (host, remote_path, user, &port, pass)) == NULL) { - mhl_mem_free (remote_path); + g_free (remote_path); remote_path = NULL; } - mhl_mem_free (host); - mhl_mem_free (user); + g_free (host); + g_free (user); if (pass) wipe_password (pass); @@ -1218,7 +1218,7 @@ smbfs_get_path (smbfs_connection ** sc, const char *path) if (f || !strncmp (remote_path, "/~/", 3)) { char *s; s = mhl_str_dir_plus_file ((*sc)->home, remote_path + 3 - f); - mhl_mem_free (remote_path); + g_free (remote_path); return s; } } @@ -1308,7 +1308,7 @@ smbfs_fake_share_stat (const char *server_url, const char *path, struct stat *bu smbfs_connection *sc; char *p; p = smbfs_get_path (&sc, path); - mhl_mem_free (p); + g_free (p); if (p) { memset (buf, 0, sizeof (*buf)); /* show this as dir */ @@ -1372,16 +1372,16 @@ smbfs_get_remote_stat (smbfs_connection * sc, const char *path, struct stat *buf if (cli_list (sc->cli, mypath, attribute, smbfs_loaddir_helper, single_entry) < 1) { my_errno = ENOENT; - mhl_mem_free (mypath); + g_free (mypath); return -1; /* cli_list returns number of files */ } memcpy (buf, &single_entry->my_stat, sizeof (struct stat)); /* don't free here, use for smbfs_fstat() */ -/* mhl_mem_free(single_entry->text); - mhl_mem_free(single_entry); */ - mhl_mem_free (mypath); +/* g_free(single_entry->text); + g_free(single_entry); */ + g_free (mypath); return 0; } @@ -1439,11 +1439,11 @@ smbfs_get_stat_info (smbfs_connection * sc, const char *path, struct stat *buf) memset (buf, 0, sizeof (struct stat)); buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask; memcpy (&single_entry->my_stat, buf, sizeof (struct stat)); - mhl_mem_free (mdp); + g_free (mdp); DEBUG (1, (" PARENT:found in %s\n", current_info->dirname)); return 0; } - mhl_mem_free (mdp); + g_free (mdp); } /* now try to identify as CURRENT dir? */ { @@ -1501,7 +1501,7 @@ smbfs_chdir (struct vfs_class *me, const char *path) DEBUG (3, ("smbfs_chdir(path:%s)\n", path)); if (!(remote_dir = smbfs_get_path (&sc, path))) return -1; - mhl_mem_free (remote_dir); + g_free (remote_dir); return 0; } @@ -1520,7 +1520,7 @@ smbfs_loaddir_by_name (struct vfs_class *me, const char *path) DEBUG(6, ("smbfs_loaddir_by_name(%s)\n", mypath)); smbfs_chdir(me, mypath); info = smbfs_opendir (me, mypath); - mhl_mem_free(mypath); + g_free(mypath); if (!info) return -1; smbfs_readdir(info); @@ -1598,7 +1598,7 @@ smbfs_stat (struct vfs_class * me, const char *path, struct stat *buf) DEBUG (1, ("smbfs_stat: showing server as directory\n")); memset (buf, 0, sizeof (struct stat)); buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask; - mhl_mem_free (service); + g_free (service); return 0; } } @@ -1619,12 +1619,12 @@ smbfs_stat (struct vfs_class * me, const char *path, struct stat *buf) if (strncmp (p, pp, strlen (p)) != 0) { DEBUG (6, ("desired '%s' is not loaded, we have '%s'\n", p, pp)); if (smbfs_loaddir_by_name (me, path) < 0) { - mhl_mem_free (service); + g_free (service); return -1; } DEBUG (6, ("loaded dir: '%s'\n", current_info->dirname)); } - mhl_mem_free (service); + g_free (service); /* stat dirs & files under shares now */ return smbfs_get_stat_info (sc, path, buf); } @@ -1686,17 +1686,17 @@ smbfs_mkdir (struct vfs_class * me, const char *path, mode_t mode) DEBUG (3, ("smbfs_mkdir(path:%s, mode:%d)\n", path, (int) mode)); if ((remote_file = smbfs_get_path (&sc, path)) == 0) return -1; - mhl_mem_free (remote_file); + g_free (remote_file); cpath = smbfs_convert_path (path, FALSE); if (!cli_mkdir (sc->cli, cpath)) { my_errno = cli_error (sc->cli, NULL, &err, NULL); message (D_ERROR, MSG_ERROR, _(" Error %s creating directory %s "), cli_errstr (sc->cli), CNV_LANG (cpath)); - mhl_mem_free (cpath); + g_free (cpath); return -1; } - mhl_mem_free (cpath); + g_free (cpath); return 0; } @@ -1712,18 +1712,18 @@ smbfs_rmdir (struct vfs_class *me, const char *path) DEBUG(3, ("smbfs_rmdir(path:%s)\n", path)); if ((remote_file = smbfs_get_path (&sc, path)) == 0) return -1; - mhl_mem_free (remote_file); + g_free (remote_file); cpath = smbfs_convert_path (path, FALSE); if (!cli_rmdir(sc->cli, cpath)) { my_errno = cli_error(sc->cli, NULL, &err, NULL); message (D_ERROR, MSG_ERROR, _(" Error %s removing directory %s "), cli_errstr(sc->cli), CNV_LANG(cpath)); - mhl_mem_free (cpath); + g_free (cpath); return -1; } - mhl_mem_free (cpath); + g_free (cpath); return 0; } @@ -1763,7 +1763,7 @@ smbfs_forget (const char *path) path += 2; if ((p = smbfs_get_host_and_username (&path, &host, &user, &port, NULL))) { - mhl_mem_free (p); + g_free (p); for (i = 0; i < SMBFS_MAX_CONNECTIONS; i++) { if (smbfs_connections[i].cli && (strcmp (host, smbfs_connections[i].host) == 0) @@ -1779,8 +1779,8 @@ smbfs_forget (const char *path) } } } - mhl_mem_free (host); - mhl_mem_free (user); + g_free (host); + g_free (user); } static int @@ -1877,9 +1877,9 @@ smbfs_open (struct vfs_class *me, const char *file, int flags, int mode) ret = smbfs_open_readwrite (remote_handle, remote_file, flags, mode); - mhl_mem_free (remote_file); + g_free (remote_file); if (!ret) - mhl_mem_free (remote_handle); + g_free (remote_handle); return ret; } @@ -1900,10 +1900,10 @@ smbfs_unlink (struct vfs_class *me, const char *path) if (!cli_unlink(sc->cli, remote_file)) { message (D_ERROR, MSG_ERROR, _(" %s removing remote file %s "), cli_errstr(sc->cli), CNV_LANG(remote_file)); - mhl_mem_free (remote_file); + g_free (remote_file); return -1; } - mhl_mem_free (remote_file); + g_free (remote_file); return 0; } @@ -1920,7 +1920,7 @@ smbfs_rename (struct vfs_class *me, const char *a, const char *b) return -1; if ((rb = smbfs_get_path (&sc, b)) == 0) { - mhl_mem_free (ra); + g_free (ra); return -1; } @@ -1929,8 +1929,8 @@ smbfs_rename (struct vfs_class *me, const char *a, const char *b) retval = cli_rename(sc->cli, ra, rb); - mhl_mem_free (ra); - mhl_mem_free (rb); + g_free (ra); + g_free (rb); if (!retval) { message (D_ERROR, MSG_ERROR, _(" %s renaming files\n"), diff --git a/vfs/tar.c b/vfs/tar.c index eda0e7a9c..12a4c8f34 100644 --- a/vfs/tar.c +++ b/vfs/tar.c @@ -35,8 +35,6 @@ #include #endif -#include - #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -248,7 +246,7 @@ tar_open_archive_int (struct vfs_class *me, const char *name, result = mc_open (s, O_RDONLY); if (result == -1) message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), s); - mhl_mem_free (s); + g_free (s); if (result == -1) ERRNOR (ENOENT, -1); } @@ -496,13 +494,13 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, longp = ((header->header.linkflag == LF_LONGNAME) ? &next_long_name : &next_long_link); - mhl_mem_free (*longp); + g_free (*longp); bp = *longp = g_malloc (*h_size + 1); for (size = *h_size; size > 0; size -= written) { data = tar_get_next_record (archive, tard)->charptr; if (data == NULL) { - mhl_mem_free (*longp); + g_free (*longp); *longp = NULL; message (D_ERROR, MSG_ERROR, _("Unexpected EOF on archive file")); @@ -517,7 +515,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, } if (bp - *longp == MC_MAXPATHLEN && bp[-1] != '\0') { - mhl_mem_free (*longp); + g_free (*longp); *longp = NULL; message (D_ERROR, MSG_ERROR, _("Inconsistent tar archive")); return STATUS_BADCHECKSUM; @@ -562,8 +560,8 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, PREFIX_SIZE); current_file_name = g_strconcat (temp_prefix, PATH_SEP_STR, temp_name, (char *) NULL); - mhl_mem_free (temp_name); - mhl_mem_free (temp_prefix); + g_free (temp_name); + g_free (temp_prefix); } break; case TAR_GNU: @@ -607,7 +605,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, } else { entry = vfs_s_new_entry (me, p, inode); vfs_s_insert_entry (me, parent, entry); - mhl_mem_free (current_link_name); + g_free (current_link_name); goto done; } } @@ -619,12 +617,12 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, if (*current_link_name) { inode->linkname = current_link_name; } else if (current_link_name != next_long_link) { - mhl_mem_free (current_link_name); + g_free (current_link_name); } entry = vfs_s_new_entry (me, p, inode); vfs_s_insert_entry (me, parent, entry); - mhl_mem_free (current_file_name); + g_free (current_file_name); done: next_long_link = next_long_name = NULL; diff --git a/vfs/undelfs.c b/vfs/undelfs.c index f4f514148..a10273f15 100644 --- a/vfs/undelfs.c +++ b/vfs/undelfs.c @@ -35,8 +35,8 @@ */ #include - #include + #include #include @@ -101,11 +101,11 @@ undelfs_shutdown (void) if (fs) ext2fs_close (fs); fs = NULL; - mhl_mem_free (ext2_fname); + g_free (ext2_fname); ext2_fname = NULL; - mhl_mem_free (delarray); + g_free (delarray); delarray = NULL; - mhl_mem_free (block_buf); + g_free (block_buf); block_buf = NULL; } @@ -146,7 +146,7 @@ undelfs_get_path (const char *dirname, char **fsname, char **file) *file = mhl_str_dup (p+1); tmp = g_strndup (dirname, p - dirname); *fsname = g_strconcat ("/dev/", tmp, (char *) NULL); - mhl_mem_free (tmp); + g_free (tmp); return; } p--; @@ -276,10 +276,10 @@ undelfs_loaddel (void) error_out: ext2fs_close_inode_scan (scan); free_block_buf: - mhl_mem_free (block_buf); + g_free (block_buf); block_buf = NULL; free_delarray: - mhl_mem_free (delarray); + g_free (delarray); delarray = NULL; return 0; } @@ -301,7 +301,7 @@ com_err (const char *whoami, long err_code, const char *fmt, ...) message (D_ERROR, _(" Ext2lib error "), " %s (%s: %ld) ", str, whoami, err_code); - mhl_mem_free (str); + g_free (str); } static void * @@ -314,7 +314,7 @@ undelfs_opendir (struct vfs_class *me, const char *dirname) return 0; /* We don't use the file name */ - mhl_mem_free (f); + g_free (f); if (!ext2_fname || strcmp (ext2_fname, file)){ undelfs_shutdown (); @@ -322,7 +322,7 @@ undelfs_opendir (struct vfs_class *me, const char *dirname) } else { /* To avoid expensive re-scannings */ readdir_ptr = READDIR_PTR_INIT; - mhl_mem_free (file); + g_free (file); return fs; } @@ -418,8 +418,8 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode) if (!ext2_fname || strcmp (ext2_fname, file)) { message (D_ERROR, undelfserr, _(" You have to chdir to extract files first ")); - mhl_mem_free (file); - mhl_mem_free (f); + g_free (file); + g_free (f); return 0; } inode = atol (f); @@ -432,15 +432,15 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode) /* Found: setup all the structures needed by read */ p = (undelfs_file *) g_try_malloc (((gsize) sizeof (undelfs_file))); if (!p) { - mhl_mem_free (file); - mhl_mem_free (f); + g_free (file); + g_free (f); return 0; } p->buf = g_try_malloc (fs->blocksize); if (!p->buf) { - mhl_mem_free (p); - mhl_mem_free (file); - mhl_mem_free (f); + g_free (p); + g_free (file); + g_free (f); return 0; } p->inode = inode; @@ -450,8 +450,8 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode) p->pos = 0; p->size = delarray[i].size; } - mhl_mem_free (file); - mhl_mem_free (f); + g_free (file); + g_free (f); undelfs_usage++; return p; } @@ -460,8 +460,8 @@ static int undelfs_close (void *vfs_info) { undelfs_file *p = vfs_info; - mhl_mem_free (p->buf); - mhl_mem_free (p); + g_free (p->buf); + g_free (p); undelfs_usage--; return 0; } @@ -595,20 +595,20 @@ undelfs_lstat (struct vfs_class *me, const char *path, struct stat *buf) f = "sda1" f ="401:1" If the first char in f is no digit -> return error */ if (!isdigit (*f)) { - mhl_mem_free (file); - mhl_mem_free (f); + g_free (file); + g_free (f); return -1; } if (!ext2_fname || strcmp (ext2_fname, file)){ message (D_ERROR, undelfserr, _(" You have to chdir to extract files first ")); - mhl_mem_free (file); - mhl_mem_free (f); + g_free (file); + g_free (f); return 0; } inode_index = undelfs_getindex (f); - mhl_mem_free (file); - mhl_mem_free (f); + g_free (file); + g_free (f); if (inode_index == -1) return -1; @@ -641,13 +641,13 @@ undelfs_chdir(struct vfs_class *me, const char *path) /* our vfs, but that is left as an excercise for the reader */ if ((fd = open (file, O_RDONLY)) == -1){ message (D_ERROR, undelfserr, _(" Cannot open file %s "), file); - mhl_mem_free (f); - mhl_mem_free (file); + g_free (f); + g_free (file); return -1; } close (fd); - mhl_mem_free (f); - mhl_mem_free (file); + g_free (f); + g_free (file); return 0; } @@ -667,8 +667,8 @@ undelfs_getid (struct vfs_class *me, const char *path) if (!fsname) return NULL; - mhl_mem_free (fname); - mhl_mem_free (fsname); + g_free (fname); + g_free (fsname); return (vfsid) fs; } diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c index 980141d41..08cb3dd80 100644 --- a/vfs/utilvfs.c +++ b/vfs/utilvfs.c @@ -138,7 +138,7 @@ vfs_split_url (const char *path, char **host, char **user, int *port, if (host) *host = mhl_str_dup (rest); - mhl_mem_free (pcopy); + g_free (pcopy); return retval; } #endif /* USE_NETCODE */ @@ -243,7 +243,7 @@ vfs_mkstemps (char **pname, const char *prefix, const char *basename) *q = 0; fd = mc_mkstemps (pname, prefix, suffix); - mhl_mem_free (suffix); + g_free (suffix); return fd; } @@ -874,7 +874,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, t[p] = 0; } - mhl_mem_free (p_copy); + g_free (p_copy); return 1; error: @@ -889,7 +889,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, _("More parsing errors will be ignored.")); } - mhl_mem_free (p_copy); + g_free (p_copy); return 0; } diff --git a/vfs/vfs.c b/vfs/vfs.c index c373f7f57..dba06198c 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -38,7 +38,6 @@ #include #include /* is_digit() */ -#include #include #include "../src/global.h" @@ -223,7 +222,7 @@ path_magic (const char *path) /* * Splits path '/p1#op/inpath' into inpath,op; returns which vfs it is. - * What is left in path is p1. You still want to mhl_mem_free(path), you DON'T + * What is left in path is p1. You still want to g_free(path), you DON'T * want to free neither *inpath nor *op */ struct vfs_class * @@ -304,7 +303,7 @@ vfs_get_class (const char *pathname) char *path = mhl_str_dup (pathname); vfs = _vfs_get_class (path); - mhl_mem_free (path); + g_free (path); if (!vfs) vfs = localfs_class; @@ -338,13 +337,13 @@ mc_open (const char *filename, int flags, ...) mode = 0; if (!vfs->open) { - mhl_mem_free (file); + g_free (file); errno = -EOPNOTSUPP; return -1; } info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */ - mhl_mem_free (file); + g_free (file); if (!info){ errno = ferrno (vfs); return -1; @@ -362,7 +361,7 @@ int mc_##name inarg \ char *mpath = vfs_canon (path); \ vfs = vfs_get_class (mpath); \ result = vfs->name ? (*vfs->name)callarg : -1; \ - mhl_mem_free (mpath); \ + g_free (mpath); \ if (result == -1) \ errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ return result; \ @@ -407,13 +406,13 @@ int mc_##name (const char *fname1, const char *fname2) \ name2 = vfs_canon (fname2); \ if (vfs != vfs_get_class (name2)){ \ errno = EXDEV; \ - mhl_mem_free (name1); \ - mhl_mem_free (name2); \ + g_free (name1); \ + g_free (name2); \ return -1; \ } \ result = vfs->name ? (*vfs->name)(vfs, name1, name2) : -1; \ - mhl_mem_free (name1); \ - mhl_mem_free (name2); \ + g_free (name1); \ + g_free (name2); \ if (result == -1) \ errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ return result; \ @@ -444,7 +443,7 @@ mc_setctl (const char *path, int ctlop, void *arg) mpath = vfs_canon (path); vfs = vfs_get_class (mpath); result = vfs->setctl ? (*vfs->setctl)(vfs, mpath, ctlop, arg) : 0; - mhl_mem_free (mpath); + g_free (mpath); return result; } @@ -483,7 +482,7 @@ mc_opendir (const char *dirname) vfs = vfs_get_class (dname); info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL; - mhl_mem_free (dname); + g_free (dname); if (!info){ errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP; return NULL; @@ -524,7 +523,7 @@ mc_closedir (DIR *dirp) result = vfs->closedir ? (*vfs->closedir)(vfs_info (handle)) : -1; vfs_free_handle (handle); - mhl_mem_free (dirp); + g_free (dirp); return result; } @@ -534,7 +533,7 @@ int mc_stat (const char *filename, struct stat *buf) { char *path; path = vfs_canon (filename); vfs = vfs_get_class (path); result = vfs->stat ? (*vfs->stat) (vfs, path, buf) : -1; - mhl_mem_free (path); + g_free (path); if (result == -1) errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; return result; @@ -546,7 +545,7 @@ int mc_lstat (const char *filename, struct stat *buf) { char *path; path = vfs_canon (filename); vfs = vfs_get_class (path); result = vfs->lstat ? (*vfs->lstat) (vfs, path, buf) : -1; - mhl_mem_free (path); + g_free (path); if (result == -1) errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; return result; @@ -585,11 +584,11 @@ _vfs_get_cwd (void) || mc_stat (current_dir, &my_stat2) || my_stat.st_ino != my_stat2.st_ino || my_stat.st_dev != my_stat2.st_dev) { - mhl_mem_free (current_dir); + g_free (current_dir); current_dir = p; return p; } /* Otherwise we return current_dir below */ - mhl_mem_free (p); + g_free (p); } return current_dir; } @@ -662,7 +661,7 @@ vfs_canon (const char *path) local = mhl_str_dir_plus_file (current_dir, path); result = vfs_canon (local); - mhl_mem_free (local); + g_free (local); return result; } @@ -692,7 +691,7 @@ mc_chdir (const char *path) new_dir = vfs_canon (path); new_vfs = vfs_get_class (new_dir); if (!new_vfs->chdir) { - mhl_mem_free (new_dir); + g_free (new_dir); return -1; } @@ -700,7 +699,7 @@ mc_chdir (const char *path) if (result == -1) { errno = ferrno (new_vfs); - mhl_mem_free (new_dir); + g_free (new_dir); return -1; } @@ -708,7 +707,7 @@ mc_chdir (const char *path) old_vfs = current_vfs; /* Actually change directory */ - mhl_mem_free (current_dir); + g_free (current_dir); current_dir = new_dir; current_vfs = new_vfs; @@ -742,7 +741,7 @@ vfs_file_class_flags (const char *filename) fname = vfs_canon (filename); vfs = vfs_get_class (fname); - mhl_mem_free (fname); + g_free (fname); return vfs->flags; } @@ -787,7 +786,7 @@ mc_def_getlocalcopy (const char *filename) close (fdout); if (fdin != -1) mc_close (fdin); - mhl_mem_free (tmp); + g_free (tmp); return NULL; } @@ -800,7 +799,7 @@ mc_getlocalcopy (const char *pathname) result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs, path) : mc_def_getlocalcopy (path); - mhl_mem_free (path); + g_free (path); if (!result) errno = ferrno (vfs); return result; @@ -863,7 +862,7 @@ mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed) return_value = vfs->ungetlocalcopy ? (*vfs->ungetlocalcopy)(vfs, path, local, has_changed) : mc_def_ungetlocalcopy (vfs, path, local, has_changed); - mhl_mem_free (path); + g_free (path); return return_value; } @@ -907,7 +906,7 @@ vfs_shut (void) vfs_gc_done (); - mhl_mem_free (current_dir); + g_free (current_dir); for (vfs = vfs_list; vfs; vfs = vfs->next) if (vfs->done)