diff --git a/ChangeLog b/ChangeLog index f350557f0..174e3aaaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,7 +22,12 @@ * syntax/Syntax, syntax/Makefile.am, syntax/vhdl.syntax: added VHDL syntax (#193) * replaced calls to g_strdup() by mhl_str_dup() +2009-01-30 Enrico Weigelt, metux ITS + + * replaced calls to g_free() by mhl_mem_free() + 2009-01-29 Mikhail S. Pobolovets + * lib/mc.ext.in: update for OpenOffice and StarOffice viewer. odt2txt is now used diff --git a/edit/bookmark.c b/edit/bookmark.c index 403b93c33..bb5c6b1f4 100644 --- a/edit/bookmark.c +++ b/edit/bookmark.c @@ -28,11 +28,12 @@ #include #include #include - #include #include #include +#include + #include "../src/global.h" #include "edit.h" @@ -158,13 +159,13 @@ int book_mark_clear (WEdit * edit, int line, int c) p->prev->next = p->next; if (p->next) p->next->prev = p->prev; - g_free (p); + mhl_mem_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) { - g_free (edit->book_mark); + mhl_mem_free (edit->book_mark); edit->book_mark = 0; } return r; @@ -185,11 +186,11 @@ void book_mark_flush (WEdit * edit, int c) q->prev->next = q->next; if (p) p->prev = q->prev; - g_free (q); + mhl_mem_free (q); } } if (!edit->book_mark->next) { - g_free (edit->book_mark); + mhl_mem_free (edit->book_mark); edit->book_mark = 0; } } diff --git a/edit/choosesyntax.c b/edit/choosesyntax.c index 47628eb53..886fe90a3 100644 --- a/edit/choosesyntax.c +++ b/edit/choosesyntax.c @@ -18,6 +18,7 @@ #include +#include #include #include "edit.h" @@ -73,9 +74,9 @@ edit_syntax_dialog (void) { if ((syntax = exec_edit_syntax_dialog ((const char**) names)) < 0) { for (i = 0; names[i]; i++) { - g_free (names[i]); + mhl_mem_free (names[i]); } - g_free (names); + mhl_mem_free (names); return; } @@ -91,7 +92,7 @@ edit_syntax_dialog (void) { break; default: option_auto_syntax = 0; - g_free (option_syntax_type); + mhl_mem_free (option_syntax_type); option_syntax_type = mhl_str_dup (names[syntax - N_DFLT_ENTRIES]); } @@ -103,8 +104,8 @@ edit_syntax_dialog (void) { edit_load_syntax (wedit, NULL, option_syntax_type); for (i = 0; names[i]; i++) { - g_free (names[i]); + mhl_mem_free (names[i]); } - g_free (names); - g_free (old_syntax_type); + mhl_mem_free (names); + mhl_mem_free (old_syntax_type); } diff --git a/edit/edit.c b/edit/edit.c index bec84d78d..82cca0dbb 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -22,6 +22,7 @@ */ #include + #include #include #include @@ -32,6 +33,7 @@ #include #include +#include #include #include "../src/global.h" @@ -217,7 +219,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); - g_free (quoted_name); + mhl_mem_free (quoted_name); return p; } @@ -233,7 +235,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); - g_free (writename); + mhl_mem_free (writename); return p; } @@ -277,7 +279,7 @@ edit_insert_file (WEdit *edit, const char *filename) g_string_sprintf (errmsg, _(" Error reading from pipe: %s "), p); edit_error_dialog (_("Error"), errmsg->str); g_string_free (errmsg, TRUE); - g_free (p); + mhl_mem_free (p); return 0; } } else { @@ -285,10 +287,10 @@ edit_insert_file (WEdit *edit, const char *filename) g_string_sprintf (errmsg, _(" Cannot open pipe for reading: %s "), p); edit_error_dialog (_("Error"), errmsg->str); g_string_free (errmsg, TRUE); - g_free (p); + mhl_mem_free (p); return 0; } - g_free (p); + mhl_mem_free (p); } else { int i, file, blocklen; long current = edit->curs1; @@ -301,7 +303,7 @@ edit_insert_file (WEdit *edit, const char *filename) edit_insert (edit, buf[i]); } edit_cursor_move (edit, current - edit->curs1); - g_free (buf); + mhl_mem_free (buf); mc_close (file); if (blocklen) return 0; @@ -448,7 +450,7 @@ edit_load_position (WEdit *edit) filename = vfs_canon (edit->filename); load_file_position (filename, &line, &column); - g_free (filename); + mhl_mem_free (filename); edit_move_to_line (edit, line - 1); edit->prev_col = column; @@ -467,7 +469,7 @@ edit_save_position (WEdit *edit) filename = vfs_canon (edit->filename); save_file_position (filename, edit->curs_line + 1, edit->curs_col); - g_free (filename); + mhl_mem_free (filename); } /* Clean the WEdit stricture except the widget part */ @@ -541,7 +543,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) - g_free (edit); + mhl_mem_free (edit); return 0; } edit->loading_done = 1; @@ -592,13 +594,13 @@ edit_clean (WEdit *edit) edit_free_syntax_rules (edit); book_mark_flush (edit, -1); for (; j <= MAXBUFF; j++) { - g_free (edit->buffers1[j]); - g_free (edit->buffers2[j]); + mhl_mem_free (edit->buffers1[j]); + mhl_mem_free (edit->buffers2[j]); } - g_free (edit->undo_stack); - g_free (edit->filename); - g_free (edit->dir); + mhl_mem_free (edit->undo_stack); + mhl_mem_free (edit->filename); + mhl_mem_free (edit->dir); edit_purge_widget (edit); @@ -638,12 +640,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)) { - g_free (e); + mhl_mem_free (e); return 0; } edit_clean (edit); memcpy (edit, e, sizeof (WEdit)); - g_free (e); + mhl_mem_free (e); return 1; } @@ -929,7 +931,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)) { - g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); + mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = NULL; } edit->last_byte--; @@ -966,7 +968,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)) { - g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); + mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL; } edit->last_byte--; @@ -1051,7 +1053,7 @@ edit_move_backward_lots (WEdit *edit, long increment) edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE); } else { - g_free (p); + mhl_mem_free (p); } s = edit->curs1 & M_EDIT_BUF_SIZE; @@ -1089,7 +1091,7 @@ edit_move_backward_lots (WEdit *edit, long increment) edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE); } else { - g_free (p); + mhl_mem_free (p); } } return edit_get_byte (edit, edit->curs1); @@ -1125,7 +1127,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)) { - g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); + mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL; } edit->curs1--; @@ -1149,7 +1151,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)) { - g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); + mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = 0; } edit->curs2--; @@ -2699,5 +2701,5 @@ user_menu (WEdit * edit) edit->force |= REDRAW_COMPLETELY; cleanup: - g_free (block_file); + mhl_mem_free (block_file); } diff --git a/edit/editcmd.c b/edit/editcmd.c index 33c067100..2f246e76c 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -37,6 +37,7 @@ #include #include +#include #include #include "../src/global.h" @@ -166,7 +167,7 @@ catstrs (const char *first,...) len++; i = (i + 1) % 16; - g_free (stacked[i]); + mhl_mem_free (stacked[i]); stacked[i] = g_malloc (len); va_end (ap); @@ -185,7 +186,7 @@ void freestrs(void) size_t i; for (i = 0; i < sizeof(stacked) / sizeof(stacked[0]); i++) { - g_free (stacked[i]); + mhl_mem_free (stacked[i]); stacked[i] = NULL; } } @@ -237,7 +238,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); - g_free (savename); + mhl_mem_free (savename); } this_save_mode = option_save_mode; @@ -340,7 +341,7 @@ edit_save_file (WEdit *edit, const char *filename) edit_error_dialog (_("Error"), catstrs (_(" Error writing to pipe: "), p, " ", (char *) NULL)); - g_free (p); + mhl_mem_free (p); goto error_save; } #endif @@ -350,10 +351,10 @@ edit_save_file (WEdit *edit, const char *filename) (_ (" Cannot open pipe for writing: "), p, " ", (char *) NULL))); - g_free (p); + mhl_mem_free (p); goto error_save; } - g_free (p); + mhl_mem_free (p); } else { long buf; buf = 0; @@ -414,14 +415,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; - g_free (savename); + mhl_mem_free (savename); return 1; error_save: /* FIXME: Is this safe ? * if (this_save_mode != EDIT_QUICK_SAVE) * mc_unlink (savename); */ - g_free (savename); + mhl_mem_free (savename); return 0; } @@ -492,7 +493,7 @@ void menu_save_mode_cmd (void) return; option_save_mode = save_mode_new; - g_free (option_backup_ext); + mhl_mem_free (option_backup_ext); option_backup_ext = str_result; str_result = NULL; } @@ -500,7 +501,7 @@ void menu_save_mode_cmd (void) void edit_set_filename (WEdit *edit, const char *f) { - g_free (edit->filename); + mhl_mem_free (edit->filename); if (!f) f = ""; edit->filename = mhl_str_dup (f); @@ -529,7 +530,7 @@ edit_save_as_cmd (WEdit *edit) if (exp) { if (!*exp) { - g_free (exp); + mhl_mem_free (exp); edit->force |= REDRAW_COMPLETELY; return 0; } else { @@ -546,7 +547,7 @@ edit_save_as_cmd (WEdit *edit) _(" A file already exists with this name. "), _("&Overwrite"), _("&Cancel"))) { edit->force |= REDRAW_COMPLETELY; - g_free (exp); + mhl_mem_free (exp); return 0; } } @@ -572,7 +573,7 @@ edit_save_as_cmd (WEdit *edit) } edit_set_filename (edit, exp); - g_free (exp); + mhl_mem_free (exp); edit->modified = 0; edit->delete_file = 0; if (different_filename) @@ -588,7 +589,7 @@ edit_save_as_cmd (WEdit *edit) /* Failed, so maintain modify (not save) lock */ if (save_lock) edit_unlock_file (exp); - g_free (exp); + mhl_mem_free (exp); edit->force |= REDRAW_COMPLETELY; return 0; } @@ -880,13 +881,13 @@ edit_load_file_from_filename (WEdit * edit, char *exp) char *prev_filename = mhl_str_dup (edit->filename); if (!edit_reload (edit, exp)) { - g_free (prev_filename); + mhl_mem_free (prev_filename); return 1; } if (prev_locked) edit_unlock_file (prev_filename); - g_free (prev_filename); + mhl_mem_free (prev_filename); return 0; } @@ -912,7 +913,7 @@ edit_load_cmd (WEdit *edit) if (exp) { if (*exp) edit_load_file_from_filename (edit, exp); - g_free (exp); + mhl_mem_free (exp); } edit->force |= REDRAW_COMPLETELY; return 0; @@ -1013,7 +1014,7 @@ edit_block_copy_cmd (WEdit *edit) edit_insert_ahead (edit, copy_buf[size]); } - g_free (copy_buf); + mhl_mem_free (copy_buf); edit_scroll_screen_over_cursor (edit); if (column_highlighting) { @@ -1114,7 +1115,7 @@ edit_block_move_cmd (WEdit *edit) edit->curs1 + end_mark - start_mark, 0, 0); } edit_scroll_screen_over_cursor (edit); - g_free (copy_buf); + mhl_mem_free (copy_buf); edit->force |= REDRAW_PAGE; } @@ -1450,7 +1451,7 @@ string_regexp_search (char *pattern, char *string, int match_type, || old_type != match_type || old_icase != icase) { if (old_pattern) { regfree (&r); - g_free (old_pattern); + mhl_mem_free (old_pattern); old_pattern = 0; } if (regcomp (&r, pattern, REG_EXTENDED | (icase ? REG_ICASE : 0) | @@ -1826,9 +1827,9 @@ edit_replace_cmd (WEdit *edit, int again) int argord[NUM_REPL_ARGS]; if (!edit) { - g_free (saved1), saved1 = NULL; - g_free (saved2), saved2 = NULL; - g_free (saved3), saved3 = NULL; + mhl_mem_free (saved1), saved1 = NULL; + mhl_mem_free (saved2), saved2 = NULL; + mhl_mem_free (saved3), saved3 = NULL; return; } @@ -1856,9 +1857,9 @@ edit_replace_cmd (WEdit *edit, int again) edit_replace_dialog (edit, disp1, disp2, disp3, &input1, &input2, &input3); - g_free (disp1); - g_free (disp2); - g_free (disp3); + mhl_mem_free (disp1); + mhl_mem_free (disp2); + mhl_mem_free (disp3); convert_from_input (input1); convert_from_input (input2); @@ -1870,10 +1871,9 @@ edit_replace_cmd (WEdit *edit, int again) goto cleanup; } - g_free (saved1), saved1 = mhl_str_dup (input1); - g_free (saved2), saved2 = mhl_str_dup (input2); - g_free (saved3), saved3 = mhl_str_dup (input3); - + 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); } { @@ -2064,9 +2064,9 @@ edit_replace_cmd (WEdit *edit, int again) edit->force = REDRAW_COMPLETELY; edit_scroll_screen_over_cursor (edit); cleanup: - g_free (input1); - g_free (input2); - g_free (input3); + mhl_mem_free (input1); + mhl_mem_free (input2); + mhl_mem_free (input3); } @@ -2078,7 +2078,7 @@ void edit_search_cmd (WEdit * edit, int again) char *exp = ""; if (!edit) { - g_free (old); + mhl_mem_free (old); old = NULL; return; } @@ -2108,7 +2108,7 @@ void edit_search_cmd (WEdit * edit, int again) if (exp) { if (*exp) { int len = 0; - g_free (old); + mhl_mem_free (old); old = mhl_str_dup (exp); if (search_create_bookmark) { @@ -2165,7 +2165,7 @@ void edit_search_cmd (WEdit * edit, int again) } } } - g_free (exp); + mhl_mem_free (exp); } edit->force |= REDRAW_COMPLETELY; edit_scroll_screen_over_cursor (edit); @@ -2204,7 +2204,7 @@ edit_ok_to_exit (WEdit *edit) #define TEMP_BUF_LEN 1024 -/* Return a null terminated length of text. Result must be g_free'd */ +/* Return a null terminated length of text. Result must be mhl_mem_free'd */ static unsigned char * edit_get_block (WEdit *edit, long start, long finish, int *l) { @@ -2257,7 +2257,7 @@ edit_save_block (WEdit * edit, const char *filename, long start, p += r; len -= r; } - g_free (block); + mhl_mem_free (block); } else { unsigned char *buf; int i = start, end; @@ -2270,7 +2270,7 @@ edit_save_block (WEdit * edit, const char *filename, long start, len -= mc_write (file, (char *) buf, end - start); start = end; } - g_free (buf); + mhl_mem_free (buf); } mc_close (file); if (len) @@ -2344,13 +2344,13 @@ edit_goto_cmd (WEdit *edit) return; if (!*f) { - g_free (f); + mhl_mem_free (f); return; } l = strtol (f, &error, 0); if (*error) { - g_free (f); + mhl_mem_free (f); return; } @@ -2360,7 +2360,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; - g_free (f); + mhl_mem_free (f); } @@ -2379,15 +2379,15 @@ edit_save_block_cmd (WEdit *edit) edit_push_action (edit, KEY_PRESS + edit->start_display); if (exp) { if (!*exp) { - g_free (exp); + mhl_mem_free (exp); return 0; } else { if (edit_save_block (edit, exp, start_mark, end_mark)) { - g_free (exp); + mhl_mem_free (exp); edit->force |= REDRAW_COMPLETELY; return 1; } else { - g_free (exp); + mhl_mem_free (exp); edit_error_dialog (_(" Save Block "), get_sys_error (_ (" Cannot save file. "))); @@ -2409,15 +2409,15 @@ edit_insert_file_cmd (WEdit *edit) edit_push_action (edit, KEY_PRESS + edit->start_display); if (exp) { if (!*exp) { - g_free (exp); + mhl_mem_free (exp); return 0; } else { if (edit_insert_file (edit, exp)) { - g_free (exp); + mhl_mem_free (exp); edit->force |= REDRAW_COMPLETELY; return 1; } else { - g_free (exp); + mhl_mem_free (exp); edit_error_dialog (_(" Insert File "), get_sys_error (_ (" Cannot insert file. "))); @@ -2448,7 +2448,7 @@ int edit_sort_cmd (WEdit * edit) if (!exp) return 1; - g_free (old); + mhl_mem_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)); @@ -2492,7 +2492,7 @@ edit_ext_cmd (WEdit *edit) return 1; e = system (catstrs (exp, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL)); - g_free (exp); + mhl_mem_free (exp); if (e) { edit_error_dialog (_("External command"), @@ -2588,7 +2588,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)); } - g_free (quoted_name); + mhl_mem_free (quoted_name); close_error_pipe (D_NORMAL, NULL); edit_refresh_cmd (edit); @@ -2629,13 +2629,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); - g_free (to); - g_free (subject); - g_free (cc); + mhl_mem_free (to); + mhl_mem_free (subject); + mhl_mem_free (cc); if (s) { p = popen (s, "w"); - g_free (s); + mhl_mem_free (s); } if (p) { @@ -2694,9 +2694,9 @@ void edit_mail_dialog (WEdit * edit) Quick_input.widgets = quick_widgets; if (quick_dialog (&Quick_input) != B_CANCEL) { - g_free (mail_cc_last); - g_free (mail_subject_last); - g_free (mail_to_last); + mhl_mem_free (mail_cc_last); + mhl_mem_free (mail_subject_last); + mhl_mem_free (mail_to_last); mail_cc_last = tmail_cc; mail_subject_last = tmail_subject; mail_to_last = tmail_to; @@ -2938,10 +2938,10 @@ edit_complete_word_cmd (WEdit *edit) } } - g_free (match_expr); + mhl_mem_free (match_expr); /* release memory before return */ for (i = 0; i < num_compl; i++) - g_free (compl[i].text); + mhl_mem_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 b19139163..68a9033d6 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -34,6 +34,8 @@ #include #include +#include + #include "../src/global.h" #include "edit.h" @@ -145,7 +147,7 @@ edit_status (WEdit *edit) printwstr (status, w - (fname_len + gap)); attrset (EDITOR_NORMAL_COLOR); - g_free (status); + mhl_mem_free (status); } /* this scrolls the text so that cursor is on the screen */ diff --git a/edit/editlock.c b/edit/editlock.c index 72e433c80..50682974c 100644 --- a/edit/editlock.c +++ b/edit/editlock.c @@ -36,6 +36,7 @@ #include #include +#include #include #include "../src/global.h" @@ -100,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); - g_free (fname_copy); + mhl_mem_free (fname_copy); return symlink_name; } @@ -175,7 +176,7 @@ edit_lock_file (const char *fname) if (lstat (lockfname, &statbuf) == 0) { lock = lock_get_info (lockfname); if (!lock) { - g_free (lockfname); + mhl_mem_free (lockfname); return 0; } lockinfo = lock_extract_info (lock); @@ -196,11 +197,11 @@ edit_lock_file (const char *fname) break; case 1: case -1: - g_free (lockfname); - g_free (msg); + mhl_mem_free (lockfname); + mhl_mem_free (msg); return 0; } - g_free (msg); + mhl_mem_free (msg); } unlink (lockfname); } @@ -208,13 +209,13 @@ edit_lock_file (const char *fname) /* Create lock symlink */ newlock = lock_build_name (); if (symlink (newlock, lockfname) == -1) { - g_free (lockfname); - g_free (newlock); + mhl_mem_free (lockfname); + mhl_mem_free (newlock); return 0; } - g_free (lockfname); - g_free (newlock); + mhl_mem_free (lockfname); + mhl_mem_free (newlock); return 1; } @@ -236,7 +237,7 @@ edit_unlock_file (const char *fname) /* Check if lock exists */ if (lstat (lockfname, &statbuf) == -1) { - g_free (lockfname); + mhl_mem_free (lockfname); return 0; } @@ -244,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 ()) { - g_free (lockfname); + mhl_mem_free (lockfname); return 0; } } /* Remove lock */ unlink (lockfname); - g_free (lockfname); + mhl_mem_free (lockfname); return 0; } diff --git a/edit/editmenu.c b/edit/editmenu.c index 596b32fa0..6a3e0da8e 100644 --- a/edit/editmenu.c +++ b/edit/editmenu.c @@ -33,9 +33,10 @@ #include #include #include - #include +#include + #include "../src/global.h" #include "edit.h" @@ -475,7 +476,7 @@ edit_done_menu (struct WMenu *wmenu) for (i = 0; i < N_menus; i++) destroy_menu (wmenu->menu[i]); - g_free(wmenu->menu); + mhl_mem_free(wmenu->menu); } diff --git a/edit/editoptions.c b/edit/editoptions.c index 777431f0d..56785c7c7 100644 --- a/edit/editoptions.c +++ b/edit/editoptions.c @@ -33,9 +33,10 @@ #include #include #include - #include +#include + #include "../src/global.h" #include "edit.h" @@ -186,13 +187,13 @@ edit_options_dialog (void) if (p) { option_word_wrap_line_length = atoi (p); - g_free (p); + mhl_mem_free (p); } if (q) { option_tab_spacing = atoi (q); if (option_tab_spacing <= 0) option_tab_spacing = 8; - g_free (q); + mhl_mem_free (q); } option_syntax_highlighting = tedit_syntax_highlighting; diff --git a/edit/editwidget.c b/edit/editwidget.c index 8ae8cf0e8..048926257 100644 --- a/edit/editwidget.c +++ b/edit/editwidget.c @@ -35,6 +35,7 @@ #include #include +#include #include #include "../src/global.h" @@ -177,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); - g_free (dir); + mhl_mem_free (dir); } if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, line))) { diff --git a/edit/syntax.c b/edit/syntax.c index df6a47e51..479f3c5cc 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -32,6 +32,7 @@ #include #include +#include #include #include "../src/global.h" @@ -103,8 +104,6 @@ int option_syntax_highlighting = 1; int option_auto_syntax = 1; char *option_syntax_type = NULL; -#define syntax_g_free(x) do {g_free(x); (x)=0;} while (0) - static gint mc_defines_destroy (gpointer key, gpointer value, gpointer data) { @@ -112,10 +111,10 @@ mc_defines_destroy (gpointer key, gpointer value, gpointer data) (void) data; - g_free (key); + mhl_mem_free (key); while (*values) - g_free (*values++); - g_free (value); + mhl_mem_free (*values++); + mhl_mem_free (value); return FALSE; } @@ -472,7 +471,7 @@ static struct syntax_rule edit_get_rule (WEdit * edit, long byte_index) break; } s = edit->syntax_marker->next; - syntax_g_free (edit->syntax_marker); + MHL_PTR_FREE (edit->syntax_marker); edit->syntax_marker = s; } } @@ -667,19 +666,19 @@ static FILE *open_include_file (const char *filename) { FILE *f; - syntax_g_free (error_file_name); + MHL_PTR_FREE (error_file_name); error_file_name = mhl_str_dup (filename); if (*filename == PATH_SEP) return fopen (filename, "r"); - g_free (error_file_name); + mhl_mem_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; - g_free (error_file_name); + mhl_mem_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"); @@ -726,8 +725,8 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) f = g; g = 0; line = save_line + 1; - syntax_g_free (error_file_name); - syntax_g_free (l); + MHL_PTR_FREE (error_file_name); + MHL_PTR_FREE (l); if (!read_one_line (&l, f)) break; } else { @@ -746,7 +745,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) g = f; f = open_include_file (args[1]); if (!f) { - syntax_g_free (error_file_name); + MHL_PTR_FREE (error_file_name); result = line; break; } @@ -923,10 +922,10 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) break_a; } free_args (args); - syntax_g_free (l); + MHL_PTR_FREE (l); } free_args (args); - syntax_g_free (l); + MHL_PTR_FREE (l); /* Terminate context array. */ if (num_contexts > 0) { @@ -935,7 +934,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) } if (!edit->rules[0]) - syntax_g_free (edit->rules); + MHL_PTR_FREE (edit->rules); if (result) return result; @@ -959,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); } - g_free (first_chars); + mhl_mem_free (first_chars); } return result; @@ -977,34 +976,34 @@ void edit_free_syntax_rules (WEdit * edit) return; edit_get_rule (edit, -1); - syntax_g_free (edit->syntax_type); + MHL_PTR_FREE (edit->syntax_type); edit->syntax_type = 0; for (i = 0; edit->rules[i]; i++) { if (edit->rules[i]->keyword) { for (j = 0; edit->rules[i]->keyword[j]; j++) { - syntax_g_free (edit->rules[i]->keyword[j]->keyword); - syntax_g_free (edit->rules[i]->keyword[j]->whole_word_chars_left); - syntax_g_free (edit->rules[i]->keyword[j]->whole_word_chars_right); - syntax_g_free (edit->rules[i]->keyword[j]); + MHL_PTR_FREE (edit->rules[i]->keyword[j]->keyword); + MHL_PTR_FREE (edit->rules[i]->keyword[j]->whole_word_chars_left); + MHL_PTR_FREE (edit->rules[i]->keyword[j]->whole_word_chars_right); + MHL_PTR_FREE (edit->rules[i]->keyword[j]); } } - syntax_g_free (edit->rules[i]->left); - syntax_g_free (edit->rules[i]->right); - syntax_g_free (edit->rules[i]->whole_word_chars_left); - syntax_g_free (edit->rules[i]->whole_word_chars_right); - syntax_g_free (edit->rules[i]->keyword); - syntax_g_free (edit->rules[i]->keyword_first_chars); - syntax_g_free (edit->rules[i]); + MHL_PTR_FREE (edit->rules[i]->left); + MHL_PTR_FREE (edit->rules[i]->right); + MHL_PTR_FREE (edit->rules[i]->whole_word_chars_left); + MHL_PTR_FREE (edit->rules[i]->whole_word_chars_right); + MHL_PTR_FREE (edit->rules[i]->keyword); + MHL_PTR_FREE (edit->rules[i]->keyword_first_chars); + MHL_PTR_FREE (edit->rules[i]); } while (edit->syntax_marker) { struct _syntax_marker *s = edit->syntax_marker->next; - syntax_g_free (edit->syntax_marker); + MHL_PTR_FREE (edit->syntax_marker); edit->syntax_marker = s; } - syntax_g_free (edit->rules); + MHL_PTR_FREE (edit->rules); } /* returns -1 on file error, line number on error in file syntax */ @@ -1029,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"); - g_free (lib_file); + mhl_mem_free (lib_file); if (!f) return -1; } @@ -1037,7 +1036,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, args[0] = 0; for (;;) { line++; - syntax_g_free (l); + MHL_PTR_FREE (l); if (!read_one_line (&l, f)) break; (void)get_args (l, args, 1023); /* Final NULL */ @@ -1118,9 +1117,8 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, else result = line_error; } else { - syntax_g_free (edit->syntax_type); + MHL_PTR_FREE (edit->syntax_type); edit->syntax_type = mhl_str_dup (syntax_type); - /* if there are no rules then turn off syntax highlighting for speed */ if (!g && !edit->rules[1]) if (!edit->rules[0]->keyword[1] && !edit->rules[0]->spelling) { @@ -1137,7 +1135,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, } } } - syntax_g_free (l); + MHL_PTR_FREE (l); fclose (f); return result; } @@ -1202,9 +1200,9 @@ edit_load_syntax (WEdit *edit, char ***pnames, const char *type) message (D_ERROR, _(" Load syntax file "), _(" Error in file %s on line %d "), error_file_name ? error_file_name : f, r); - syntax_g_free (error_file_name); + MHL_PTR_FREE (error_file_name); } else { /* succeeded */ } - g_free (f); + mhl_mem_free (f); } diff --git a/edit/usermap.c b/edit/usermap.c index f5d5e4f33..b25cad949 100644 --- a/edit/usermap.c +++ b/edit/usermap.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "../src/global.h" @@ -243,7 +244,7 @@ cfg_free_maps(config_t *cfg) cfg->ext_keymap = NULL; for (i = 0; i < 10; i++) - g_free(cfg->labels[i]); + mhl_mem_free(cfg->labels[i]); } /* Returns an array containing the words in str. WARNING: As long as @@ -555,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); - g_free(ss); + mhl_mem_free(ss); g_ptr_array_free(args, TRUE); fclose(fp); return false; @@ -603,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); - g_free(msg); - g_free(file); + mhl_mem_free(msg); + mhl_mem_free(file); return false; } @@ -615,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); - g_free(file); + mhl_mem_free(file); return false; } else { cfg_free_maps(&cfg); @@ -627,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)); - g_free(file); + mhl_mem_free(file); return true; } diff --git a/edit/wordproc.c b/edit/wordproc.c index fc16136b1..db64a0a54 100644 --- a/edit/wordproc.c +++ b/edit/wordproc.c @@ -30,9 +30,10 @@ #include #include #include - #include +#include + #include "../src/global.h" #include "edit.h" @@ -349,13 +350,13 @@ format_paragraph (WEdit *edit, int force) if (!force) { int i; if (strchr (NO_FORMAT_CHARS_START, *t)) { - g_free (t); + mhl_mem_free (t); return; } for (i = 0; i < size - 1; i++) { if (t[i] == '\n') { if (strchr (NO_FORMAT_CHARS_START "\t ", t[i + 1])) { - g_free (t); + mhl_mem_free (t); return; } } @@ -363,7 +364,7 @@ format_paragraph (WEdit *edit, int force) } format_this (t, q - p, indent); put_paragraph (edit, t, p, indent, size); - g_free (t); + mhl_mem_free (t); /* Scroll left as much as possible to show the formatted paragraph */ edit_scroll_left (edit, -edit->start_col); diff --git a/src/achown.c b/src/achown.c index de2ae0783..c68a80668 100644 --- a/src/achown.c +++ b/src/achown.c @@ -22,11 +22,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "tty.h" #include "win.h" @@ -596,7 +597,7 @@ init_chown_advanced (void) static void chown_advanced_done (void) { - g_free (sf_stat); + mhl_mem_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 fa828ddda..689a3865c 100644 --- a/src/background.c +++ b/src/background.c @@ -31,11 +31,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "background.h" #include "tty.h" /* doupdate() */ @@ -89,8 +90,8 @@ unregister_task_running (pid_t pid, int fd) prev->next = p->next; else task_list = p->next; - g_free (p->info); - g_free (p); + mhl_mem_free (p->info); + mhl_mem_free (p); break; } prev = p; @@ -321,7 +322,7 @@ background_attention (int fd, void *closure) write (fd, &len, sizeof (len)); if (len){ write (fd, resstr, len); - g_free (resstr); + mhl_mem_free (resstr); } } else { len = 0; @@ -329,7 +330,7 @@ background_attention (int fd, void *closure) } } for (i = 0; i < argc; i++) - g_free (data [i]); + mhl_mem_free (data [i]); do_refresh (); mc_refresh (); diff --git a/src/boxes.c b/src/boxes.c index 33ec10e92..173908d86 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -30,6 +30,7 @@ #include #include +#include #include #include "global.h" @@ -234,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)) { - g_free (section); + mhl_mem_free (section); section = mhl_str_dup (p); } panel_load_setup (panel, section); - g_free (section); + mhl_mem_free (section); } current_mode = panel->list_type; @@ -250,10 +251,10 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n result = -1; if (section) { - g_free (panel->user_format); + mhl_mem_free (panel->user_format); for (i = 0; i < LIST_TYPES; i++) - g_free (panel->user_status_format [i]); - g_free (panel); + mhl_mem_free (panel->user_status_format [i]); + mhl_mem_free (panel); } if (dd->ret_value != B_CANCEL){ @@ -783,19 +784,19 @@ configure_vfs (void) if (quick_dialog (&confvfs_dlg) != B_CANCEL) { vfs_timeout = atoi (ret_timeout); - g_free (ret_timeout); + mhl_mem_free (ret_timeout); if (vfs_timeout < 0 || vfs_timeout > 10000) vfs_timeout = 10; #if defined(USE_NETCODE) - g_free (ftpfs_anonymous_passwd); + mhl_mem_free (ftpfs_anonymous_passwd); ftpfs_anonymous_passwd = ret_passwd; - g_free (ftpfs_proxy_host); + mhl_mem_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; - g_free (ret_directory_timeout); + mhl_mem_free (ret_directory_timeout); #endif } } @@ -906,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); - g_free (s); + mhl_mem_free (s); tl = tl->next; } } @@ -1084,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); - g_free (title); + mhl_mem_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 cb45a52dd..2b0c05aed 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); - g_free (fname); + mhl_mem_free (fname); return -1; } - g_free (fname); + mhl_mem_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); - g_free (default_codepage); + mhl_mem_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++) { - g_free (codepages[i].id); - g_free (codepages[i].name); + mhl_mem_free (codepages[i].id); + mhl_mem_free (codepages[i].name); } n_codepages = 0; - g_free (codepages); + mhl_mem_free (codepages); codepages = 0; } } diff --git a/src/cmd.c b/src/cmd.c index e4b934fa3..373cacc47 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -33,6 +33,7 @@ #endif #include +#include #include #include "global.h" @@ -240,7 +241,7 @@ view_file_cmd (void) return; view_file (filename, 0, use_internal_view); - g_free (filename); + mhl_mem_free (filename); } /* Run plain internal viewer on the currently selected file */ @@ -265,7 +266,7 @@ filtered_view_cmd (void) mc_internal_viewer (command, "", NULL, 0); - g_free (command); + mhl_mem_free (command); } void do_edit_at_line (const char *what, int start_line) @@ -383,8 +384,8 @@ mkdir_cmd (void) message (D_ERROR, MSG_ERROR, " %s ", unix_error_string (errno)); } - g_free (absdir); - g_free (dir); + mhl_mem_free (absdir); + mhl_mem_free (dir); } void delete_cmd (void) @@ -416,13 +417,13 @@ void find_cmd (void) static void set_panel_filter_to (WPanel *p, char *allocated_filter_string) { - g_free (p->filter); + mhl_mem_free (p->filter); p->filter = 0; if (!(allocated_filter_string [0] == '*' && allocated_filter_string [1] == 0)) p->filter = allocated_filter_string; else - g_free (allocated_filter_string); + mhl_mem_free (allocated_filter_string); reread_cmd (); } @@ -494,7 +495,7 @@ select_unselect_cmd (const char *title, const char *history_name, int cmd) if (!reg_exp) return; if (!*reg_exp) { - g_free (reg_exp); + mhl_mem_free (reg_exp); return; } @@ -524,14 +525,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 ")); - g_free (reg_exp); + mhl_mem_free (reg_exp); return; } if (c) { do_file_mark (current_panel, i, cmd); } } - g_free (reg_exp); + mhl_mem_free (reg_exp); } void select_cmd (void) @@ -584,11 +585,11 @@ void ext_cmd (void) buffer = mhl_str_dir_plus_file (home_dir, MC_USER_EXT); check_for_default (extdir, buffer); do_edit (buffer); - g_free (buffer); + mhl_mem_free (buffer); } else if (dir == 1) do_edit (extdir); - g_free (extdir); + mhl_mem_free (extdir); flush_extension_file (); } @@ -626,14 +627,14 @@ menu_edit_cmd (int where) break; default: - g_free (menufile); + mhl_mem_free (menufile); return; } do_edit (buffer); if (dir == 0) chmod(buffer, 0600); - g_free (buffer); - g_free (menufile); + mhl_mem_free (buffer); + mhl_mem_free (menufile); } void quick_chdir_cmd (void) @@ -649,7 +650,7 @@ void quick_chdir_cmd (void) else if (!do_cd (target, cd_exact)) message (D_ERROR, MSG_ERROR, _("Cannot change directory") ); - g_free (target); + mhl_mem_free (target); } /* edit file menu for mc */ @@ -687,11 +688,11 @@ edit_syntax_cmd (void) buffer = mhl_str_dir_plus_file (home_dir, SYNTAX_FILE); check_for_default (extdir, buffer); do_edit (buffer); - g_free (buffer); + mhl_mem_free (buffer); } else if (dir == 1) do_edit (extdir); - g_free (extdir); + mhl_mem_free (extdir); } #endif @@ -706,7 +707,7 @@ void reselect_vfs (void) if (!do_cd (target, cd_exact)) message (D_ERROR, MSG_ERROR, _("Cannot change directory") ); - g_free (target); + mhl_mem_free (target); } #endif /* USE_VFS */ @@ -819,8 +820,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); - g_free (src_name); - g_free (dst_name); + mhl_mem_free (src_name); + mhl_mem_free (dst_name); } } /* for (i ...) */ } @@ -879,7 +880,7 @@ history_cmd (void) else current = listbox->list->current->data; destroy_dlg (listbox->dlg); - g_free (listbox); + mhl_mem_free (listbox); if (!current) return; @@ -939,8 +940,8 @@ do_link (int symbolic_link, const char *fname) } symlink_dialog (s, d, &dest, &src); - g_free (d); - g_free (s); + mhl_mem_free (d); + mhl_mem_free (s); if (!dest || !*dest || !src || !*src) goto cleanup; @@ -953,8 +954,8 @@ do_link (int symbolic_link, const char *fname) repaint_screen (); cleanup: - g_free (src); - g_free (dest); + mhl_mem_free (src); + mhl_mem_free (dest); } void link_cmd (void) @@ -1002,10 +1003,10 @@ void edit_symlink_cmd (void) update_panels (UP_OPTIMIZE, UP_KEEPSEL); repaint_screen (); } - g_free (dest); + mhl_mem_free (dest); } } - g_free (q); + mhl_mem_free (q); } else { message (D_ERROR, MSG_ERROR, _("`%s' is not a symbolic link"), selection (current_panel)->fname); @@ -1024,7 +1025,7 @@ user_file_menu_cmd (void) } /* partly taken from dcigettext.c, returns "" for default locale */ -/* value should be freed by calling function g_free() */ +/* value should be freed by calling function mhl_mem_free() */ char *guess_message_value (void) { static const char * const var[] = { @@ -1094,7 +1095,7 @@ get_random_hint (int force) if (eol) *eol = 0; result = mhl_str_dup (&data[start]); - g_free (data); + mhl_mem_free (data); return result; } @@ -1125,8 +1126,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); - g_free (cd_path); - g_free (machine); + mhl_mem_free (cd_path); + mhl_mem_free (machine); } #endif /* USE_NETCODE || USE_EXT2FSLIB */ @@ -1186,9 +1187,9 @@ void quick_cd_cmd (void) char *q = g_strconcat ("cd ", p, (char *) NULL); do_cd_command (q); - g_free (q); + mhl_mem_free (q); } - g_free (p); + mhl_mem_free (p); } void @@ -1254,17 +1255,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){ - g_free (p->user_format); + mhl_mem_free (p->user_format); p->user_format = user; - g_free (p->user_status_format [view_type]); + mhl_mem_free (p->user_status_format [view_type]); p->user_status_format [view_type] = status; set_panel_formats (p); } else { - g_free (user); - g_free (status); + mhl_mem_free (user); + mhl_mem_free (status); } set_panel_formats (p); diff --git a/src/color.c b/src/color.c index 96059c6d5..a98b58834 100644 --- a/src/color.c +++ b/src/color.c @@ -22,6 +22,7 @@ #include #include +#include #include #include "global.h" @@ -254,7 +255,7 @@ static void configure_colors_string (const char *the_color_string) color_string++; } } - g_free (p); + mhl_mem_free (p); } static void configure_colors (void) @@ -466,9 +467,9 @@ done_colors (void) for (p = c.next; p; p = next) { next = p->next; - g_free (p->fg); - g_free (p->bg); - g_free (p); + mhl_mem_free (p->fg); + mhl_mem_free (p->bg); + mhl_mem_free (p); } c.next = NULL; } diff --git a/src/command.c b/src/command.c index 644a35c9c..536c14dac 100644 --- a/src/command.c +++ b/src/command.c @@ -28,8 +28,8 @@ #include #include -#include #include +#include #include "global.h" /* home_dir */ #include "tty.h" @@ -130,16 +130,15 @@ examine_cd (char *path) if (*p) { r = mhl_str_dir_plus_file (p, q); result = do_cd (r, cd_parse_command); - g_free (r); + mhl_mem_free (r); } *s = c; p = s + 1; } - g_free (cdpath); + mhl_mem_free (cdpath); } - g_free (q); - g_free (path_tilde); -// mhl_mem_free(path); + mhl_mem_free (q); + mhl_mem_free (path_tilde); return result; } @@ -183,14 +182,14 @@ void do_cd_command (char *cmd) char *new; new = mhl_str_dir_plus_file (old, cmd+3); sync_tree (new); - g_free (new); + mhl_mem_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)); - g_free (d); + mhl_mem_free (d); return; } } @@ -244,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); - g_free (s); + mhl_mem_free (s); j = strlen (command); } else { command[j] = cmd[i]; @@ -254,7 +253,7 @@ enter (WInput *cmdline) } new_input (cmdline); shell_execute (command, 0); - g_free (command); + mhl_mem_free (command); #ifdef HAVE_SUBSHELL_SUPPORT if (quit & SUBSHELL_EXIT) { @@ -316,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); - g_free (quoted_text); + mhl_mem_free (quoted_text); } diff --git a/src/complete.c b/src/complete.c index d8c7f0723..2c483d2ad 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; - g_free (dirname); - g_free (filename); - g_free (users_dirname); + mhl_mem_free (dirname); + mhl_mem_free (filename); + mhl_mem_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; } } - g_free (tmp); + mhl_mem_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; } - g_free (dirname); + mhl_mem_free (dirname); dirname = NULL; - g_free (filename); + mhl_mem_free (filename); filename = NULL; - g_free (users_dirname); + mhl_mem_free (users_dirname); users_dirname = NULL; return NULL; } else { @@ -368,7 +368,7 @@ static void fetch_hosts (const char *filename) *(hosts_p++) = name; *hosts_p = NULL; } else - g_free (name); + mhl_mem_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++) - g_free (*host_p); - g_free (hosts); + mhl_mem_free (*host_p); + mhl_mem_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++) - g_free (*host_p); - g_free (hosts); + mhl_mem_free (*host_p); + mhl_mem_free (hosts); hosts = NULL; return NULL; } else { @@ -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); - g_free (expanded); + mhl_mem_free (expanded); canonicalize_pathname (cur_word); cur_path = strchr (cur_path, 0) + 1; init_state = state; @@ -530,20 +530,19 @@ command_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags) filename_completion_function (cur_word, state - init_state, flags); if (!found) { - g_free (cur_word); + mhl_mem_free (cur_word); cur_word = NULL; } } } if (!found) { - g_free (path); + mhl_mem_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); return e_p.s; @@ -618,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 */ - g_free (match_list [j]); + mhl_mem_free (match_list [j]); j++; if (j > matches) break; @@ -634,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. */ - g_free (match_list); + mhl_mem_free (match_list); match_list = NULL; } return match_list; @@ -818,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); - g_free (r); + mhl_mem_free (r); } *s = c; cdpath = s + 1; } - g_free (cdpath_ref); + mhl_mem_free (cdpath_ref); } } } - g_free (word); + mhl_mem_free (word); return matches; } @@ -840,8 +839,8 @@ void free_completions (WInput *in) if (!in->completions) return; for (p=in->completions; *p; p++) - g_free (*p); - g_free (in->completions); + mhl_mem_free (*p); + mhl_mem_free (in->completions); in->completions = NULL; } diff --git a/src/cons.handler.c b/src/cons.handler.c index 1fe35b0b3..21a11fec7 100644 --- a/src/cons.handler.c +++ b/src/cons.handler.c @@ -267,7 +267,7 @@ console_shutdown (void) if (!console_flag) return; - g_free (screen_shot.buf); + mhl_mem_free (screen_shot.buf); console_flag = 0; } diff --git a/src/dialog.c b/src/dialog.c index a07628801..043f7debf 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "global.h" @@ -220,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); - g_free (t); + mhl_mem_free (t); } return (new_d); @@ -815,11 +816,11 @@ destroy_dlg (Dlg_head *h) c = h->current; for (i = 0; i < h->count; i++) { c = c->next; - g_free (h->current); + mhl_mem_free (h->current); h->current = c; } - g_free (h->title); - g_free (h); + mhl_mem_free (h->title); + mhl_mem_free (h); do_refresh (); } diff --git a/src/dir.c b/src/dir.c index c98271af1..597d0c1be 100644 --- a/src/dir.c +++ b/src/dir.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "global.h" @@ -255,7 +256,7 @@ clean_dir (dir_list *list, int count) int i; for (i = 0; i < count; i++){ - g_free (list->list [i].fname); + mhl_mem_free (list->list [i].fname); list->list [i].fname = 0; } } @@ -472,9 +473,9 @@ alloc_dir_copy (int size) if (dir_copy.list){ for (i = 0; i < dir_copy.size; i++) { - g_free (dir_copy.list [i].fname); + mhl_mem_free (dir_copy.list [i].fname); } - g_free (dir_copy.list); + mhl_mem_free (dir_copy.list); dir_copy.list = 0; } diff --git a/src/ecs-test.c b/src/ecs-test.c index e7f64e5db..963a63bf2 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); - g_free(ecs); + mhl_mem_free(ecs); valid = ecs_str_to_mbstr(&mbs, teststr_ecs); assert(valid); assert(strlen(mbs) == 11); - g_free(mbs); + mhl_mem_free(mbs); } #endif diff --git a/src/ecs.c b/src/ecs.c index 3fa3da63c..a38c54e93 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) { - g_free(str); + mhl_mem_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) { - g_free(str); + mhl_mem_free(str); return FALSE; } diff --git a/src/ecs.h b/src/ecs.h index 9ba672cf7..98e9a9a92 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 - * g_free after use. The return value is TRUE if the string is valid + * mhl_mem_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 913a48693..ee56d81d5 100644 --- a/src/execute.c +++ b/src/execute.c @@ -19,6 +19,7 @@ #include +#include #include #include "global.h" @@ -163,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); - g_free (old_vfs_dir); + mhl_mem_free (old_vfs_dir); } #endif /* USE_VFS */ @@ -197,7 +198,7 @@ shell_execute (const char *command, int flags) #endif /* HAVE_SUBSHELL_SUPPORT */ do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL); - g_free (cmd); + mhl_mem_free (cmd); } @@ -370,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); - g_free (localcopy); - g_free (fn); + mhl_mem_free (localcopy); + mhl_mem_free (fn); } diff --git a/src/ext.c b/src/ext.c index 329928be3..134411a02 100644 --- a/src/ext.c +++ b/src/ext.c @@ -27,6 +27,7 @@ #include #include +#include #include #include "global.h" @@ -53,7 +54,7 @@ static char *data = NULL; void flush_extension_file (void) { - g_free (data); + mhl_mem_free (data); data = NULL; } @@ -122,14 +123,14 @@ exec_extension (const char *filename, const char *data, int *move_dir, unlink (file_name); if (localcopy) { mc_ungetlocalcopy (filename, localcopy, 0); - g_free (localcopy); + mhl_mem_free (localcopy); } - g_free (file_name); + mhl_mem_free (file_name); return; } fputs (parameter, cmd_file); written_nonspace = 1; - g_free (parameter); + mhl_mem_free (parameter); } else { size_t len = strlen (prompt); @@ -157,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); - g_free (v); + mhl_mem_free (v); data += i; } else { char *text; @@ -168,7 +169,7 @@ exec_extension (const char *filename, const char *data, int *move_dir, if (localcopy == NULL) { fclose (cmd_file); unlink (file_name); - g_free (file_name); + mhl_mem_free (file_name); return; } mc_stat (localcopy, &mystat); @@ -185,7 +186,7 @@ exec_extension (const char *filename, const char *data, int *move_dir, strcpy (p, text); p = strchr (p, 0); } - g_free (text); + mhl_mem_free (text); written_nonspace = 1; } } @@ -216,7 +217,7 @@ exec_extension (const char *filename, const char *data, int *move_dir, if ((run_view && !written_nonspace) || is_cd) { unlink (file_name); - g_free (file_name); + mhl_mem_free (file_name); file_name = NULL; } else { /* Set executable flag on the command file ... */ @@ -275,14 +276,14 @@ exec_extension (const char *filename, const char *data, int *move_dir, } } - g_free (file_name); - g_free (cmd); + mhl_mem_free (file_name); + mhl_mem_free (cmd); if (localcopy) { mc_stat (localcopy, &mystat); mc_ungetlocalcopy (filename, localcopy, localmtime != mystat.st_mtime); - g_free (localcopy); + mhl_mem_free (localcopy); } } @@ -305,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"); - g_free (tmp); - g_free (command); + mhl_mem_free (tmp); + mhl_mem_free (command); if (f != NULL) { #ifdef __QNXNTO__ if (setvbuf (f, NULL, _IOFBF, 0) != 0) { @@ -387,7 +388,7 @@ regex_check_type (const char *filename, const char *ptr, int *have_type) /* No data */ content_string[0] = 0; } - g_free (realname); + mhl_mem_free (realname); } if (got_data == -1) { @@ -443,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)) { - g_free (extension_file); + mhl_mem_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); - g_free (extension_file); + mhl_mem_free (extension_file); if (data == NULL) return 0; if (!strstr (data, "default/")) { if (!strstr (data, "regex/") && !strstr (data, "shell/") && !strstr (data, "type/")) { - g_free (data); + mhl_mem_free (data); data = NULL; if (mc_user_ext) { home_error = 1; @@ -470,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); - g_free (title); + mhl_mem_free (title); return 0; } } @@ -482,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); - g_free (title); + mhl_mem_free (title); } } mc_stat (filename, &mystat); @@ -595,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); - g_free (filename_copy); + mhl_mem_free (filename_copy); ret = 1; } diff --git a/src/file.c b/src/file.c index c5dac1338..1a367eaf1 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); - g_free (s); + mhl_mem_free (s); return p; } @@ -267,7 +267,7 @@ free_linklist (struct link **linklist) for (lp = *linklist; lp != NULL; lp = lp2) { lp2 = lp->next; - g_free (lp); + mhl_mem_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); - g_free (p); + mhl_mem_free (p); g_strlcpy (link_target, s, sizeof (link_target)); - g_free (s); + mhl_mem_free (s); s = diff_two_paths (q, link_target); if (s) { g_strlcpy (link_target, s, sizeof (link_target)); - g_free (s); + mhl_mem_free (s); } } else - g_free (p); - g_free (q); + mhl_mem_free (p); + mhl_mem_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: - g_free (buf); + mhl_mem_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) { - g_free (parent_dirs); + mhl_mem_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; - g_free (parent_dirs); + mhl_mem_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); - g_free (mdpath); + mhl_mem_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); - g_free (dest_file); + mhl_mem_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); } } - g_free (path); + mhl_mem_free (path); } mc_closedir (reading); @@ -1019,8 +1019,8 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, } ret: - g_free (dest_dir); - g_free (parent_dirs); + mhl_mem_free (dest_dir); + mhl_mem_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; } - g_free (destdir); + mhl_mem_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; - g_free (lp); + mhl_mem_free (lp); } } erase_dir_iff_empty (ctx, s); ret: - g_free (destdir); + mhl_mem_free (destdir); while (erase_list) { lp = erase_list; erase_list = erase_list->next; - g_free (lp); + mhl_mem_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)) { - g_free (path); + mhl_mem_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); - g_free (path); + mhl_mem_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) { - g_free (fullname); + mhl_mem_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; } - g_free (fullname); + mhl_mem_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; - g_free (dir_name); + mhl_mem_free (dir_name); } else { (*ret_marked)++; *ret_total += s->st_size; @@ -1829,7 +1829,7 @@ panel_operate (void *source_panel, FileOperation operation, } if (!*dest) { file_op_context_destroy (ctx); - g_free (dest); + mhl_mem_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); - g_free (dest); + mhl_mem_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 - g_free (source_with_path); + mhl_mem_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 (); } - g_free (temp2); + mhl_mem_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); - g_free (save_cwd); + mhl_mem_free (save_cwd); } if (save_dest) { mc_setctl (save_dest, VFS_SETCTL_STALE_DATA, NULL); - g_free (save_dest); + mhl_mem_free (save_dest); } free_linklist (&linklist); free_linklist (&dest_dirs); #ifdef WITH_FULL_PATHS - g_free (source_with_path); + mhl_mem_free (source_with_path); #endif /* WITH_FULL_PATHS */ - g_free (dest); - g_free (ctx->dest_mask); + mhl_mem_free (dest); + mhl_mem_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 (); - g_free (text); + mhl_mem_free (text); } switch (ctx->recursive_result) { diff --git a/src/filegui.c b/src/filegui.c index 9a4fc2f7b..e7814aca0 100644 --- a/src/filegui.c +++ b/src/filegui.c @@ -52,6 +52,7 @@ #include #include +#include #include #include "global.h" @@ -257,7 +258,7 @@ file_op_context_destroy_ui (FileOpContext *ctx) dlg_run_done (ui->op_dlg); destroy_dlg (ui->op_dlg); - g_free (ui); + mhl_mem_free (ui); } the_hint->widget.y = last_hint_line; @@ -905,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) { - g_free (def_text_secure); + mhl_mem_free (def_text_secure); return 0; } - g_free (def_text_secure); + mhl_mem_free (def_text_secure); if (ctx->follow_links) ctx->stat_func = mc_stat; @@ -929,7 +930,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, orig_mask = source_mask; if (!dest_dir || !*dest_dir) { - g_free (source_mask); + mhl_mem_free (source_mask); return dest_dir; } if (source_easy_patterns) { @@ -940,7 +941,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, error = re_compile_pattern (source_mask, strlen (source_mask), &ctx->rx); - g_free (source_mask); + mhl_mem_free (source_mask); } else error = re_compile_pattern (source_mask, strlen (source_mask), @@ -949,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); - g_free (orig_mask); + mhl_mem_free (orig_mask); goto ask_file_mask; } - g_free (orig_mask); + mhl_mem_free (orig_mask); tmpdest = dest_dir; dest_dir = tilde_expand(tmpdest); - g_free(tmpdest); + mhl_mem_free(tmpdest); ctx->dest_mask = strrchr (dest_dir, PATH_SEP); if (ctx->dest_mask == NULL) @@ -978,7 +979,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, *orig_mask = 0; } if (!*dest_dir) { - g_free (dest_dir); + mhl_mem_free (dest_dir); dest_dir = mhl_str_dup ("./"); } if (val == B_USER) diff --git a/src/filenot.c b/src/filenot.c index 7a67a0abd..c3c2e949c 100644 --- a/src/filenot.c +++ b/src/filenot.c @@ -27,6 +27,7 @@ #include #include +#include #include #include "global.h" @@ -64,12 +65,12 @@ my_mkdir_rec (char *s, mode_t mode) p = mhl_str_dir_plus_file (s, ".."); q = vfs_canon (p); - g_free (p); + mhl_mem_free (p); if (!(result = my_mkdir_rec (q, mode))) result = mc_mkdir (s, mode); - g_free (q); + mhl_mem_free (q); return result; } @@ -84,7 +85,7 @@ my_mkdir (const char *s, mode_t mode) char *p = vfs_canon (s); result = my_mkdir_rec (p, mode); - g_free (p); + mhl_mem_free (p); } if (result == 0) { my_s = get_absolute_name (s); @@ -93,7 +94,7 @@ my_mkdir (const char *s, mode_t mode) tree_add_entry (tree, my_s); #endif - g_free (my_s); + mhl_mem_free (my_s); } return result; } @@ -116,7 +117,7 @@ my_rmdir (const char *s) tree_remove_entry (tree, my_s); #endif - g_free (my_s); + mhl_mem_free (my_s); } return result; } diff --git a/src/fileopctx.c b/src/fileopctx.c index ad02cf4ae..cffda15a8 100644 --- a/src/fileopctx.c +++ b/src/fileopctx.c @@ -25,6 +25,8 @@ #include +#include + #include "global.h" #include "fileopctx.h" @@ -77,5 +79,5 @@ file_op_context_destroy (FileOpContext *ctx) /* FIXME: do we need to free ctx->dest_mask? */ - g_free (ctx); + mhl_mem_free (ctx); } diff --git a/src/find.c b/src/find.c index 01f75c951..bf95b7f35 100644 --- a/src/find.c +++ b/src/find.c @@ -28,6 +28,7 @@ #include #include +#include #include #include "global.h" @@ -308,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); - g_free (in_start_dir); + mhl_mem_free (in_start_dir); if (strcmp (temp_dir, ".") == 0) { - g_free (temp_dir); + mhl_mem_free (temp_dir); temp_dir = mhl_str_dup (current_panel->cwd); } in_start_dir = tree_box (temp_dir); if (in_start_dir) - g_free (temp_dir); + mhl_mem_free (temp_dir); else in_start_dir = temp_dir; /* Warning: Dreadful goto */ @@ -323,7 +324,7 @@ find_parameters (char **start_dir, char **pattern, char **content) break; default: - g_free (in_contents); + mhl_mem_free (in_contents); if (in_with->buffer[0]) { *content = mhl_str_dup (in_with->buffer); in_contents = mhl_str_dup (*content); @@ -339,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); - g_free (in_start_dir); + mhl_mem_free (in_start_dir); in_start_dir = mhl_str_dup (*start_dir); - g_free (in_start_name); + mhl_mem_free (in_start_name); in_start_name = mhl_str_dup (*pattern); } @@ -370,7 +371,7 @@ pop_directory (void) if (dir_stack_base){ name = dir_stack_base->name; next = dir_stack_base->prev; - g_free (dir_stack_base); + mhl_mem_free (dir_stack_base); dir_stack_base = next; return name; } else @@ -388,7 +389,7 @@ insert_file (const char *dir, const char *file) if (old_dir){ if (strcmp (old_dir, dir)){ - g_free (old_dir); + mhl_mem_free (old_dir); old_dir = mhl_str_dup (dir); dirname = add_to_list (dir, NULL); } @@ -399,7 +400,7 @@ insert_file (const char *dir, const char *file) tmp_name = g_strconcat (" ", file, (char *) NULL); add_to_list (tmp_name, dirname); - g_free (tmp_name); + mhl_mem_free (tmp_name); } static void @@ -521,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)){ - g_free (fname); + mhl_mem_free (fname); return 0; } file_fd = mc_open (fname, O_RDONLY); - g_free (fname); + mhl_mem_free (fname); if (file_fd == -1) return 0; @@ -562,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){ - g_free (p); + mhl_mem_free (p); p = g_strdup_printf ("%d:%s", line, filename); find_add_match (h, directory, p); found = 1; @@ -579,7 +580,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename) line++; found = 0; } - g_free (p); + mhl_mem_free (p); if ((line & 0xff) == 0) { FindProgressStatus res; @@ -622,7 +623,7 @@ do_search (struct Dlg_head *h) mc_closedir (dirp); dirp = 0; } - g_free (directory); + mhl_mem_free (directory); directory = NULL; dp = 0; return 1; @@ -652,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; - g_free (temp_dir); + mhl_mem_free (temp_dir); if (found) - g_free (tmp); + mhl_mem_free (tmp); else break; } else break; } - g_free (directory); + mhl_mem_free (directory); directory = tmp; if (verbose){ @@ -700,7 +701,7 @@ do_search (struct Dlg_head *h) push_directory (tmp_name); subdirs_left--; } - g_free (tmp_name); + mhl_mem_free (tmp_name); } if (regexp_match (find_pattern, dp->d_name, match_file)){ @@ -737,14 +738,14 @@ init_find_vars (void) { char *dir; - g_free (old_dir); + mhl_mem_free (old_dir); old_dir = 0; count = 0; matches = 0; /* Remove all the items in the stack */ while ((dir = pop_directory ()) != NULL) - g_free (dir); + mhl_mem_free (dir); } static char * @@ -778,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); - g_free (fullname); + mhl_mem_free (fullname); } static int @@ -978,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) - g_free (dir); + mhl_mem_free (dir); get_list_info (&file_tmp, &dir_tmp); @@ -1013,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) { - g_free (name); + mhl_mem_free (name); continue; } if (status == -1) { - g_free (name); + mhl_mem_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) { - g_free (name); + mhl_mem_free (name); continue; } } @@ -1061,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 */ - g_free (old_dir); + mhl_mem_free (old_dir); old_dir = 0; return return_value; @@ -1080,8 +1081,8 @@ do_find (void) dirname = filename = NULL; is_start = 0; v = find_file (start_dir, pattern, content, &dirname, &filename); - g_free (start_dir); - g_free (pattern); + mhl_mem_free (start_dir); + mhl_mem_free (pattern); if (find_regex_flag && r) regfree (r); @@ -1096,14 +1097,14 @@ do_find (void) do_cd (filename, cd_exact); select_item (current_panel); } - g_free (dirname); - g_free (filename); + mhl_mem_free (dirname); + mhl_mem_free (filename); break; } - g_free (content); + mhl_mem_free (content); dir_and_file_set = dirname && filename; - g_free (dirname); - g_free (filename); + mhl_mem_free (dirname); + mhl_mem_free (filename); if (v == B_CANCEL) break; diff --git a/src/help.c b/src/help.c index 3c157656b..efdf220d9 100644 --- a/src/help.c +++ b/src/help.c @@ -48,6 +48,7 @@ #include #include +#include #include #include "global.h" @@ -128,7 +129,7 @@ search_string (const char *start, const char *text) } } cleanup: - g_free (local_text); + mhl_mem_free (local_text); return result; } @@ -328,7 +329,7 @@ static void clear_link_areas (void) while (link_area){ current = link_area; link_area = current -> next; - g_free (current); + mhl_mem_free (current); } inside_link_area = 0; } @@ -754,7 +755,7 @@ static void interactive_display_finish (void) { clear_link_areas (); - g_free (data); + mhl_mem_free (data); } void @@ -775,7 +776,7 @@ interactive_display (const char *filename, const char *node) } if (!filename) - g_free (hlpfile); + mhl_mem_free (hlpfile); if (!data) return; diff --git a/src/hotlist.c b/src/hotlist.c index ef5fc17cd..a54a0b5c5 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -36,6 +36,7 @@ #include #include +#include #include #include "global.h" @@ -200,7 +201,7 @@ update_path_name (void) else label_set_text (movelist_group, name_trunc (p, dlg->cols - (UX * 2 + 4))); - g_free (p); + mhl_mem_free (p); dlg_redraw (dlg); } @@ -210,7 +211,7 @@ do { \ int i; \ \ if ((i = strlen (current->label) + 3) > buflen) { \ - g_free (buf); \ + mhl_mem_free (buf); \ buf = g_malloc (buflen = 1024 * (i/1024 + 1)); \ } \ buf[0] = '\0'; \ @@ -464,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); - g_free (tmp); + mhl_mem_free (tmp); dlg_stop (h); h->ret_value = B_CANCEL; return MSG_HANDLED; @@ -687,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); - g_free (hdr); + mhl_mem_free (hdr); for (i = 0; i < BUTTONS; i++) { if (hotlist_but[i].type & list_type) @@ -812,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); - g_free (lbl); + mhl_mem_free (lbl); } else listbox_add_item (l_hotlist, pos, 0, new->label, new); listbox_select_entry (l_hotlist, l_hotlist->current); @@ -938,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); - g_free (to_free); + mhl_mem_free (to_free); if (!ret) return; if (!title || !*title || !url || !*url) { - g_free (title); - g_free (url); + mhl_mem_free (title); + mhl_mem_free (url); return; } @@ -1045,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); - g_free (prompt); + mhl_mem_free (prompt); if (!label || !*label) { - g_free (label_string); - g_free (label); + mhl_mem_free (label_string); + mhl_mem_free (label); return; } add2hotlist (label, label_string, HL_TYPE_ENTRY, 0); @@ -1066,9 +1067,9 @@ static void remove_group (struct hotlist *grp) if (current->type == HL_TYPE_GROUP) remove_group (current); - g_free (current->label); - g_free (current->directory); - g_free (current); + mhl_mem_free (current->label); + mhl_mem_free (current->directory); + mhl_mem_free (current); current = next; } @@ -1095,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")); - g_free (title); + mhl_mem_free (title); if (result != 0) return; @@ -1113,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")); - g_free (header); + mhl_mem_free (header); if (result != 0) return; @@ -1124,9 +1125,9 @@ static void remove_from_hotlist (struct hotlist *entry) unlink_entry (entry); - g_free (entry->label); - g_free (entry->directory); - g_free (entry); + mhl_mem_free (entry->label); + mhl_mem_free (entry->directory); + mhl_mem_free (entry); /* now remove list entry from screen */ listbox_remove_current (l_hotlist, 1); hotlist_state.modified = 1; @@ -1184,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); } - g_free (group_section); + mhl_mem_free (group_section); profile_keys = profile_init_iterator (grp->directory, profile_name); @@ -1428,7 +1429,7 @@ clean_up_hotlist_groups (const char *section) } profile_clean_section (grp_section, profile_name); } - g_free (grp_section); + mhl_mem_free (grp_section); } @@ -1573,7 +1574,7 @@ int save_hotlist (void) hotlist_state.modified = 0; } else rename (fbak, hotlist_file_name); - g_free (fbak); + mhl_mem_free (fbak); } return saved; @@ -1587,20 +1588,20 @@ void done_hotlist (void) { if (hotlist){ remove_group (hotlist); - g_free (hotlist->label); - g_free (hotlist->directory); - g_free (hotlist); + mhl_mem_free (hotlist->label); + mhl_mem_free (hotlist->directory); + mhl_mem_free (hotlist); hotlist = 0; } hotlist_state.loaded = 0; - g_free (hotlist_file_name); + mhl_mem_free (hotlist_file_name); hotlist_file_name = 0; l_hotlist = 0; current_group = 0; if (tkn_buf){ - g_free (tkn_buf); + mhl_mem_free (tkn_buf); tkn_buf_length = 0; tkn_length = 0; tkn_buf = NULL; diff --git a/src/key.c b/src/key.c index 68690914e..1434fa7dd 100644 --- a/src/key.c +++ b/src/key.c @@ -33,6 +33,7 @@ #include #include +#include #include #include "global.h" @@ -154,7 +155,7 @@ void delete_select_channel (int fd) else select_list = p_next; - g_free (p); + mhl_mem_free (p); p = p_next; continue; } @@ -1397,7 +1398,7 @@ static void k_dispose (key_def *k) return; k_dispose (k->child); k_dispose (k->next); - g_free (k); + mhl_mem_free (k); } static void s_dispose (SelectList *sel) @@ -1406,7 +1407,7 @@ static void s_dispose (SelectList *sel) return; s_dispose (sel->next); - g_free (sel); + mhl_mem_free (sel); } void done_key () diff --git a/src/layout.c b/src/layout.c index 9e25deafa..33f58cc26 100644 --- a/src/layout.c +++ b/src/layout.c @@ -41,6 +41,7 @@ #endif #include +#include #include #include "global.h" @@ -1052,13 +1053,13 @@ void swap_panels () if (panels [0].type == view_listing) { if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) { - g_free (panel1->panel_name); + mhl_mem_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))) { - g_free (panel2->panel_name); + mhl_mem_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 93208834f..2be4b8c12 100644 --- a/src/learn.c +++ b/src/learn.c @@ -25,11 +25,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "tty.h" #include "win.h" @@ -88,7 +89,7 @@ _("Please press the %s\n" _(key_name_conv_tab [action - B_USER].longname)); mc_refresh (); if (learnkeys [action - B_USER].sequence != NULL) { - g_free (learnkeys [action - B_USER].sequence); + mhl_mem_free (learnkeys [action - B_USER].sequence); learnkeys [action - B_USER].sequence = NULL; } seq = learn_key (); @@ -117,7 +118,7 @@ _("Please press the %s\n" _(" You have entered \"%s\""), seq); } - g_free (seq); + mhl_mem_free (seq); } dlg_run_done (d); @@ -327,7 +328,7 @@ learn_save (void) if (profile_changed) sync_profiles (); - g_free (section); + mhl_mem_free (section); } void learn_keys (void) diff --git a/src/listmode.c b/src/listmode.c index 84af11321..0cfcbf6c6 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); - g_free (s); + mhl_mem_free (s); if (run_dlg (listmode_dlg) == B_ENTER) { newformat = collect_new_format (); diff --git a/src/logging.c b/src/logging.c index 9fa8605e9..a48dcfb79 100644 --- a/src/logging.c +++ b/src/logging.c @@ -26,6 +26,7 @@ #include #include +#include #include #include "global.h" @@ -45,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); - g_free(mc_ini); + mhl_mem_free(mc_ini); logging_initialized = TRUE; } return logging_enabled; @@ -67,6 +68,6 @@ mc_log(const char *fmt, ...) (void)vfprintf(f, fmt, args); (void)fclose(f); } - g_free(logfilename); + mhl_mem_free(logfilename); } } diff --git a/src/main.c b/src/main.c index 6c867a532..6a8376aa9 100644 --- a/src/main.c +++ b/src/main.c @@ -33,6 +33,7 @@ #include #include +#include #include #include "global.h" @@ -301,7 +302,7 @@ reload_panelized (WPanel *panel) do_file_mark (panel, i, 0); } if (mc_lstat (list->list[i].fname, &list->list[i].st)) { - g_free (list->list[i].fname); + mhl_mem_free (list->list[i].fname); continue; } if (list->list[i].f.marked) @@ -349,7 +350,7 @@ update_one_panel_widget (WPanel *panel, int force_update, panel->dirty = 1; if (free_pointer) - g_free (my_current_file); + mhl_mem_free (my_current_file); } void @@ -589,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); - g_free (olddir); - g_free (translated_url); + mhl_mem_free (olddir); + mhl_mem_free (translated_url); return 0; } - g_free (translated_url); + mhl_mem_free (translated_url); /* Success: save previous directory, shutdown status of previous dir */ strcpy (panel->lwd, olddir); @@ -616,7 +617,7 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type) panel->dirty = 1; update_xterm_title_path (); - g_free (olddir); + mhl_mem_free (olddir); return 1; } @@ -687,7 +688,7 @@ directory_history_list (WPanel *panel) directory_history_add (panel, panel->cwd); else message (D_ERROR, MSG_ERROR, _("Cannot change directory")); - g_free (s); + mhl_mem_free (s); } #ifdef HAVE_SUBSHELL_SUPPORT @@ -776,7 +777,7 @@ treebox_cmd (void) sel_dir = tree_box (selection (current_panel)->fname); if (sel_dir) { do_cd (sel_dir, cd_exact); - g_free (sel_dir); + mhl_mem_free (sel_dir); } } @@ -793,7 +794,7 @@ listmode_cmd (void) if (!newmode) return; - g_free (current_panel->user_format); + mhl_mem_free (current_panel->user_format); current_panel->list_type = list_user; current_panel->user_format = newmode; set_panel_formats (current_panel); @@ -1035,7 +1036,7 @@ translated_mc_chdir (char *dir) newdir = vfs_translate_url (dir); mc_chdir (newdir); - g_free (newdir); + mhl_mem_free (newdir); } static void @@ -1141,7 +1142,7 @@ copy_readlink (WPanel *panel) int i; i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1); - g_free (p); + mhl_mem_free (p); if (i > 0) { buffer[i] = 0; command_insert (cmdline, buffer, 1); @@ -1621,7 +1622,7 @@ update_xterm_title_path (void) numeric_keypad_mode (); fprintf (stdout, "\33]0;mc - %s\7", p); fflush (stdout); - g_free (p); + mhl_mem_free (p); } } @@ -1645,7 +1646,7 @@ load_hint (int force) if ((hint = get_random_hint (force))) { if (*hint) set_hintbar (hint); - g_free (hint); + mhl_mem_free (hint); } else { char text[BUF_SMALL]; @@ -1713,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); - g_free (path); + mhl_mem_free (path); } #ifdef USE_INTERNAL_EDIT else { @@ -2082,7 +2083,7 @@ handle_args (int argc, char *argv[]) edit_one_file = fname; edit_one_file_start_line = atoi (p); } else { - g_free (fname); + mhl_mem_free (fname); goto try_plus_filename; } } else { @@ -2251,15 +2252,15 @@ main (int argc, char *argv[]) close (last_wd_fd); } } - g_free (last_wd_string); + mhl_mem_free (last_wd_string); - g_free (mc_home); + mhl_mem_free (mc_home); done_key (); #ifdef HAVE_CHARSET free_codepages_list (); #endif - g_free (this_dir); - g_free (other_dir); + mhl_mem_free (this_dir); + mhl_mem_free (other_dir); return 0; } diff --git a/src/menu.c b/src/menu.c index 41bda66d1..09e91e3d3 100644 --- a/src/menu.c +++ b/src/menu.c @@ -23,6 +23,7 @@ #include #include +#include #include #include "global.h" @@ -532,9 +533,9 @@ menubar_arrange(WMenu* menubar) void destroy_menu (Menu *menu) { - g_free (menu->name); - g_free (menu->help_node); - g_free (menu); + mhl_mem_free (menu->name); + mhl_mem_free (menu->help_node); + mhl_mem_free (menu); } WMenu * diff --git a/src/panelize.c b/src/panelize.c index 28a62c038..b2902d283 100644 --- a/src/panelize.c +++ b/src/panelize.c @@ -29,6 +29,7 @@ #include #include +#include #include #include "global.h" @@ -233,7 +234,7 @@ add2panelize_cmd (void) if (!label) return; if (!*label) { - g_free (label); + mhl_mem_free (label); return; } @@ -255,9 +256,9 @@ static void remove_from_panelize (struct panelize *entry) } } - g_free (entry->label); - g_free (entry->command); - g_free (entry); + mhl_mem_free (entry->label); + mhl_mem_free (entry->command); + mhl_mem_free (entry); } } @@ -297,7 +298,7 @@ external_panelize (void) char *cmd = mhl_str_dup (target); destroy_dlg (panelize_dlg); do_external_panelize (cmd); - g_free (cmd); + mhl_mem_free (cmd); repaint_screen (); return; } @@ -351,9 +352,9 @@ void done_panelize (void) for (; current; current = next){ next = current->next; - g_free (current->label); - g_free (current->command); - g_free (current); + mhl_mem_free (current->label); + mhl_mem_free (current->command); + mhl_mem_free (current); } } diff --git a/src/profile.c b/src/profile.c index 6b27d631a..7ae367b16 100644 --- a/src/profile.c +++ b/src/profile.c @@ -28,6 +28,7 @@ #include #include +#include #include #include "global.h" @@ -249,7 +250,7 @@ static TSecHeader *load (const char *file) break; case OnSecHeader: { /* Broken initialization file */ TSecHeader *link = SecHeader->link; - g_free (SecHeader); + mhl_mem_free (SecHeader); SecHeader = link; fprintf (stderr, "Warning: Corrupted initialization file `%s'\n", file); @@ -299,7 +300,7 @@ GetSetProfileChar (int set, const char *AppName, const char *KeyName, if ( g_strcasecmp (key->KeyName, KeyName)) continue; if (set){ - g_free (key->Value); + mhl_mem_free (key->Value); key->Value = mhl_str_dup (Default); } return key->Value; @@ -383,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); - g_free (t); + mhl_mem_free (t); } static void dump_sections (FILE *profile, TSecHeader *p) @@ -426,9 +427,9 @@ static void free_keys (TKeys *p) if (!p) return; free_keys (p->link); - g_free (p->KeyName); - g_free (p->Value); - g_free (p); + mhl_mem_free (p->KeyName); + mhl_mem_free (p->Value); + mhl_mem_free (p); } static void free_sections (TSecHeader *p) @@ -437,10 +438,10 @@ static void free_sections (TSecHeader *p) return; free_sections (p->link); free_keys (p->Keys); - g_free (p->AppName); + mhl_mem_free (p->AppName); p->link = 0; p->Keys = 0; - g_free (p); + mhl_mem_free (p); } static void free_profile (TProfile *p) @@ -449,8 +450,8 @@ static void free_profile (TProfile *p) return; free_profile (p->link); free_sections (p->Section); - g_free (p->FileName); - g_free (p); + mhl_mem_free (p->FileName); + mhl_mem_free (p); } void free_profile_name (const char *s) diff --git a/src/rxvt.c b/src/rxvt.c index da658f2e5..d75ba0519 100644 --- a/src/rxvt.c +++ b/src/rxvt.c @@ -21,10 +21,11 @@ #include #include #include - #include #include +#include + #include "global.h" #include "tty.h" /* move, addch */ #include "cons.saver.h" @@ -113,6 +114,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] : ' '); } - g_free (k); + mhl_mem_free (k); } diff --git a/src/screen.c b/src/screen.c index 7a6683a49..b2d569793 100644 --- a/src/screen.c +++ b/src/screen.c @@ -27,6 +27,7 @@ #include #include +#include #include #include "global.h" @@ -132,7 +133,7 @@ delete_format (format_e *format) while (format){ next = format->next; - g_free (format); + mhl_mem_free (format); format = next; } } @@ -712,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); - g_free (link); + mhl_mem_free (link); if (len > 0){ link_target[len] = 0; tty_printf ("-> %-*s", panel->widget.cols - 5, @@ -797,7 +798,7 @@ show_dir (WPanel *panel) trim (strip_home_and_password (panel->cwd), tmp, max (panel->widget.cols - 9, 0)); addstr (tmp); - g_free (tmp); + mhl_mem_free (tmp); addch (' '); widget_move (&panel->widget, 0, 1); @@ -893,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); - g_free (subdir); + mhl_mem_free (subdir); return; } } @@ -901,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); - g_free (subdir); + mhl_mem_free (subdir); } void @@ -965,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) g_free, NULL); + g_list_foreach (p->dir_history, (GFunc) mhl_mem_free, NULL); g_list_free (p->dir_history); } - g_free (p->hist_name); + mhl_mem_free (p->hist_name); delete_format (p->format); delete_format (p->status_format); - g_free (p->user_format); + mhl_mem_free (p->user_format); for (i = 0; i < LIST_TYPES; i++) - g_free (p->user_status_format[i]); - g_free (p->dir.list); - g_free (p->panel_name); - g_free (name); + mhl_mem_free (p->user_status_format[i]); + mhl_mem_free (p->dir.list); + mhl_mem_free (p->panel_name); + mhl_mem_free (name); } static void @@ -1040,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)) { - g_free (section); + mhl_mem_free (section); section = mhl_str_dup (panel->panel_name); } panel_load_setup (panel, section); - g_free (section); + mhl_mem_free (section); /* Load format strings */ err = set_panel_formats (panel); @@ -1327,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); - g_free (tmp_format); + mhl_mem_free (tmp_format); return 0; } total_cols += darr->requested_field_len; @@ -1416,7 +1417,7 @@ set_panel_formats (WPanel *p) form = use_display_format (p, panel_format (p), &err, 0); if (err){ - g_free (err); + mhl_mem_free (err); retcode = 1; } else { @@ -1431,7 +1432,7 @@ set_panel_formats (WPanel *p) form = use_display_format (p, mini_status_format (p), &err, 1); if (err){ - g_free (err); + mhl_mem_free (err); retcode += 2; } else { @@ -1448,11 +1449,11 @@ set_panel_formats (WPanel *p) if (retcode) message( 1, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) ); if (retcode & 0x01){ - g_free (p->user_format); + mhl_mem_free (p->user_format); p->user_format = mhl_str_dup (DEFAULT_USER_FORMAT); } if (retcode & 0x02){ - g_free (p->user_status_format [p->list_type]); + mhl_mem_free (p->user_status_format [p->list_type]); p->user_status_format [p->list_type] = mhl_str_dup (DEFAULT_USER_FORMAT); } @@ -1977,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)) { - g_free (full_name); + mhl_mem_free (full_name); return 0; } - g_free (full_name); + mhl_mem_free (full_name); if (confirm_execute) { if (query_dialog @@ -1996,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); - g_free (tmp); + mhl_mem_free (tmp); /* We took action only if the dialog was shown or the execution * was successful */ return confirm_execute || (ret == 0); @@ -2006,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); - g_free (tmp); + mhl_mem_free (tmp); shell_execute (cmd, 0); - g_free (cmd); + mhl_mem_free (cmd); } return 1; @@ -2044,7 +2045,7 @@ chdir_other_panel (WPanel *panel) move_down (panel); - g_free (new_dir); + mhl_mem_free (new_dir); } /* @@ -2108,7 +2109,7 @@ chdir_to_readlink (WPanel *panel) move_down (panel); - g_free (new_dir); + mhl_mem_free (new_dir); } } @@ -2255,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)); - g_free(cwd); + mhl_mem_free(cwd); } else subshell_chdir (panel->cwd); @@ -2475,7 +2476,7 @@ panel_re_sort (WPanel *panel) break; } } - g_free (filename); + mhl_mem_free (filename); panel->top_file = panel->selected - ITEMS (panel)/2; if (panel->top_file < 0) panel->top_file = 0; @@ -2498,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); - g_free (current_file); + mhl_mem_free (current_file); } panel_re_sort (panel); } diff --git a/src/setup.c b/src/setup.c index 02df102a4..eaa86a7d7 100644 --- a/src/setup.c +++ b/src/setup.c @@ -23,6 +23,7 @@ #include #include +#include #include #include "global.h" @@ -293,7 +294,7 @@ save_layout (void) save_string ("Layout", layout [i].opt_name, buffer, profile); } - g_free (profile); + mhl_mem_free (profile); } void @@ -313,7 +314,7 @@ save_configure (void) set_config_string (profile, str_options[i].opt_name, *str_options[i].opt_addr); - g_free (profile); + mhl_mem_free (profile); } static void @@ -380,7 +381,7 @@ save_setup (void) get_codepage_id( display_codepage ), profile_name ); #endif /* HAVE_CHARSET */ - g_free (profile); + mhl_mem_free (profile); saving_setup = 0; } @@ -413,12 +414,12 @@ panel_load_setup (WPanel *panel, const char *section) } /* User formats */ - g_free (panel->user_format); + mhl_mem_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++){ - g_free (panel->user_status_format [i]); + mhl_mem_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, @@ -471,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); - g_free (buffer); + mhl_mem_free (buffer); return p; } #endif /* !USE_NETCODE */ @@ -489,10 +490,10 @@ setup_init (void) if (!exist_file (profile)){ inifile = mhl_str_dir_plus_file (mc_home, "mc.ini"); if (exist_file (inifile)){ - g_free (profile); + mhl_mem_free (profile); profile = inifile; } else - g_free (inifile); + mhl_mem_free (inifile); } profile_name = profile; @@ -542,7 +543,7 @@ load_setup (void) if (vfs_file_is_local (buffer)) other_dir = buffer; else - g_free (buffer); + mhl_mem_free (buffer); } boot_current_is_left = @@ -603,8 +604,8 @@ load_anon_passwd () void done_setup (void) { - g_free (profile_name); - g_free (global_profile_name); + mhl_mem_free (profile_name); + mhl_mem_free (global_profile_name); done_hotlist (); done_panelize (); /* directory_history_free (); */ @@ -623,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); - g_free (section_name); + mhl_mem_free (section_name); while (profile_keys){ profile_keys = profile_iterator_next (profile_keys, &key, &value); @@ -637,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); - g_free (valcopy); + mhl_mem_free (valcopy); } } } diff --git a/src/subshell.c b/src/subshell.c index 8fcc7e496..2f2f9bfa0 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -44,6 +44,7 @@ # include /* For I_PUSH */ #endif /* HAVE_STROPTS_H */ +#include #include #include "global.h" @@ -672,8 +673,8 @@ exit_subshell (void) tcsh_fifo, unix_error_string (errno)); } - g_free (subshell_prompt); - g_free (pty_buffer); + mhl_mem_free (subshell_prompt); + mhl_mem_free (pty_buffer); subshell_prompt = NULL; pty_buffer = NULL; } @@ -764,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)); - g_free (temp); + mhl_mem_free (temp); } else { /* Should not happen unless the directory name is so long that we don't have memory to quote it. */ @@ -800,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); - g_free (cwd); + mhl_mem_free (cwd); } } diff --git a/src/tree.c b/src/tree.c index 580cfc4a1..8ff94ef15 100644 --- a/src/tree.c +++ b/src/tree.c @@ -33,6 +33,8 @@ #include #include +#include + #include "global.h" #include "tty.h" #include "color.h" @@ -126,7 +128,7 @@ static void tree_destroy (WTree *tree) tree_store_remove_entry_remove_hook (remove_callback); save_tree (tree); - g_free (tree->tree_shown); + mhl_mem_free (tree->tree_shown); tree->tree_shown = 0; tree->selected_ptr = NULL; } @@ -206,7 +208,7 @@ static void show_tree (WTree *tree) x = y = 1; } - g_free (tree->tree_shown); + mhl_mem_free (tree->tree_shown); tree->tree_shown = g_new (tree_entry*, tree_lines); for (i = 0; i < tree_lines; i++) @@ -605,7 +607,7 @@ static void tree_copy (WTree *tree, const char *default_dest) return; if (!*dest){ - g_free (dest); + mhl_mem_free (dest); return; } @@ -614,7 +616,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); - g_free (dest); + mhl_mem_free (dest); } static void @@ -646,19 +648,19 @@ static void tree_move (WTree *tree, const char *default_dest) if (!dest) return; if (!*dest){ - g_free (dest); + mhl_mem_free (dest); return; } if (stat (dest, &buf)){ message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "), unix_error_string (errno)); - g_free (dest); + mhl_mem_free (dest); return; } if (!S_ISDIR (buf.st_mode)){ file_error (_(" Destination \"%s\" must be a directory \n %s "), dest); - g_free (dest); + mhl_mem_free (dest); return; } @@ -667,7 +669,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); - g_free (dest); + mhl_mem_free (dest); } static void @@ -716,7 +718,7 @@ tree_rmdir_cmd (WTree *tree) tree->selected_ptr->name); result = query_dialog (_(" Delete "), buf, D_ERROR, 2, _("&Yes"), _("&No")); - g_free (buf); + mhl_mem_free (buf); if (result != 0) return; } diff --git a/src/treestore.c b/src/treestore.c index a9f2e818a..cb08cb2db 100644 --- a/src/treestore.c +++ b/src/treestore.c @@ -42,6 +42,7 @@ #include #include +#include #include #include "global.h" @@ -238,7 +239,7 @@ tree_store_load_from(char *name) } strcpy(oldname, name); } - g_free(name); + mhl_mem_free(name); } fclose(file); } @@ -269,7 +270,7 @@ tree_store_load(void) name = mhl_str_dir_plus_file(home_dir, MC_TREE); retval = tree_store_load_from(name); - g_free(name); + mhl_mem_free(name); return retval; } @@ -336,12 +337,12 @@ tree_store_save_to(char *name) i = fprintf(file, "%d:%d %s\n", current->scanned, common, encoded); - g_free(encoded); + mhl_mem_free(encoded); } else { char *encoded = encode(current->name); i = fprintf(file, "%d:%s\n", current->scanned, encoded); - g_free(encoded); + mhl_mem_free(encoded); } if (i == EOF) { @@ -377,15 +378,15 @@ tree_store_save(void) retval = tree_store_save_to(tmp); if (retval) { - g_free(tmp); + mhl_mem_free(tmp); return retval; } name = mhl_str_dir_plus_file(home_dir, MC_TREE); retval = rename(tmp, name); - g_free(tmp); - g_free(name); + mhl_mem_free(tmp); + mhl_mem_free(name); if (retval) return errno; @@ -483,7 +484,7 @@ tree_store_add_entry(const char *name) break; } } - g_free(parent); + mhl_mem_free(parent); } tree_store_dirty(TRUE); @@ -548,8 +549,8 @@ remove_entry(tree_entry * entry) ts.tree_last = entry->prev; /* Free the memory used by the entry */ - g_free(entry->name); - g_free(entry); + mhl_mem_free(entry->name); + mhl_mem_free(entry); return ret; } @@ -619,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)); } - g_free(name); + mhl_mem_free(name); /* Clear the deletion mark from the subdirectory and its children */ base = current; @@ -718,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; - g_free(ts.check_name); + mhl_mem_free(ts.check_name); ts.check_name = NULL; for (l = the_queue; l; l = l->next) { - g_free(l->data); + mhl_mem_free(l->data); } g_list_free(the_queue); @@ -742,7 +743,7 @@ process_special_dirs(GList ** special_dirs, char *file) *special_dirs = g_list_prepend(*special_dirs, mhl_str_dup(token)); s = NULL; } - g_free(buffer); + mhl_mem_free(buffer); } static bool @@ -802,7 +803,7 @@ tree_store_rescan(const char *dir) if (S_ISDIR(buf.st_mode)) tree_store_mark_checked(dp->d_name); } - g_free(full_name); + mhl_mem_free(full_name); } mc_closedir(dirp); } diff --git a/src/user.c b/src/user.c index 84d59ab2f..8f670eaab 100644 --- a/src/user.c +++ b/src/user.c @@ -23,6 +23,7 @@ #include #include +#include #include #include "global.h" @@ -144,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); - g_free (var_name); + mhl_mem_free (var_name); if (value){ *v = mhl_str_dup (value); return q-p; @@ -223,7 +224,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) qstr = (*quote_func) (cwd, 0); - g_free (cwd); + mhl_mem_free (cwd); return qstr; } @@ -240,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); - g_free (file); + mhl_mem_free (file); return fname; } else if (c_lc == 'b') { return strip_ext ((*quote_func) (fname, 0)); @@ -280,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)); - g_free (tmp); + mhl_mem_free (tmp); strcat (block, " "); if (c_lc == 'u') do_file_mark (panel, i, 0); @@ -470,7 +471,7 @@ debug_out (char *start, char *end, int cond) } debug_flag = 0; - g_free (msg); + mhl_mem_free (msg); msg = NULL; } else { const char *type; @@ -494,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); - g_free (msg); + mhl_mem_free (msg); msg = p; } } @@ -612,15 +613,15 @@ execute_menu_command (WEdit *edit_widget, const char *commands) /* User canceled */ fclose (cmd_file); unlink (file_name); - g_free (file_name); + mhl_mem_free (file_name); return; } if (do_quote) { fputs (tmp = name_quote (parameter, 0), cmd_file); - g_free (tmp); + mhl_mem_free (tmp); } else fputs (parameter, cmd_file); - g_free (parameter); + mhl_mem_free (parameter); parameter = 0; } else { if (parameter < &prompt [sizeof (prompt) - 1]) { @@ -639,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); - g_free (text); + mhl_mem_free (text); } } else { if (*commands == '%') { @@ -665,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); - g_free(cmd); + mhl_mem_free(cmd); } unlink (file_name); - g_free (file_name); + mhl_mem_free (file_name); } /* @@ -722,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)){ - g_free (menu); + mhl_mem_free (menu); menu = mhl_str_dir_plus_file \ (home_dir, edit_widget ? CEDIT_HOME_MENU : MC_HOME_MENU); if (!exist_file (menu)){ - g_free (menu); + mhl_mem_free (menu); menu = mhl_str_dir_plus_file \ (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); } @@ -735,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)); - g_free (menu); + mhl_mem_free (menu); menu = NULL; return; } @@ -840,9 +841,9 @@ user_menu_cmd (struct WEdit *edit_widget) } easy_patterns = old_patterns; - g_free (menu); + mhl_mem_free (menu); menu = NULL; - g_free (entries); - g_free (data); + mhl_mem_free (entries); + mhl_mem_free (data); } diff --git a/src/util.c b/src/util.c index 9e2075155..dc0346813 100644 --- a/src/util.c +++ b/src/util.c @@ -35,6 +35,7 @@ #include #include +#include #include #include "global.h" @@ -270,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); - g_free (secure_path); + mhl_mem_free (secure_path); return ret; } @@ -601,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); - g_free (old_pattern); + mhl_mem_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)) { - g_free (my_pattern); + mhl_mem_free (my_pattern); return -1; } old_pattern = my_pattern; @@ -681,7 +682,7 @@ load_file (const char *filename) if (read_size > 0) return data; else { - g_free (data); + mhl_mem_free (data); return 0; } } @@ -700,7 +701,7 @@ load_mc_home_file (const char *filename, char **allocated_filename) data = load_file (hintfile); if (!data) { - g_free (hintfile); + mhl_mem_free (hintfile); /* Fall back to the two-letter language code */ if (lang[0] && lang[1]) lang[2] = 0; @@ -708,21 +709,21 @@ load_mc_home_file (const char *filename, char **allocated_filename) data = load_file (hintfile); if (!data) { - g_free (hintfile); + mhl_mem_free (hintfile); hintfile = hintfile_base; data = load_file (hintfile_base); } } - g_free (lang); + mhl_mem_free (lang); if (hintfile != hintfile_base) - g_free (hintfile_base); + mhl_mem_free (hintfile_base); if (allocated_filename) *allocated_filename = hintfile; else - g_free (hintfile); + mhl_mem_free (hintfile); return data; } @@ -852,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); - g_free(strerror_currentlocale); + mhl_mem_free(strerror_currentlocale); #else snprintf (buffer, sizeof (buffer), "%s (%d)", g_strerror (error_num), error_num); @@ -937,12 +938,12 @@ get_current_wd (char *buffer, int size) len = strlen(p) + 1; if (len > size) { - g_free (p); + mhl_mem_free (p); return NULL; } memcpy (buffer, p, len); - g_free (p); + mhl_mem_free (p); return buffer; } @@ -1048,7 +1049,7 @@ execute_hooks (Hook *hook_list) for (hook_list = p; hook_list;){ p = hook_list; hook_list = hook_list->next; - g_free (p); + mhl_mem_free (p); } } @@ -1062,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) - g_free (current); + mhl_mem_free (current); else add_hook (&new_list, current->hook_fn, current->hook_data); } @@ -1089,7 +1090,7 @@ wipe_password (char *passwd) return; for (;*p ; p++) *p = 0; - g_free (passwd); + mhl_mem_free (passwd); } /* Convert "\E" -> esc character and ^x to control-x key and ^^ to ^ key */ @@ -1154,8 +1155,8 @@ resolve_symlinks (const char *path) c = *q; *q = 0; if (mc_lstat (path, &mybuf) < 0) { - g_free (buf); - g_free (buf2); + mhl_mem_free (buf); + mhl_mem_free (buf2); *q = c; return NULL; } @@ -1164,8 +1165,8 @@ resolve_symlinks (const char *path) else { len = mc_readlink (path, buf2, MC_MAXPATHLEN - 1); if (len < 0) { - g_free (buf); - g_free (buf2); + mhl_mem_free (buf); + mhl_mem_free (buf2); *q = c; return NULL; } @@ -1190,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; - g_free (buf2); + mhl_mem_free (buf2); return buf; } @@ -1208,7 +1209,7 @@ diff_two_paths (const char *first, const char *second) return NULL; my_second = resolve_symlinks (second); if (my_second == NULL) { - g_free (my_first); + mhl_mem_free (my_first); return NULL; } for (j = 0; j < 2; j++) { @@ -1234,10 +1235,10 @@ diff_two_paths (const char *first, const char *second) currlen = (i + 1) * 3 + strlen (q) + 1; if (j) { if (currlen < prevlen) - g_free (buf); + mhl_mem_free (buf); else { - g_free (my_first); - g_free (my_second); + mhl_mem_free (my_first); + mhl_mem_free (my_second); return buf; } } @@ -1247,8 +1248,8 @@ diff_two_paths (const char *first, const char *second) strcpy (p, "../"); strcpy (p, q); } - g_free (my_first); - g_free (my_second); + mhl_mem_free (my_first); + mhl_mem_free (my_second); return buf; } @@ -1270,7 +1271,7 @@ list_append_unique (GList *list, char *text) while (link) { newlink = g_list_previous (link); if (!strcmp ((char *) link->data, text)) { - g_free (link->data); + mhl_mem_free (link->data); g_list_remove_link (list, link); g_list_free_1 (link); } @@ -1289,7 +1290,7 @@ list_append_unique (GList *list, char *text) /* * Arguments: - * pname (output) - pointer to the name of the temp file (needs g_free). + * pname (output) - pointer to the name of the temp file (needs mhl_mem_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. @@ -1320,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)]; - g_free (tmpbase); + mhl_mem_free (tmpbase); /* Get some more or less random data. */ gettimeofday (&tv, NULL); @@ -1357,7 +1358,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix) } /* Unsuccessful. Free the filename. */ - g_free (tmpname); + mhl_mem_free (tmpname); *pname = NULL; return -1; @@ -1382,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"); - g_free (fn); + mhl_mem_free (fn); if (!f) return; @@ -1433,8 +1434,8 @@ save_file_position (const char *filename, long line, long column) /* open temporary file */ t = fopen (tmp, "w"); if (!t) { - g_free (tmp); - g_free (fn); + mhl_mem_free (tmp); + mhl_mem_free (fn); return; } @@ -1461,8 +1462,8 @@ save_file_position (const char *filename, long line, long column) fclose (t); rename (tmp, fn); - g_free (tmp); - g_free (fn); + mhl_mem_free (tmp); + mhl_mem_free (fn); } extern const char * diff --git a/src/utilunix.c b/src/utilunix.c index b550f4406..5dfa18ece 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -42,6 +42,7 @@ #include #include +#include #include #include "global.h" @@ -74,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) { - g_free (cache [*last].string); + mhl_mem_free (cache [*last].string); cache [*last].string = mhl_str_dup (text); cache [*last].index = id; *last = ((*last)+1) % size; @@ -205,7 +206,7 @@ tilde_expand (const char *directory) name = g_strndup (p, q - p); passwd = getpwnam (name); q++; - g_free (name); + mhl_mem_free (name); } } @@ -295,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); - g_free (fallback_prefix); + mhl_mem_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 5a3de16dd..dcd35596c 100644 --- a/src/view.c +++ b/src/view.c @@ -44,6 +44,7 @@ #include #include +#include #include #include "global.h" @@ -348,7 +349,7 @@ view_hexedit_free_change_list (WView *view) for (curr = view->change_list; curr != NULL; curr = next) { next = curr->next; - g_free (curr); + mhl_mem_free (curr); } view->change_list = NULL; view->dirty++; @@ -374,8 +375,8 @@ view_growbuf_free (WView *view) assert (view->growbuf_in_use); for (i = 0; i < view->growbuf_blocks; i++) - g_free (view->growbuf_blockptr[i]); - g_free (view->growbuf_blockptr); + mhl_mem_free (view->growbuf_blockptr[i]); + mhl_mem_free (view->growbuf_blockptr); view->growbuf_blockptr = NULL; view->growbuf_in_use = FALSE; } @@ -415,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) { - g_free (newblock); - g_free (newblocks); + mhl_mem_free (newblock); + mhl_mem_free (newblocks); return; } memcpy (newblocks, view->growbuf_blockptr, sizeof (*newblocks) * view->growbuf_blocks); - g_free (view->growbuf_blockptr); + mhl_mem_free (view->growbuf_blockptr); view->growbuf_blockptr = newblocks; view->growbuf_blockptr[view->growbuf_blocks++] = newblock; view->growbuf_lastindex = 0; @@ -707,11 +708,11 @@ view_close_datasource (WView *view) case DS_FILE: (void) mc_close (view->ds_file_fd); view->ds_file_fd = -1; - g_free (view->ds_file_data); + mhl_mem_free (view->ds_file_data); view->ds_file_data = NULL; break; case DS_STRING: - g_free (view->ds_string_data); + mhl_mem_free (view->ds_string_data); view->ds_string_data = NULL; break; default: @@ -1399,8 +1400,8 @@ view_toggle_magic_mode (WView *view) view_done (view); view_load (view, command, filename, 0); - g_free (filename); - g_free (command); + mhl_mem_free (filename); + mhl_mem_free (command); view->dpy_bbar_dirty = TRUE; view->dirty++; } @@ -1418,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); - g_free (canon_fname); + mhl_mem_free (canon_fname); } /* Write back the global viewer mode */ @@ -1431,8 +1432,8 @@ view_done (WView *view) /* view->widget needs no destructor */ - g_free (view->filename), view->filename = NULL; - g_free (view->command), view->command = NULL; + mhl_mem_free (view->filename), view->filename = NULL; + mhl_mem_free (view->command), view->command = NULL; view_close_datasource (view); /* the growing buffer is freed with the datasource */ @@ -1546,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)) { - g_free (view->filename); + mhl_mem_free (view->filename); view->filename = g_strconcat (file, decompress_extension (type), (char *) NULL); } view_set_datasource_file (view, fd, &st); @@ -1569,7 +1570,7 @@ view_load (WView *view, const char *command, const char *file, canon_fname = vfs_canon (file); load_file_position (file, &line, &col); - g_free (canon_fname); + mhl_mem_free (canon_fname); view_moveto (view, offset_doz(line, 1), col); } else if (start_line > 0) { view_moveto (view, start_line - 1, 0); @@ -2165,7 +2166,7 @@ view_hexedit_save_changes (WView *view) view->change_list = next; view->dirty++; view_set_byte (view, curr->offset, curr->value); - g_free (curr); + mhl_mem_free (curr); } if (mc_close (fp) == -1) { @@ -2173,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); - g_free (error); + mhl_mem_free (error); } view_update (view); return TRUE; @@ -2181,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); - g_free (error); + mhl_mem_free (error); (void) mc_close (fp); answer = query_dialog (_(" Save file "), text, D_ERROR, 2, _("&Retry"), _("&Cancel")); - g_free (text); + mhl_mem_free (text); if (answer == 0) goto retry_save; @@ -2391,7 +2392,7 @@ search (WView *view, char *text, view->update_activate = 0; enable_interrupt_key (); - for (;; g_free (s)) { + for (;; mhl_mem_free (s)) { if (p >= view->update_activate) { view->update_activate += view->update_steps; if (verbose) { @@ -2410,7 +2411,7 @@ search (WView *view, char *text, search_status = (*search) (view, text, s + 1, match_normal); if (search_status < 0) { - g_free (s); + mhl_mem_free (s); break; } @@ -2438,7 +2439,7 @@ search (WView *view, char *text, view->dpy_start = t; } - g_free (s); + mhl_mem_free (s); break; } disable_interrupt_key (); @@ -2599,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")); - g_free (buffer); + mhl_mem_free (buffer); view->search_length = 0; return; } @@ -2607,7 +2608,7 @@ hex_search (WView *view, const char *text) /* Then start the search */ pos = block_search (view, buffer, block_len); - g_free (buffer); + mhl_mem_free (buffer); if (pos == INVALID_OFFSET) { message (D_NORMAL, _("Search"), _(" Search string not found ")); @@ -2639,7 +2640,7 @@ regexp_view_search (WView *view, char *pattern, char *string, || old_type != match_type) { if (old_pattern != NULL) { regfree (&r); - g_free (old_pattern); + mhl_mem_free (old_pattern); old_pattern = 0; } for (i = 0; pattern[i] != '\0'; i++) { @@ -2743,7 +2744,7 @@ view_moveto_line_cmd (WView *view) if (*answer_end == '\0' && errno == 0 && line >= 1) view_moveto (view, line - 1, 0); } - g_free (answer); + mhl_mem_free (answer); view->dirty++; view_update (view); } @@ -2767,7 +2768,7 @@ view_moveto_addr_cmd (WView *view) message (D_ERROR, _("Warning"), _(" Invalid address ")); } } - g_free (line); + mhl_mem_free (line); } view->dirty++; view_update (view); @@ -2792,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') { - g_free (regexp); + mhl_mem_free (regexp); return; } - g_free (last_regexp); + mhl_mem_free (last_regexp); view->search_exp = last_regexp = regexp; view->direction = direction; @@ -2865,7 +2866,7 @@ view_normal_search_cmd (WView *view) convert_from_input (exp); - g_free (last_search_string); + mhl_mem_free (last_search_string); view->search_exp = last_search_string = exp; exp = NULL; @@ -2874,8 +2875,8 @@ view_normal_search_cmd (WView *view) view->last_search = do_normal_search; cleanup: - g_free (exp); - g_free (defval); + mhl_mem_free (exp); + mhl_mem_free (defval); } static void diff --git a/src/widget.c b/src/widget.c index 70f208ed2..31afab692 100644 --- a/src/widget.c +++ b/src/widget.c @@ -35,6 +35,7 @@ #include #include +#include #include #include "global.h" @@ -189,7 +190,7 @@ button_callback (Widget *w, widget_msg_t msg, int parm) return MSG_HANDLED; case WIDGET_DESTROY: - g_free (b->text); + mhl_mem_free (b->text); return MSG_HANDLED; default: @@ -282,7 +283,7 @@ button_get_text (WButton *b) void button_set_text (WButton *b, const char *text) { - g_free (b->text); + mhl_mem_free (b->text); b->text = mhl_str_dup (text); b->widget.cols = button_len (text, b->flags); button_scan_hotkey(b); @@ -475,7 +476,7 @@ check_callback (Widget *w, widget_msg_t msg, int parm) return MSG_HANDLED; case WIDGET_DESTROY: - g_free (c->text); + mhl_mem_free (c->text); return MSG_HANDLED; default: @@ -587,7 +588,7 @@ label_callback (Widget *w, widget_msg_t msg, int parm) } case WIDGET_DESTROY: - g_free (l->text); + mhl_mem_free (l->text); return MSG_HANDLED; default: @@ -603,7 +604,7 @@ label_set_text (WLabel *label, const char *text) if (label->text && text && !strcmp (label->text, text)) return; /* Flickering is not nice */ - g_free (label->text); + mhl_mem_free (label->text); if (text){ label->text = mhl_str_dup (text); @@ -879,7 +880,7 @@ history_get (const char *input_name) hist = list_append_unique (hist, mhl_str_dup (this_entry)); } - g_free (profile); + mhl_mem_free (profile); /* return pointer to the last entry in the list */ hist = g_list_last (hist); @@ -912,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) { - g_free (profile); + mhl_mem_free (profile); return; } @@ -941,7 +942,7 @@ history_put (const char *input_name, GList *h) } } - g_free (profile); + mhl_mem_free (profile); } /* }}} history saving and loading */ @@ -1052,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); - g_free (r); + mhl_mem_free (r); } } @@ -1073,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) g_free, NULL); + g_list_foreach (in->history, (GFunc) mhl_mem_free, NULL); g_list_free (in->history); } - g_free (in->buffer); + mhl_mem_free (in->buffer); free_completions (in); - g_free (in->history_name); + mhl_mem_free (in->history_name); } void @@ -1300,7 +1301,7 @@ copy_region (WInput *in, int x_first, int x_last) if (last == first) return; - g_free (kill_buffer); + mhl_mem_free (kill_buffer); kill_buffer = g_strndup(in->buffer+first,last-first); } @@ -1381,7 +1382,7 @@ yank (WInput *in) static void kill_line (WInput *in) { - g_free (kill_buffer); + mhl_mem_free (kill_buffer); kill_buffer = mhl_str_dup (&in->buffer [in->point]); in->buffer [in->point] = 0; } @@ -1390,7 +1391,7 @@ void assign_text (WInput *in, const char *text) { free_completions (in); - g_free (in->buffer); + mhl_mem_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); @@ -1856,8 +1857,8 @@ listbox_remove_list (WListbox *l) while (l->count--) { q = p->next; - g_free (p->text); - g_free (p); + mhl_mem_free (p->text); + mhl_mem_free (p); p = q; } l->pos = l->count = 0; @@ -1898,8 +1899,8 @@ listbox_remove_current (WListbox *l, int force) l->list = l->top = l->current = 0; } - g_free (p->text); - g_free (p); + mhl_mem_free (p->text); + mhl_mem_free (p); } /* Makes *e the selected entry (sets current and pos) */ @@ -2021,8 +2022,8 @@ listbox_destroy (WListbox *l) for (i = 0; i < l->count; i++){ n = p->next; - g_free (p->text); - g_free (p); + mhl_mem_free (p->text); + mhl_mem_free (p); p = n; } } @@ -2337,7 +2338,7 @@ buttonbar_callback (Widget *w, widget_msg_t msg, int parm) case WIDGET_DESTROY: for (i = 0; i < 10; i++) - g_free (bb->labels[i].text); + mhl_mem_free (bb->labels[i].text); return MSG_HANDLED; default: @@ -2384,7 +2385,7 @@ buttonbar_new (int visible) static void set_label_text (WButtonBar * bb, int index, const char *text) { - g_free (bb->labels[index - 1].text); + mhl_mem_free (bb->labels[index - 1].text); bb->labels[index - 1].text = mhl_str_dup (text); } @@ -2483,7 +2484,7 @@ groupbox_callback (Widget *w, widget_msg_t msg, int parm) return MSG_HANDLED; case WIDGET_DESTROY: - g_free (g->title); + mhl_mem_free (g->title); return MSG_HANDLED; default: @@ -2506,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); - g_free (t); + mhl_mem_free (t); } return g; diff --git a/src/wtools.c b/src/wtools.c index cfc25aaf0..099066988 100644 --- a/src/wtools.c +++ b/src/wtools.c @@ -29,6 +29,7 @@ #include #include +#include #include #include "global.h" @@ -88,7 +89,7 @@ int run_listbox (Listbox *l) else val = l->list->pos; destroy_dlg (l->dlg); - g_free (l); + mhl_mem_free (l); return val; } @@ -208,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); - g_free (p); + mhl_mem_free (p); return d; } @@ -230,7 +231,7 @@ create_message (int flags, const char *title, const char *text, ...) va_end (args); d = do_create_message (flags, title, p); - g_free (p); + mhl_mem_free (p); return d; } @@ -260,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); - g_free (title); + mhl_mem_free (title); } #endif /* WITH_BACKGROUND */ @@ -287,7 +288,7 @@ message (int flags, const char *title, const char *text, ...) #endif /* WITH_BACKGROUND */ fg_message (flags, title, p); - g_free (p); + mhl_mem_free (p); } @@ -414,7 +415,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip) } return_val = dd->ret_value; destroy_dlg (dd); - g_free (widgets); + mhl_mem_free (widgets); return return_val; } @@ -515,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); - g_free (p_text); + mhl_mem_free (p_text); if (ret != B_CANCEL) { return my_str; @@ -562,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); - g_free (result); + mhl_mem_free (result); return expanded; } return result; diff --git a/src/x11conn.c b/src/x11conn.c index 09a135f84..85059321a 100644 --- a/src/x11conn.c +++ b/src/x11conn.c @@ -35,9 +35,10 @@ typedef int dummy; /* C99 forbids empty compilation unit */ #else #include - #include +#include + #include "../src/global.h" #ifdef HAVE_GMODULE @@ -134,7 +135,7 @@ static bool x11_available(void) if (x11_module == NULL) x11_module = g_module_open ("libX11.so.6", G_MODULE_BIND_LAZY); - g_free (x11_module_fname); + mhl_mem_free (x11_module_fname); if (x11_module == NULL) return FALSE; diff --git a/vfs/cpio.c b/vfs/cpio.c index 0019b4bf1..deccfd895 100644 --- a/vfs/cpio.c +++ b/vfs/cpio.c @@ -22,6 +22,7 @@ #include +#include #include #include "../src/global.h" @@ -146,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; - g_free (l); + mhl_mem_free (l); } super->u.arch.deferred = NULL; } @@ -177,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); - g_free (s); + mhl_mem_free (s); return -1; } - g_free (s); + mhl_mem_free (s); } super->u.arch.fd = fd; @@ -293,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) { - g_free(name); + mhl_mem_free(name); return STATUS_EOF; } name[u.buf.c_namesize - 1] = '\0'; @@ -301,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 */ - g_free(name); + mhl_mem_free(name); return STATUS_TRAIL; } @@ -352,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) { - g_free (name); + mhl_mem_free (name); return STATUS_EOF; } name[hd.c_namesize - 1] = '\0'; @@ -360,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 */ - g_free(name); + mhl_mem_free(name); return STATUS_TRAIL; } @@ -417,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) { - g_free (name); + mhl_mem_free (name); return STATUS_EOF; } name[hd.c_namesize - 1] = '\0'; @@ -425,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 */ - g_free(name); + mhl_mem_free(name); return STATUS_TRAIL; } @@ -548,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; - g_free (name); + mhl_mem_free (name); return STATUS_EOF; } inode->linkname[st->st_size] = 0; /* Linkname stored without terminating \0 !!! */ @@ -560,7 +561,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super, } /* !entry */ - g_free (name); + mhl_mem_free (name); return STATUS_OK; } diff --git a/vfs/direntry.c b/vfs/direntry.c index d85c1d833..e49616677 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -28,6 +28,7 @@ #include +#include #include #include "../src/global.h" @@ -98,14 +99,14 @@ vfs_s_free_inode (struct vfs_class *me, struct vfs_s_inode *ino) } CALL (free_inode) (me, ino); - g_free (ino->linkname); + mhl_mem_free (ino->linkname); if (ino->localname){ unlink (ino->localname); - g_free(ino->localname); + mhl_mem_free(ino->localname); } total_inodes--; ino->super->ino_usage--; - g_free(ino); + mhl_mem_free(ino); } else ino->st.st_nlink--; } @@ -118,7 +119,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent) ent->next->prevp = ent->prevp; } - g_free (ent->name); + mhl_mem_free (ent->name); ent->name = NULL; if (ent->ino){ @@ -128,7 +129,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent) } total_entries--; - g_free(ent); + mhl_mem_free(ent); } void @@ -230,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; - g_free (fullpath); + mhl_mem_free (fullpath); } } target = (MEDATA->find_entry) (me, entry->dir->super->root, linkname, follow - 1, 0); - g_free (fullname); + mhl_mem_free (fullname); return target; } @@ -261,7 +262,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root, path++; if (!path[0]) { - g_free (pathref); + mhl_mem_free (pathref); return ent; } @@ -292,7 +293,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root, root = ent->ino; } cleanup: - g_free (pathref); + mhl_mem_free (pathref); return NULL; } @@ -339,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); - g_free (path); + mhl_mem_free (path); return retval; } @@ -364,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); - g_free (path); + mhl_mem_free (path); return NULL; } vfs_s_insert_entry (me, root, ent); @@ -378,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)) { - g_free (path); + mhl_mem_free (path); return NULL; } #endif - g_free (path); + mhl_mem_free (path); return ent; } @@ -449,8 +450,8 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super) } CALL (free_archive) (me, super); - g_free (super->name); - g_free(super); + mhl_mem_free (super->name); + mhl_mem_free(super); } @@ -524,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)); - g_free (buf); + mhl_mem_free (buf); return retval; } @@ -552,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); - g_free (path); + mhl_mem_free (path); path = newpath; } return path; @@ -590,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)); - g_free (q); + mhl_mem_free (q); return ino; } @@ -651,7 +652,7 @@ vfs_s_closedir (void *data) struct vfs_s_inode *dir = info->dir; vfs_s_free_inode (dir->super->me, dir); - g_free (data); + mhl_mem_free (data); return 0; } @@ -734,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))) { - g_free (q); + mhl_mem_free (q); ERRNOR (EEXIST, NULL); } if (!ino) { @@ -745,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)) { - g_free (q); + mhl_mem_free (q); return NULL; } @@ -759,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) { - g_free (q); + mhl_mem_free (q); return NULL; } close (tmp_handle); was_changed = 1; } - g_free (q); + mhl_mem_free (q); if (S_ISDIR (ino->st.st_mode)) ERRNOR (EISDIR, NULL); @@ -785,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))) { - g_free (fh); + mhl_mem_free (fh); return NULL; } if (fh->ino->localname) { fh->handle = open (fh->ino->localname, NO_LINEAR (flags), mode); if (fh->handle == -1) { - g_free (fh); + mhl_mem_free (fh); ERRNOR (errno, NULL); } } @@ -901,7 +902,7 @@ vfs_s_close (void *fh) res = -1; else { res = MEDATA->file_store (me, fh, s, FH->ino->localname); - g_free (s); + mhl_mem_free (s); } vfs_s_invalidate (me, FH_SUPER); } @@ -909,7 +910,7 @@ vfs_s_close (void *fh) close (FH->handle); vfs_s_free_inode (me, FH->ino); - g_free (fh); + mhl_mem_free (fh); return res; } @@ -995,7 +996,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino) close (handle); unlink (ino->localname); error_4: - g_free (ino->localname); + mhl_mem_free (ino->localname); ino->localname = NULL; return -1; } @@ -1011,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); - g_free (name); + mhl_mem_free (name); a = a->next; } } @@ -1095,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; - g_free(p); + mhl_mem_free(p); return (vfsid) archive; } diff --git a/vfs/extfs.c b/vfs/extfs.c index e4aef784e..0cb8bd754 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -36,6 +36,7 @@ #endif #include +#include #include #include "../src/global.h" @@ -125,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); - g_free (name); + mhl_mem_free (name); a = a->next; } } @@ -218,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); - g_free(archive->local_name); + mhl_mem_free(archive->local_name); } - g_free (archive->name); - g_free (archive); + mhl_mem_free (archive->name); + mhl_mem_free (archive); } static FILE * @@ -253,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); - g_free (tmp); - g_free (mc_extfsdir); + mhl_mem_free (tmp); + mhl_mem_free (mc_extfsdir); open_error_pipe (); result = popen (cmd, "r"); - g_free (cmd); + mhl_mem_free (cmd); if (result == NULL) { close_error_pipe (D_ERROR, NULL); if (local_name) { mc_ungetlocalcopy (name, local_name, 0); - g_free(local_name); + mhl_mem_free(local_name); } return NULL; } @@ -355,7 +356,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc) 0); if (pent == NULL) { /* FIXME: Should clean everything one day */ - g_free (buffer); + mhl_mem_free (buffer); pclose (extfsd); close_error_pipe (D_ERROR, _("Inconsistent extfs archive")); return -1; @@ -374,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 */ - g_free (buffer); + mhl_mem_free (buffer); pclose (extfsd); close_error_pipe (D_ERROR, _("Inconsistent extfs archive")); @@ -419,11 +420,11 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc) } } read_extfs_continue: - g_free (current_file_name); - g_free (current_link_name); + mhl_mem_free (current_file_name); + mhl_mem_free (current_link_name); } } - g_free (buffer); + mhl_mem_free (buffer); /* Check if extfs 'list' returned 0 */ if (pclose (extfsd) != 0) { @@ -498,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); - g_free (buf); + mhl_mem_free (buf); return res2; } @@ -532,7 +533,7 @@ static char *extfs_get_path_from_entry (struct entry *entry) strcat (localpath, "/"); p = head; head = head->next; - g_free (p); + mhl_mem_free (p); } return (localpath); } @@ -567,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); - g_free (looping); + mhl_mem_free (looping); if (pent == NULL) my_errno = ENOENT; return pent; @@ -620,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); - g_free (file); + mhl_mem_free (file); archive_name = name_quote (extfs_get_archive_name (archive), 0); quoted_localname = name_quote (localname, 0); @@ -628,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); - g_free (quoted_file); - g_free (quoted_localname); - g_free (mc_extfsdir); - g_free (archive_name); + mhl_mem_free (quoted_file); + mhl_mem_free (quoted_localname); + mhl_mem_free (mc_extfsdir); + mhl_mem_free (archive_name); open_error_pipe (); retval = my_system (EXECUTE_AS_SHELL, shell, cmd); - g_free (cmd); + mhl_mem_free (cmd); close_error_pipe (D_ERROR, NULL); return retval; } @@ -650,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); - g_free (p); + mhl_mem_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); - g_free (mc_extfsdir); - g_free (archive_name); - g_free (q); + mhl_mem_free (mc_extfsdir); + mhl_mem_free (archive_name); + mhl_mem_free (q); shell_execute (cmd, 0); - g_free (cmd); + mhl_mem_free (cmd); } static void * @@ -682,7 +683,7 @@ extfs_open (struct vfs_class *me, const char *file, int flags, int mode) created = (entry != NULL); } - g_free (q); + mhl_mem_free (q); if (entry == NULL) return NULL; if ((entry = extfs_resolve_symlinks (entry)) == NULL) @@ -765,7 +766,7 @@ extfs_close (void *data) if (!file->archive->fd_usage) vfs_stamp_create (&vfs_extfs_ops, file->archive); - g_free (data); + mhl_mem_free (data); if (errno_code) ERRNOR (EIO, -1); return 0; @@ -881,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); - g_free (q); + mhl_mem_free (q); if (entry == NULL) return NULL; if ((entry = extfs_resolve_symlinks (entry)) == NULL) @@ -913,7 +914,7 @@ static void * extfs_readdir(void *data) static int extfs_closedir (void *data) { - g_free (data); + mhl_mem_free (data); return 0; } @@ -960,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: - g_free (path2); + mhl_mem_free (path2); return result; } @@ -1007,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: - g_free (mpath); + mhl_mem_free (mpath); return result; } @@ -1052,7 +1053,7 @@ static int extfs_unlink (struct vfs_class *me, const char *file) extfs_remove_entry (entry); result = 0; cleanup: - g_free (mpath); + mhl_mem_free (mpath); return result; } @@ -1089,7 +1090,7 @@ static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) } result = 0; cleanup: - g_free (mpath); + mhl_mem_free (mpath); return result; } @@ -1119,7 +1120,7 @@ static int extfs_rmdir (struct vfs_class *me, const char *path) extfs_remove_entry (entry); result = 0; cleanup: - g_free (mpath); + mhl_mem_free (mpath); return result; } @@ -1134,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); - g_free (q); + mhl_mem_free (q); if (!entry) return -1; entry = extfs_resolve_symlinks (entry); @@ -1159,7 +1160,7 @@ extfs_getid (struct vfs_class *me, const char *path) if (!(p = extfs_get_path (me, path, &archive, 1))) return NULL; - g_free (p); + mhl_mem_free (p); return (vfsid) archive; } @@ -1201,12 +1202,12 @@ static void extfs_remove_entry (struct entry *e) unlink (e->inode->local_filename); free (e->inode->local_filename); } - g_free (e->inode->linkname); - g_free (e->inode); + mhl_mem_free (e->inode->linkname); + mhl_mem_free (e->inode); } - g_free (e->name); - g_free (e); + mhl_mem_free (e->name); + mhl_mem_free (e); } static void extfs_free_entry (struct entry *e) @@ -1223,13 +1224,13 @@ static void extfs_free_entry (struct entry *e) unlink (e->inode->local_filename); free (e->inode->local_filename); } - g_free (e->inode->linkname); - g_free (e->inode); + mhl_mem_free (e->inode->linkname); + mhl_mem_free (e->inode); } if (e->next_in_dir != NULL) extfs_free_entry (e->next_in_dir); - g_free (e->name); - g_free (e); + mhl_mem_free (e->name); + mhl_mem_free (e); } static void extfs_free (vfsid id) @@ -1306,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); - g_free (mc_extfsini); + mhl_mem_free (mc_extfsini); return 0; } @@ -1322,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); - g_free (mc_extfsini); + mhl_mem_free (mc_extfsini); return 0; } if (*key == '#' || *key == '\n') @@ -1342,7 +1343,7 @@ static int extfs_init (struct vfs_class *me) extfs_prefixes [extfs_no++] = mhl_str_dup (key); } fclose(cfg); - g_free (mc_extfsini); + mhl_mem_free (mc_extfsini); return 1; } @@ -1371,7 +1372,7 @@ static void extfs_done (struct vfs_class *me) } for (i = 0; i < extfs_no; i++ ) - g_free (extfs_prefixes [i]); + mhl_mem_free (extfs_prefixes [i]); extfs_no = 0; } diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index d2213954a..2c0900011 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 ); - g_free (remote_path); + mhl_mem_free (remote_path); remote_path = s; } } @@ -56,6 +56,7 @@ 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 */ @@ -69,6 +70,7 @@ What to do with this? #include #include +#include #include #include "../src/global.h" @@ -246,14 +248,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)) { - g_free (*pass); + mhl_mem_free (*pass); *pass = NULL; } - g_free (new_user); + mhl_mem_free (new_user); } - g_free (p); + mhl_mem_free (p); } /* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */ @@ -310,7 +312,7 @@ ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super) if (!cwdir) return 1; sock = ftpfs_chdir_internal (me, super, cwdir); - g_free (cwdir); + mhl_mem_free (cwdir); return sock == COMPLETE; } SUP.cwdir = cwdir; @@ -364,7 +366,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, } got_sigpipe = 1; } - g_free (cmdstr); + mhl_mem_free (cmdstr); disable_interrupt_key (); return TRANSIENT; } @@ -388,10 +390,10 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, } } retry = 0; - g_free (cmdstr); + mhl_mem_free (cmdstr); return status; } - g_free (cmdstr); + mhl_mem_free (cmdstr); return COMPLETE; } @@ -403,10 +405,10 @@ ftpfs_free_archive (struct vfs_class *me, struct vfs_s_super *super) ftpfs_command(me, super, NONE, "QUIT"); close(SUP.sock); } - g_free (SUP.host); - g_free (SUP.user); - g_free (SUP.cwdir); - g_free (SUP.password); + mhl_mem_free (SUP.host); + mhl_mem_free (SUP.user); + mhl_mem_free (SUP.cwdir); + mhl_mem_free (SUP.password); } /* some defines only used by ftpfs_changetype */ @@ -457,7 +459,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); - g_free (p); + mhl_mem_free (p); if (op == NULL) ERRNOR (EPERM, 0); SUP.password = mhl_str_dup (op); @@ -503,13 +505,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, ""); - g_free (p); + mhl_mem_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); - g_free (op); + mhl_mem_free (op); } if (code != COMPLETE) break; @@ -518,7 +520,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, case COMPLETE: print_vfs_message (_("ftpfs: logged in")); wipe_password (pass); - g_free (name); + mhl_mem_free (name); return 1; default: @@ -534,7 +536,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, SUP.user); login_fail: wipe_password (pass); - g_free (name); + mhl_mem_free (name); ERRNOR (EPERM, 0); } @@ -584,7 +586,7 @@ ftpfs_load_no_proxy_list (void) fclose (npf); } - g_free (mc_file); + mhl_mem_free (mc_file); } /* Return 1 if FTP proxy should be used for this host, 0 otherwise */ @@ -636,8 +638,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); - g_free (user); - g_free (dir); + mhl_mem_free (user); + mhl_mem_free (dir); } static int @@ -680,7 +682,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) - g_free (host); + mhl_mem_free (host); return -1; } server_address.sin_family = hp->h_addrtype; @@ -696,13 +698,13 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super) disable_interrupt_key(); ftpfs_errno = errno; if (free_host) - g_free (host); + mhl_mem_free (host); return -1; } print_vfs_message (_("ftpfs: making connection to %s"), host); if (free_host) - g_free (host); + mhl_mem_free (host); if (connect (my_socket, (struct sockaddr *) &server_address, sizeof (server_address)) < 0){ @@ -817,8 +819,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)); - g_free (host); - g_free (user); + mhl_mem_free (host); + mhl_mem_free (user); return port; } @@ -969,7 +971,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); - g_free (remote_path); + mhl_mem_free (remote_path); } else j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd); if (j != PRELIM) @@ -1155,7 +1157,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); - g_free(filename); + mhl_mem_free(filename); if (r == 0) { if (S_ISLNK (s.st_mode)) { /* This server doesn't understand LIST -lLa */ @@ -1236,7 +1238,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); - g_free (path); + mhl_mem_free (path); } if (sock == -1) @@ -1409,7 +1411,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); - g_free (name); + mhl_mem_free (name); if (FH_SOCK == -1) ERRNOR (EACCES, 0); fh->linear = LS_LINEAR_OPEN; @@ -1485,23 +1487,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))) { - g_free(mpath); + mhl_mem_free(mpath); return -1; } p = ftpfs_translate_path (me, super, rpath); r = ftpfs_command (me, super, WAIT_REPLY, cmd, p); - g_free (p); + mhl_mem_free (p); vfs_stamp_create (&vfs_ftpfs_ops, super); if (flags & OPT_IGNORE_ERROR) r = COMPLETE; if (r != COMPLETE) { me->verrno = EPERM; - g_free (mpath); + mhl_mem_free (mpath); return -1; } if (flush_directory_cache) vfs_s_invalidate(me, super); - g_free(mpath); + mhl_mem_free(mpath); return 0; } @@ -1577,12 +1579,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); - g_free (p); + mhl_mem_free (p); if (r != COMPLETE) { ftpfs_errno = EIO; } else { - g_free(SUP.cwdir); + mhl_mem_free(SUP.cwdir); SUP.cwdir = mhl_str_dup (remote_path); SUP.cwd_deferred = 0; } @@ -1645,7 +1647,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); - g_free (name); + mhl_mem_free (name); if (fh->handle < 0) return -1; @@ -1657,7 +1659,7 @@ ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, if (fh->ino->localname) { unlink (fh->ino->localname); - g_free (fh->ino->localname); + mhl_mem_free (fh->ino->localname); fh->ino->localname = NULL; } return 0; @@ -1696,12 +1698,12 @@ ftpfs_done (struct vfs_class *me) while (no_proxy) { np = no_proxy->next; - g_free (no_proxy->domain); - g_free (no_proxy); + mhl_mem_free (no_proxy->domain); + mhl_mem_free (no_proxy); no_proxy = np; } - g_free (ftpfs_anonymous_passwd); - g_free (ftpfs_proxy_host); + mhl_mem_free (ftpfs_anonymous_passwd); + mhl_mem_free (ftpfs_proxy_host); } static void @@ -1713,7 +1715,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); - g_free (name); + mhl_mem_free (name); super = super->next; } } @@ -1891,7 +1893,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) { - g_free (netrcname); + mhl_mem_free (netrcname); return 0; } @@ -1966,8 +1968,8 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) break; } - g_free (netrc); - g_free (netrcname); + mhl_mem_free (netrc); + mhl_mem_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 8da894618..70d0e651c 100644 --- a/vfs/gc.c +++ b/vfs/gc.c @@ -31,6 +31,7 @@ #include #include /* is_digit() */ +#include #include #include "../src/global.h" @@ -109,7 +110,7 @@ vfs_rmstamp (struct vfs_class *v, vfsid id) } else { st1->next = stamp->next; } - g_free (stamp); + mhl_mem_free (stamp); return; } @@ -128,7 +129,7 @@ vfs_getid (struct vfs_class *vclass, const char *dir) if (vclass->getid) id = (*vclass->getid) (vclass, dir1); - g_free (dir1); + mhl_mem_free (dir1); return id; } @@ -297,7 +298,7 @@ vfs_gc_done (void) if (stamp->v->free) (*stamp->v->free) (stamp->id); st = stamp->next; - g_free (stamp); + mhl_mem_free (stamp); stamp = st; } diff --git a/vfs/local.c b/vfs/local.c index 29ff36b5f..96ba885c2 100644 --- a/vfs/local.c +++ b/vfs/local.c @@ -5,6 +5,7 @@ #include #include +#include #include #include "../src/global.h" @@ -69,7 +70,7 @@ local_close (void *data) return -1; fd = *(int *) data; - g_free (data); + mhl_mem_free (data); return close (fd); } @@ -110,7 +111,7 @@ local_closedir (void *data) int i; i = closedir (* (DIR **) data); - g_free (data); + mhl_mem_free (data); return i; } diff --git a/vfs/mcfs.c b/vfs/mcfs.c index dde1b45fd..293e59dcd 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); - g_free (name); + mhl_mem_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))) { - g_free (remote_path); + mhl_mem_free (remote_path); remote_path = NULL; } - g_free (host); - g_free (user); + mhl_mem_free (host); + mhl_mem_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); - g_free (remote_path); + mhl_mem_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) { - g_free (r1); + mhl_mem_free (r1); return -1; } rpc_send (mc->sock, RPC_INT, command, RPC_STRING, r1, RPC_STRING, r2, RPC_END); - g_free (r1); - g_free (r2); + mhl_mem_free (r1); + mhl_mem_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); - g_free (remote_file); + mhl_mem_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); - g_free (remote_file); + mhl_mem_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); - g_free (remote_file); + mhl_mem_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); - g_free (remote_file); + mhl_mem_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); - g_free (data); + mhl_mem_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); - g_free (remote_dir); + mhl_mem_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); - g_free (de->text); - g_free (de); + mhl_mem_free (de->text); + mhl_mem_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; - g_free (q->text); - g_free (q); + mhl_mem_free (q->text); + mhl_mem_free (q); } - g_free (info); + mhl_mem_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); - g_free (buf); + mhl_mem_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); - g_free (remote_file); + mhl_mem_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); } - g_free (file); + mhl_mem_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); - g_free (remote_file); + mhl_mem_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); - g_free (stat_str); + mhl_mem_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); - g_free (remote_dir); + mhl_mem_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) { - g_free (host); - g_free (user); + mhl_mem_free (host); + mhl_mem_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); } } - g_free (p); - g_free (host); - g_free (user); + mhl_mem_free (p); + mhl_mem_free (host); + mhl_mem_free (user); if (pass) wipe_password (pass); } @@ -1215,9 +1215,9 @@ init_mcfs (void) static void mcfs_free_bucket (int bucket) { - g_free (mcfs_connections[bucket].host); - g_free (mcfs_connections[bucket].user); - g_free (mcfs_connections[bucket].home); + mhl_mem_free (mcfs_connections[bucket].host); + mhl_mem_free (mcfs_connections[bucket].user); + mhl_mem_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 d79c6f355..83e6795c2 100644 --- a/vfs/mcserv.c +++ b/vfs/mcserv.c @@ -124,10 +124,6 @@ # 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; @@ -214,7 +210,7 @@ do_open (void) handle = open (arg, flags, mode); send_status (handle, errno); - g_free (arg); + mhl_mem_free (arg); } static void @@ -241,7 +237,7 @@ do_read (void) send_status (n, 0); rpc_send (msock, RPC_BLOCK, n, data, RPC_END); - g_free (data); + mhl_mem_free (data); } static void @@ -381,7 +377,7 @@ do_lstat (void) send_status (n, errno); if (n >= 0) send_stat_info (&st); - g_free (file); + mhl_mem_free (file); } static void @@ -413,7 +409,7 @@ do_stat (void) send_status (n, errno); if (n >= 0) send_stat_info (&st); - g_free (file); + mhl_mem_free (file); } /* }}} */ @@ -433,7 +429,7 @@ close_handle (int handle) mcfs_DIR.used--; if (mcfs_DIR.dirs[handle]) closedir (mcfs_DIR.dirs[handle]); - g_free (mcfs_DIR.names[handle]); + mhl_mem_free (mcfs_DIR.names[handle]); mcfs_DIR.dirs[handle] = 0; mcfs_DIR.names[handle] = 0; } @@ -449,7 +445,7 @@ do_opendir (void) if (mcfs_DIR.used == OPENDIR_HANDLES) { send_status (-1, ENFILE); /* Error */ - g_free (arg); + mhl_mem_free (arg); return; } @@ -463,7 +459,7 @@ do_opendir (void) if (handle == -1) { send_status (-1, EMFILE); - g_free (arg); + mhl_mem_free (arg); if (!inetd_started) fprintf (stderr, "OOPS! you have found a bug in mc - do_opendir()!\n"); @@ -483,7 +479,7 @@ do_opendir (void) } else { send_status (-1, errno); - g_free (arg); + mhl_mem_free (arg); } } @@ -518,7 +514,7 @@ do_readdir (void) snprintf (fname, fname_len, "%s/%s", mcfs_DIR.names[handle], dirent->d_name); n = lstat (fname, &st); - g_free (fname); + mhl_mem_free (fname); send_status (n, errno); if (n >= 0) send_stat_info (&st); @@ -549,7 +545,7 @@ do_chdir (void) status = chdir (file); send_status (status, errno); - g_free (file); + mhl_mem_free (file); } static void @@ -562,7 +558,7 @@ do_rmdir (void) status = rmdir (file); send_status (status, errno); - g_free (file); + mhl_mem_free (file); } static void @@ -575,7 +571,7 @@ do_mkdir (void) status = mkdir (file, mode); send_status (status, errno); - g_free (file); + mhl_mem_free (file); } static void @@ -589,7 +585,7 @@ do_mknod (void) status = mknod (file, mode, dev); send_status (status, errno); - g_free (file); + mhl_mem_free (file); } static void @@ -606,7 +602,7 @@ do_readlink (void) buffer[n] = 0; rpc_send (msock, RPC_STRING, buffer, RPC_END); } - g_free (file); + mhl_mem_free (file); } static void @@ -618,7 +614,7 @@ do_unlink (void) rpc_get (msock, RPC_STRING, &file, RPC_END); status = unlink (file); send_status (status, errno); - g_free (file); + mhl_mem_free (file); } static void @@ -630,8 +626,8 @@ do_rename (void) rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); status = rename (f1, f2); send_status (status, errno); - g_free (f1); - g_free (f2); + mhl_mem_free (f1); + mhl_mem_free (f2); } static void @@ -643,8 +639,8 @@ do_symlink (void) rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); status = symlink (f1, f2); send_status (status, errno); - g_free (f1); - g_free (f2); + mhl_mem_free (f1); + mhl_mem_free (f2); } static void @@ -656,8 +652,8 @@ do_link (void) rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); status = link (f1, f2); send_status (status, errno); - g_free (f1); - g_free (f2); + mhl_mem_free (f1); + mhl_mem_free (f2); } @@ -686,7 +682,7 @@ do_chmod (void) rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_END); status = chmod (file, mode); send_status (status, errno); - g_free (file); + mhl_mem_free (file); } static void @@ -699,7 +695,7 @@ do_chown (void) RPC_END); status = chown (file, owner, group); send_status (status, errno); - g_free (file); + mhl_mem_free (file); } static void @@ -720,13 +716,13 @@ do_utime (void) if (verbose) printf ("Got a = %s, m = %s, comp a = %ld, m = %ld\n", as, ms, atime, mtime); - g_free (as); - g_free (ms); + mhl_mem_free (as); + mhl_mem_free (ms); times.actime = (time_t) atime; times.modtime = (time_t) mtime; status = utime (file, ×); send_status (status, errno); - g_free (file); + mhl_mem_free (file); } static void diff --git a/vfs/sfs.c b/vfs/sfs.c index a8ae3ba72..705de5d6f 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -34,6 +34,7 @@ #include #include +#include #include #include "../src/global.h" @@ -82,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, "/")) { - g_free (pname); + mhl_mem_free (pname); return -1; } @@ -90,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) { - g_free (pname); + mhl_mem_free (pname); return -1; } pqname = name_quote (s, 0); - g_free (s); + mhl_mem_free (s); } else { pqname = name_quote (pname, 0); } - g_free (pname); + mhl_mem_free (pname); #define COPY_CHAR \ if ((size_t) (t-pad) > sizeof(pad)) { \ - g_free (pqname); \ + mhl_mem_free (pqname); \ return -1; \ } \ else \ @@ -110,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)) { \ - g_free (pqname); \ + mhl_mem_free (pqname); \ return -1; \ } else { \ strcpy (t, a); \ @@ -146,7 +147,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache) } } - g_free (pqname); + mhl_mem_free (pqname); open_error_pipe (); if (my_system (EXECUTE_AS_SHELL, "/bin/sh", pad)) { close_error_pipe (D_ERROR, NULL); @@ -193,7 +194,7 @@ sfs_redirect (struct vfs_class *me, const char *name) } unlink (cache); - g_free (cache); + mhl_mem_free (cache); return "/I_MUST_NOT_EXIST"; } @@ -287,9 +288,9 @@ static void sfs_free (vfsid id) else head = cur->next; - g_free (cur->cache); - g_free (cur->name); - g_free (cur); + mhl_mem_free (cur->cache); + mhl_mem_free (cur->name); + mhl_mem_free (cur); } static void sfs_fill_names (struct vfs_class *me, fill_names_f func) @@ -343,10 +344,10 @@ static int sfs_init (struct vfs_class *me) if (!cfg){ fprintf (stderr, _("Warning: file %s not found\n"), mc_sfsini); - g_free (mc_sfsini); + mhl_mem_free (mc_sfsini); return 0; } - g_free (mc_sfsini); + mhl_mem_free (mc_sfsini); sfs_no = 0; while (sfs_no < MAXFS && fgets (key, sizeof (key), cfg)) { @@ -408,8 +409,8 @@ sfs_done (struct vfs_class *me) (void) me; for (i = 0; i < sfs_no; i++){ - g_free (sfs_prefix [i]); - g_free (sfs_command [i]); + mhl_mem_free (sfs_prefix [i]); + mhl_mem_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 a4e50505e..db0d94525 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) { - g_free(string_to_free); + mhl_mem_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) { - g_free (a->host); - g_free (a->share); - g_free (a->domain); - g_free (a->user); + mhl_mem_free (a->host); + mhl_mem_free (a->share); + mhl_mem_free (a->domain); + mhl_mem_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); - g_free (data.host); - g_free (data.share); + mhl_mem_free (data.host); + mhl_mem_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) { - g_free (bucket->domain); - g_free (bucket->user); - g_free (bucket->password); + mhl_mem_free (bucket->domain); + mhl_mem_free (bucket->user); + mhl_mem_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) { - g_free (bucket->domain); - g_free (bucket->user); - g_free (bucket->password); + mhl_mem_free (bucket->domain); + mhl_mem_free (bucket->user); + mhl_mem_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); - g_free (path); + mhl_mem_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); - g_free(host); + mhl_mem_free(host); return False; } - g_free(host); + mhl_mem_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); - g_free (my_dirname); + mhl_mem_free (my_dirname); return 0; } if (*(my_dirname) == 0) smbfs_info->dirname = smbfs_info->conn->service; - g_free (my_dirname); + mhl_mem_free (my_dirname); /* do_dskattr(); */ done: @@ -805,8 +805,8 @@ smbfs_free_dir (dir_entry *de) if (!de) return; smbfs_free_dir (de->next); - g_free (de->text); - g_free (de); + mhl_mem_free (de->text); + mhl_mem_free (de); } #endif @@ -855,10 +855,10 @@ smbfs_closedir (void *info) /* for (p = smbfs_info->entries; p;){ q = p; p = p->next; - g_free (q->text); - g_free (q); + mhl_mem_free (q->text); + mhl_mem_free (q); } - g_free (info); */ + mhl_mem_free (info); */ return 0; } @@ -1043,12 +1043,12 @@ smbfs_get_master_browser(char **host) static void smbfs_free_bucket (smbfs_connection *bucket) { - g_free (bucket->host); - g_free (bucket->service); - g_free (bucket->domain); - g_free (bucket->user); + mhl_mem_free (bucket->host); + mhl_mem_free (bucket->service); + mhl_mem_free (bucket->domain); + mhl_mem_free (bucket->user); wipe_password (bucket->password); - g_free (bucket->home); + mhl_mem_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? */ - g_free (host); + mhl_mem_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) { - g_free (remote_path); + mhl_mem_free (remote_path); remote_path = NULL; } - g_free (host); - g_free (user); + mhl_mem_free (host); + mhl_mem_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); - g_free (remote_path); + mhl_mem_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); - g_free (p); + mhl_mem_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; - g_free (mypath); + mhl_mem_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() */ -/* g_free(single_entry->text); - g_free(single_entry); */ - g_free (mypath); +/* mhl_mem_free(single_entry->text); + mhl_mem_free(single_entry); */ + mhl_mem_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)); - g_free (mdp); + mhl_mem_free (mdp); DEBUG (1, (" PARENT:found in %s\n", current_info->dirname)); return 0; } - g_free (mdp); + mhl_mem_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; - g_free (remote_dir); + mhl_mem_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); - g_free(mypath); + mhl_mem_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; - g_free (service); + mhl_mem_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) { - g_free (service); + mhl_mem_free (service); return -1; } DEBUG (6, ("loaded dir: '%s'\n", current_info->dirname)); } - g_free (service); + mhl_mem_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; - g_free (remote_file); + mhl_mem_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)); - g_free (cpath); + mhl_mem_free (cpath); return -1; } - g_free (cpath); + mhl_mem_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; - g_free (remote_file); + mhl_mem_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)); - g_free (cpath); + mhl_mem_free (cpath); return -1; } - g_free (cpath); + mhl_mem_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))) { - g_free (p); + mhl_mem_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) } } } - g_free (host); - g_free (user); + mhl_mem_free (host); + mhl_mem_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); - g_free (remote_file); + mhl_mem_free (remote_file); if (!ret) - g_free (remote_handle); + mhl_mem_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)); - g_free (remote_file); + mhl_mem_free (remote_file); return -1; } - g_free (remote_file); + mhl_mem_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) { - g_free (ra); + mhl_mem_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); - g_free (ra); - g_free (rb); + mhl_mem_free (ra); + mhl_mem_free (rb); if (!retval) { message (D_ERROR, MSG_ERROR, _(" %s renaming files\n"), diff --git a/vfs/tar.c b/vfs/tar.c index 12a4c8f34..eda0e7a9c 100644 --- a/vfs/tar.c +++ b/vfs/tar.c @@ -35,6 +35,8 @@ #include #endif +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -246,7 +248,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); - g_free (s); + mhl_mem_free (s); if (result == -1) ERRNOR (ENOENT, -1); } @@ -494,13 +496,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); - g_free (*longp); + mhl_mem_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) { - g_free (*longp); + mhl_mem_free (*longp); *longp = NULL; message (D_ERROR, MSG_ERROR, _("Unexpected EOF on archive file")); @@ -515,7 +517,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, } if (bp - *longp == MC_MAXPATHLEN && bp[-1] != '\0') { - g_free (*longp); + mhl_mem_free (*longp); *longp = NULL; message (D_ERROR, MSG_ERROR, _("Inconsistent tar archive")); return STATUS_BADCHECKSUM; @@ -560,8 +562,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); - g_free (temp_name); - g_free (temp_prefix); + mhl_mem_free (temp_name); + mhl_mem_free (temp_prefix); } break; case TAR_GNU: @@ -605,7 +607,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); - g_free (current_link_name); + mhl_mem_free (current_link_name); goto done; } } @@ -617,12 +619,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) { - g_free (current_link_name); + mhl_mem_free (current_link_name); } entry = vfs_s_new_entry (me, p, inode); vfs_s_insert_entry (me, parent, entry); - g_free (current_file_name); + mhl_mem_free (current_file_name); done: next_long_link = next_long_name = NULL; diff --git a/vfs/undelfs.c b/vfs/undelfs.c index 00afcaf83..f4f514148 100644 --- a/vfs/undelfs.c +++ b/vfs/undelfs.c @@ -51,6 +51,7 @@ #include #include +#include #include #include "../src/global.h" @@ -100,11 +101,11 @@ undelfs_shutdown (void) if (fs) ext2fs_close (fs); fs = NULL; - g_free (ext2_fname); + mhl_mem_free (ext2_fname); ext2_fname = NULL; - g_free (delarray); + mhl_mem_free (delarray); delarray = NULL; - g_free (block_buf); + mhl_mem_free (block_buf); block_buf = NULL; } @@ -145,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); - g_free (tmp); + mhl_mem_free (tmp); return; } p--; @@ -275,10 +276,10 @@ undelfs_loaddel (void) error_out: ext2fs_close_inode_scan (scan); free_block_buf: - g_free (block_buf); + mhl_mem_free (block_buf); block_buf = NULL; free_delarray: - g_free (delarray); + mhl_mem_free (delarray); delarray = NULL; return 0; } @@ -300,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); - g_free (str); + mhl_mem_free (str); } static void * @@ -313,7 +314,7 @@ undelfs_opendir (struct vfs_class *me, const char *dirname) return 0; /* We don't use the file name */ - g_free (f); + mhl_mem_free (f); if (!ext2_fname || strcmp (ext2_fname, file)){ undelfs_shutdown (); @@ -321,7 +322,7 @@ undelfs_opendir (struct vfs_class *me, const char *dirname) } else { /* To avoid expensive re-scannings */ readdir_ptr = READDIR_PTR_INIT; - g_free (file); + mhl_mem_free (file); return fs; } @@ -417,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 ")); - g_free (file); - g_free (f); + mhl_mem_free (file); + mhl_mem_free (f); return 0; } inode = atol (f); @@ -431,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) { - g_free (file); - g_free (f); + mhl_mem_free (file); + mhl_mem_free (f); return 0; } p->buf = g_try_malloc (fs->blocksize); if (!p->buf) { - g_free (p); - g_free (file); - g_free (f); + mhl_mem_free (p); + mhl_mem_free (file); + mhl_mem_free (f); return 0; } p->inode = inode; @@ -449,8 +450,8 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode) p->pos = 0; p->size = delarray[i].size; } - g_free (file); - g_free (f); + mhl_mem_free (file); + mhl_mem_free (f); undelfs_usage++; return p; } @@ -459,8 +460,8 @@ static int undelfs_close (void *vfs_info) { undelfs_file *p = vfs_info; - g_free (p->buf); - g_free (p); + mhl_mem_free (p->buf); + mhl_mem_free (p); undelfs_usage--; return 0; } @@ -594,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)) { - g_free (file); - g_free (f); + mhl_mem_free (file); + mhl_mem_free (f); return -1; } if (!ext2_fname || strcmp (ext2_fname, file)){ message (D_ERROR, undelfserr, _(" You have to chdir to extract files first ")); - g_free (file); - g_free (f); + mhl_mem_free (file); + mhl_mem_free (f); return 0; } inode_index = undelfs_getindex (f); - g_free (file); - g_free (f); + mhl_mem_free (file); + mhl_mem_free (f); if (inode_index == -1) return -1; @@ -640,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); - g_free (f); - g_free (file); + mhl_mem_free (f); + mhl_mem_free (file); return -1; } close (fd); - g_free (f); - g_free (file); + mhl_mem_free (f); + mhl_mem_free (file); return 0; } @@ -666,8 +667,8 @@ undelfs_getid (struct vfs_class *me, const char *path) if (!fsname) return NULL; - g_free (fname); - g_free (fsname); + mhl_mem_free (fname); + mhl_mem_free (fsname); return (vfsid) fs; } diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c index 944d6e194..980141d41 100644 --- a/vfs/utilvfs.c +++ b/vfs/utilvfs.c @@ -23,6 +23,7 @@ #include #include +#include #include #include "../src/global.h" @@ -137,7 +138,7 @@ vfs_split_url (const char *path, char **host, char **user, int *port, if (host) *host = mhl_str_dup (rest); - g_free (pcopy); + mhl_mem_free (pcopy); return retval; } #endif /* USE_NETCODE */ @@ -242,7 +243,7 @@ vfs_mkstemps (char **pname, const char *prefix, const char *basename) *q = 0; fd = mc_mkstemps (pname, prefix, suffix); - g_free (suffix); + mhl_mem_free (suffix); return fd; } @@ -873,7 +874,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, t[p] = 0; } - g_free (p_copy); + mhl_mem_free (p_copy); return 1; error: @@ -888,7 +889,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, _("More parsing errors will be ignored.")); } - g_free (p_copy); + mhl_mem_free (p_copy); return 0; } diff --git a/vfs/vfs.c b/vfs/vfs.c index dba06198c..c373f7f57 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -38,6 +38,7 @@ #include #include /* is_digit() */ +#include #include #include "../src/global.h" @@ -222,7 +223,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 g_free(path), you DON'T + * What is left in path is p1. You still want to mhl_mem_free(path), you DON'T * want to free neither *inpath nor *op */ struct vfs_class * @@ -303,7 +304,7 @@ vfs_get_class (const char *pathname) char *path = mhl_str_dup (pathname); vfs = _vfs_get_class (path); - g_free (path); + mhl_mem_free (path); if (!vfs) vfs = localfs_class; @@ -337,13 +338,13 @@ mc_open (const char *filename, int flags, ...) mode = 0; if (!vfs->open) { - g_free (file); + mhl_mem_free (file); errno = -EOPNOTSUPP; return -1; } info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */ - g_free (file); + mhl_mem_free (file); if (!info){ errno = ferrno (vfs); return -1; @@ -361,7 +362,7 @@ int mc_##name inarg \ char *mpath = vfs_canon (path); \ vfs = vfs_get_class (mpath); \ result = vfs->name ? (*vfs->name)callarg : -1; \ - g_free (mpath); \ + mhl_mem_free (mpath); \ if (result == -1) \ errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ return result; \ @@ -406,13 +407,13 @@ int mc_##name (const char *fname1, const char *fname2) \ name2 = vfs_canon (fname2); \ if (vfs != vfs_get_class (name2)){ \ errno = EXDEV; \ - g_free (name1); \ - g_free (name2); \ + mhl_mem_free (name1); \ + mhl_mem_free (name2); \ return -1; \ } \ result = vfs->name ? (*vfs->name)(vfs, name1, name2) : -1; \ - g_free (name1); \ - g_free (name2); \ + mhl_mem_free (name1); \ + mhl_mem_free (name2); \ if (result == -1) \ errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ return result; \ @@ -443,7 +444,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; - g_free (mpath); + mhl_mem_free (mpath); return result; } @@ -482,7 +483,7 @@ mc_opendir (const char *dirname) vfs = vfs_get_class (dname); info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL; - g_free (dname); + mhl_mem_free (dname); if (!info){ errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP; return NULL; @@ -523,7 +524,7 @@ mc_closedir (DIR *dirp) result = vfs->closedir ? (*vfs->closedir)(vfs_info (handle)) : -1; vfs_free_handle (handle); - g_free (dirp); + mhl_mem_free (dirp); return result; } @@ -533,7 +534,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; - g_free (path); + mhl_mem_free (path); if (result == -1) errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; return result; @@ -545,7 +546,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; - g_free (path); + mhl_mem_free (path); if (result == -1) errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; return result; @@ -584,11 +585,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) { - g_free (current_dir); + mhl_mem_free (current_dir); current_dir = p; return p; } /* Otherwise we return current_dir below */ - g_free (p); + mhl_mem_free (p); } return current_dir; } @@ -661,7 +662,7 @@ vfs_canon (const char *path) local = mhl_str_dir_plus_file (current_dir, path); result = vfs_canon (local); - g_free (local); + mhl_mem_free (local); return result; } @@ -691,7 +692,7 @@ mc_chdir (const char *path) new_dir = vfs_canon (path); new_vfs = vfs_get_class (new_dir); if (!new_vfs->chdir) { - g_free (new_dir); + mhl_mem_free (new_dir); return -1; } @@ -699,7 +700,7 @@ mc_chdir (const char *path) if (result == -1) { errno = ferrno (new_vfs); - g_free (new_dir); + mhl_mem_free (new_dir); return -1; } @@ -707,7 +708,7 @@ mc_chdir (const char *path) old_vfs = current_vfs; /* Actually change directory */ - g_free (current_dir); + mhl_mem_free (current_dir); current_dir = new_dir; current_vfs = new_vfs; @@ -741,7 +742,7 @@ vfs_file_class_flags (const char *filename) fname = vfs_canon (filename); vfs = vfs_get_class (fname); - g_free (fname); + mhl_mem_free (fname); return vfs->flags; } @@ -786,7 +787,7 @@ mc_def_getlocalcopy (const char *filename) close (fdout); if (fdin != -1) mc_close (fdin); - g_free (tmp); + mhl_mem_free (tmp); return NULL; } @@ -799,7 +800,7 @@ mc_getlocalcopy (const char *pathname) result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs, path) : mc_def_getlocalcopy (path); - g_free (path); + mhl_mem_free (path); if (!result) errno = ferrno (vfs); return result; @@ -862,7 +863,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); - g_free (path); + mhl_mem_free (path); return return_value; } @@ -906,7 +907,7 @@ vfs_shut (void) vfs_gc_done (); - g_free (current_dir); + mhl_mem_free (current_dir); for (vfs = vfs_list; vfs; vfs = vfs->next) if (vfs->done)