First bunch of mhl_mem_free removal patches

Signed-off-by: Patrick Winnertz <winnie@debian.org>
This commit is contained in:
Patrick Winnertz 2009-02-05 23:27:37 +01:00
parent 3d0f9e419a
commit 1c287d798d
76 changed files with 1016 additions and 1029 deletions

View File

@ -40,7 +40,7 @@
2009-01-30 Enrico Weigelt, metux ITS <weigelt@metux.de> 2009-01-30 Enrico Weigelt, metux ITS <weigelt@metux.de>
* replaced calls to g_free() by mhl_mem_free() * replaced calls to g_free() by g_free()
2009-01-29 Mikhail S. Pobolovets <styx.mp@gmail.com> 2009-01-29 Mikhail S. Pobolovets <styx.mp@gmail.com>

View File

@ -28,12 +28,11 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <mhl/memory.h>
#include "../src/global.h" #include "../src/global.h"
#include "edit.h" #include "edit.h"
@ -159,13 +158,13 @@ int book_mark_clear (WEdit * edit, int line, int c)
p->prev->next = p->next; p->prev->next = p->next;
if (p->next) if (p->next)
p->next->prev = p->prev; p->next->prev = p->prev;
mhl_mem_free (p); g_free (p);
break; break;
} }
} }
/* if there is only our dummy book mark left, clear it for speed */ /* if there is only our dummy book mark left, clear it for speed */
if (edit->book_mark->line == -1 && !edit->book_mark->next) { if (edit->book_mark->line == -1 && !edit->book_mark->next) {
mhl_mem_free (edit->book_mark); g_free (edit->book_mark);
edit->book_mark = 0; edit->book_mark = 0;
} }
return r; return r;
@ -186,11 +185,11 @@ void book_mark_flush (WEdit * edit, int c)
q->prev->next = q->next; q->prev->next = q->next;
if (p) if (p)
p->prev = q->prev; p->prev = q->prev;
mhl_mem_free (q); g_free (q);
} }
} }
if (!edit->book_mark->next) { if (!edit->book_mark->next) {
mhl_mem_free (edit->book_mark); g_free (edit->book_mark);
edit->book_mark = 0; edit->book_mark = 0;
} }
} }

View File

@ -74,9 +74,9 @@ edit_syntax_dialog (void) {
if ((syntax = exec_edit_syntax_dialog ((const char**) names)) < 0) { if ((syntax = exec_edit_syntax_dialog ((const char**) names)) < 0) {
for (i = 0; names[i]; i++) { for (i = 0; names[i]; i++) {
mhl_mem_free (names[i]); g_free (names[i]);
} }
mhl_mem_free (names); g_free (names);
return; return;
} }
@ -92,7 +92,7 @@ edit_syntax_dialog (void) {
break; break;
default: default:
option_auto_syntax = 0; option_auto_syntax = 0;
mhl_mem_free (option_syntax_type); g_free (option_syntax_type);
option_syntax_type = mhl_str_dup (names[syntax - N_DFLT_ENTRIES]); option_syntax_type = mhl_str_dup (names[syntax - N_DFLT_ENTRIES]);
} }
@ -104,8 +104,8 @@ edit_syntax_dialog (void) {
edit_load_syntax (wedit, NULL, option_syntax_type); edit_load_syntax (wedit, NULL, option_syntax_type);
for (i = 0; names[i]; i++) { for (i = 0; names[i]; i++) {
mhl_mem_free (names[i]); g_free (names[i]);
} }
mhl_mem_free (names); g_free (names);
mhl_mem_free (old_syntax_type); g_free (old_syntax_type);
} }

View File

@ -22,7 +22,6 @@
*/ */
#include <config.h> #include <config.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h> #include <sys/types.h>
@ -219,7 +218,7 @@ edit_get_filter (const char *filename)
l = strlen (quoted_name); l = strlen (quoted_name);
p = g_malloc (strlen (all_filters[i].read) + l + 2); p = g_malloc (strlen (all_filters[i].read) + l + 2);
sprintf (p, all_filters[i].read, quoted_name); sprintf (p, all_filters[i].read, quoted_name);
mhl_mem_free (quoted_name); g_free (quoted_name);
return p; return p;
} }
@ -235,7 +234,7 @@ edit_get_write_filter (const char *write_name, const char *filename)
l = strlen (writename); l = strlen (writename);
p = g_malloc (strlen (all_filters[i].write) + l + 2); p = g_malloc (strlen (all_filters[i].write) + l + 2);
sprintf (p, all_filters[i].write, writename); sprintf (p, all_filters[i].write, writename);
mhl_mem_free (writename); g_free (writename);
return p; return p;
} }
@ -303,7 +302,7 @@ edit_insert_file (WEdit *edit, const char *filename)
edit_insert (edit, buf[i]); edit_insert (edit, buf[i]);
} }
edit_cursor_move (edit, current - edit->curs1); edit_cursor_move (edit, current - edit->curs1);
mhl_mem_free (buf); g_free (buf);
mc_close (file); mc_close (file);
if (blocklen) if (blocklen)
return 0; return 0;
@ -450,7 +449,7 @@ edit_load_position (WEdit *edit)
filename = vfs_canon (edit->filename); filename = vfs_canon (edit->filename);
load_file_position (filename, &line, &column); load_file_position (filename, &line, &column);
mhl_mem_free (filename); g_free (filename);
edit_move_to_line (edit, line - 1); edit_move_to_line (edit, line - 1);
edit->prev_col = column; edit->prev_col = column;
@ -469,7 +468,7 @@ edit_save_position (WEdit *edit)
filename = vfs_canon (edit->filename); filename = vfs_canon (edit->filename);
save_file_position (filename, edit->curs_line + 1, edit->curs_col); save_file_position (filename, edit->curs_line + 1, edit->curs_col);
mhl_mem_free (filename); g_free (filename);
} }
/* Clean the WEdit stricture except the widget part */ /* Clean the WEdit stricture except the widget part */
@ -543,7 +542,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
if (edit_load_file (edit)) { if (edit_load_file (edit)) {
/* edit_load_file already gives an error message */ /* edit_load_file already gives an error message */
if (to_free) if (to_free)
mhl_mem_free (edit); g_free (edit);
return 0; return 0;
} }
edit->loading_done = 1; edit->loading_done = 1;
@ -594,13 +593,13 @@ edit_clean (WEdit *edit)
edit_free_syntax_rules (edit); edit_free_syntax_rules (edit);
book_mark_flush (edit, -1); book_mark_flush (edit, -1);
for (; j <= MAXBUFF; j++) { for (; j <= MAXBUFF; j++) {
mhl_mem_free (edit->buffers1[j]); g_free (edit->buffers1[j]);
mhl_mem_free (edit->buffers2[j]); g_free (edit->buffers2[j]);
} }
mhl_mem_free (edit->undo_stack); g_free (edit->undo_stack);
mhl_mem_free (edit->filename); g_free (edit->filename);
mhl_mem_free (edit->dir); g_free (edit->dir);
edit_purge_widget (edit); edit_purge_widget (edit);
@ -640,12 +639,12 @@ edit_reload (WEdit *edit, const char *filename)
e = g_malloc0 (sizeof (WEdit)); e = g_malloc0 (sizeof (WEdit));
e->widget = edit->widget; e->widget = edit->widget;
if (!edit_init (e, lines, columns, filename, 0)) { if (!edit_init (e, lines, columns, filename, 0)) {
mhl_mem_free (e); g_free (e);
return 0; return 0;
} }
edit_clean (edit); edit_clean (edit);
memcpy (edit, e, sizeof (WEdit)); memcpy (edit, e, sizeof (WEdit));
mhl_mem_free (e); g_free (e);
return 1; return 1;
} }
@ -931,7 +930,7 @@ int edit_delete (WEdit * edit)
p = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1]; 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)) { if (!(edit->curs2 & M_EDIT_BUF_SIZE)) {
mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = NULL; edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = NULL;
} }
edit->last_byte--; edit->last_byte--;
@ -968,7 +967,7 @@ edit_backspace (WEdit * edit)
p = *(edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE] + ((edit->curs1 - 1) & M_EDIT_BUF_SIZE)); 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)) { if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) {
mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL; edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL;
} }
edit->last_byte--; edit->last_byte--;
@ -1053,7 +1052,7 @@ edit_move_backward_lots (WEdit *edit, long increment)
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] =
g_malloc (EDIT_BUF_SIZE); g_malloc (EDIT_BUF_SIZE);
} else { } else {
mhl_mem_free (p); g_free (p);
} }
s = edit->curs1 & M_EDIT_BUF_SIZE; s = edit->curs1 & M_EDIT_BUF_SIZE;
@ -1091,7 +1090,7 @@ edit_move_backward_lots (WEdit *edit, long increment)
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] =
g_malloc (EDIT_BUF_SIZE); g_malloc (EDIT_BUF_SIZE);
} else { } else {
mhl_mem_free (p); g_free (p);
} }
} }
return edit_get_byte (edit, edit->curs1); return edit_get_byte (edit, edit->curs1);
@ -1127,7 +1126,7 @@ void edit_cursor_move (WEdit * edit, long increment)
edit->curs2++; edit->curs2++;
c = edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 - 1) & M_EDIT_BUF_SIZE]; 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)) { if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) {
mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]); g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL; edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL;
} }
edit->curs1--; edit->curs1--;
@ -1151,7 +1150,7 @@ void edit_cursor_move (WEdit * edit, long increment)
edit->curs1++; edit->curs1++;
c = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1]; 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)) { if (!(edit->curs2 & M_EDIT_BUF_SIZE)) {
mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]); g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = 0; edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = 0;
} }
edit->curs2--; edit->curs2--;
@ -2701,5 +2700,5 @@ user_menu (WEdit * edit)
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
cleanup: cleanup:
mhl_mem_free (block_file); g_free (block_file);
} }

View File

@ -28,6 +28,7 @@
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h> #include <sys/types.h>
@ -145,7 +146,7 @@ catstrs (const char *first,...)
len++; len++;
i = (i + 1) % 16; i = (i + 1) % 16;
mhl_mem_free (stacked[i]); g_free (stacked[i]);
stacked[i] = g_malloc (len); stacked[i] = g_malloc (len);
va_end (ap); va_end (ap);
@ -164,7 +165,7 @@ void freestrs(void)
size_t i; size_t i;
for (i = 0; i < sizeof(stacked) / sizeof(stacked[0]); i++) { for (i = 0; i < sizeof(stacked) / sizeof(stacked[0]); i++) {
mhl_mem_free (stacked[i]); g_free (stacked[i]);
stacked[i] = NULL; stacked[i] = NULL;
} }
} }
@ -216,7 +217,7 @@ edit_save_file (WEdit *edit, const char *filename)
if (*filename != PATH_SEP && edit->dir) { if (*filename != PATH_SEP && edit->dir) {
savename = mhl_str_dir_plus_file (edit->dir, filename); savename = mhl_str_dir_plus_file (edit->dir, filename);
filename = catstrs (savename, (char *) NULL); filename = catstrs (savename, (char *) NULL);
mhl_mem_free (savename); g_free (savename);
} }
this_save_mode = option_save_mode; this_save_mode = option_save_mode;
@ -281,9 +282,9 @@ edit_save_file (WEdit *edit, const char *filename)
} else } else
savedir = mhl_str_dup ("."); savedir = mhl_str_dup (".");
saveprefix = mhl_str_dir_plus_file (savedir, "cooledit"); saveprefix = mhl_str_dir_plus_file (savedir, "cooledit");
mhl_mem_free (savedir); g_free (savedir);
fd = mc_mkstemps (&savename, saveprefix, NULL); fd = mc_mkstemps (&savename, saveprefix, NULL);
mhl_mem_free (saveprefix); g_free (saveprefix);
if (!savename) if (!savename)
return 0; return 0;
/* FIXME: /* FIXME:
@ -319,7 +320,7 @@ edit_save_file (WEdit *edit, const char *filename)
edit_error_dialog (_("Error"), edit_error_dialog (_("Error"),
catstrs (_(" Error writing to pipe: "), catstrs (_(" Error writing to pipe: "),
p, " ", (char *) NULL)); p, " ", (char *) NULL));
mhl_mem_free (p); g_free (p);
goto error_save; goto error_save;
} }
#endif #endif
@ -329,10 +330,10 @@ edit_save_file (WEdit *edit, const char *filename)
(_ (_
(" Cannot open pipe for writing: "), (" Cannot open pipe for writing: "),
p, " ", (char *) NULL))); p, " ", (char *) NULL)));
mhl_mem_free (p); g_free (p);
goto error_save; goto error_save;
} }
mhl_mem_free (p); g_free (p);
} else { } else {
long buf; long buf;
buf = 0; buf = 0;
@ -393,14 +394,14 @@ edit_save_file (WEdit *edit, const char *filename)
if (this_save_mode != EDIT_QUICK_SAVE) if (this_save_mode != EDIT_QUICK_SAVE)
if (mc_rename (savename, filename) == -1) if (mc_rename (savename, filename) == -1)
goto error_save; goto error_save;
mhl_mem_free (savename); g_free (savename);
return 1; return 1;
error_save: error_save:
/* FIXME: Is this safe ? /* FIXME: Is this safe ?
* if (this_save_mode != EDIT_QUICK_SAVE) * if (this_save_mode != EDIT_QUICK_SAVE)
* mc_unlink (savename); * mc_unlink (savename);
*/ */
mhl_mem_free (savename); g_free (savename);
return 0; return 0;
} }
@ -471,7 +472,7 @@ void menu_save_mode_cmd (void)
return; return;
option_save_mode = save_mode_new; option_save_mode = save_mode_new;
mhl_mem_free (option_backup_ext); g_free (option_backup_ext);
option_backup_ext = str_result; option_backup_ext = str_result;
str_result = NULL; str_result = NULL;
} }
@ -479,7 +480,7 @@ void menu_save_mode_cmd (void)
void void
edit_set_filename (WEdit *edit, const char *f) edit_set_filename (WEdit *edit, const char *f)
{ {
mhl_mem_free (edit->filename); g_free (edit->filename);
if (!f) if (!f)
f = ""; f = "";
edit->filename = mhl_str_dup (f); edit->filename = mhl_str_dup (f);
@ -508,7 +509,7 @@ edit_save_as_cmd (WEdit *edit)
if (exp) { if (exp) {
if (!*exp) { if (!*exp) {
mhl_mem_free (exp); g_free (exp);
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
return 0; return 0;
} else { } else {
@ -525,7 +526,7 @@ edit_save_as_cmd (WEdit *edit)
_(" A file already exists with this name. "), _(" A file already exists with this name. "),
_("&Overwrite"), _("&Cancel"))) { _("&Overwrite"), _("&Cancel"))) {
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
mhl_mem_free (exp); g_free (exp);
return 0; return 0;
} }
} }
@ -551,7 +552,7 @@ edit_save_as_cmd (WEdit *edit)
} }
edit_set_filename (edit, exp); edit_set_filename (edit, exp);
mhl_mem_free (exp); g_free (exp);
edit->modified = 0; edit->modified = 0;
edit->delete_file = 0; edit->delete_file = 0;
if (different_filename) if (different_filename)
@ -567,7 +568,7 @@ edit_save_as_cmd (WEdit *edit)
/* Failed, so maintain modify (not save) lock */ /* Failed, so maintain modify (not save) lock */
if (save_lock) if (save_lock)
edit_unlock_file (exp); edit_unlock_file (exp);
mhl_mem_free (exp); g_free (exp);
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
return 0; return 0;
} }
@ -859,13 +860,13 @@ edit_load_file_from_filename (WEdit * edit, char *exp)
char *prev_filename = mhl_str_dup (edit->filename); char *prev_filename = mhl_str_dup (edit->filename);
if (!edit_reload (edit, exp)) { if (!edit_reload (edit, exp)) {
mhl_mem_free (prev_filename); g_free (prev_filename);
return 1; return 1;
} }
if (prev_locked) if (prev_locked)
edit_unlock_file (prev_filename); edit_unlock_file (prev_filename);
mhl_mem_free (prev_filename); g_free (prev_filename);
return 0; return 0;
} }
@ -891,7 +892,7 @@ edit_load_cmd (WEdit *edit)
if (exp) { if (exp) {
if (*exp) if (*exp)
edit_load_file_from_filename (edit, exp); edit_load_file_from_filename (edit, exp);
mhl_mem_free (exp); g_free (exp);
} }
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
return 0; return 0;
@ -992,7 +993,7 @@ edit_block_copy_cmd (WEdit *edit)
edit_insert_ahead (edit, copy_buf[size]); edit_insert_ahead (edit, copy_buf[size]);
} }
mhl_mem_free (copy_buf); g_free (copy_buf);
edit_scroll_screen_over_cursor (edit); edit_scroll_screen_over_cursor (edit);
if (column_highlighting) { if (column_highlighting) {
@ -1093,7 +1094,7 @@ edit_block_move_cmd (WEdit *edit)
edit->curs1 + end_mark - start_mark, 0, 0); edit->curs1 + end_mark - start_mark, 0, 0);
} }
edit_scroll_screen_over_cursor (edit); edit_scroll_screen_over_cursor (edit);
mhl_mem_free (copy_buf); g_free (copy_buf);
edit->force |= REDRAW_PAGE; edit->force |= REDRAW_PAGE;
} }
@ -1429,7 +1430,7 @@ string_regexp_search (char *pattern, char *string, int match_type,
|| old_type != match_type || old_icase != icase) { || old_type != match_type || old_icase != icase) {
if (old_pattern) { if (old_pattern) {
regfree (&r); regfree (&r);
mhl_mem_free (old_pattern); g_free (old_pattern);
old_pattern = 0; old_pattern = 0;
} }
if (regcomp (&r, pattern, REG_EXTENDED | (icase ? REG_ICASE : 0) | if (regcomp (&r, pattern, REG_EXTENDED | (icase ? REG_ICASE : 0) |
@ -1805,9 +1806,9 @@ edit_replace_cmd (WEdit *edit, int again)
int argord[NUM_REPL_ARGS]; int argord[NUM_REPL_ARGS];
if (!edit) { if (!edit) {
mhl_mem_free (saved1), saved1 = NULL; g_free (saved1), saved1 = NULL;
mhl_mem_free (saved2), saved2 = NULL; g_free (saved2), saved2 = NULL;
mhl_mem_free (saved3), saved3 = NULL; g_free (saved3), saved3 = NULL;
return; return;
} }
@ -1835,9 +1836,9 @@ edit_replace_cmd (WEdit *edit, int again)
edit_replace_dialog (edit, disp1, disp2, disp3, &input1, &input2, edit_replace_dialog (edit, disp1, disp2, disp3, &input1, &input2,
&input3); &input3);
mhl_mem_free (disp1); g_free (disp1);
mhl_mem_free (disp2); g_free (disp2);
mhl_mem_free (disp3); g_free (disp3);
convert_from_input (input1); convert_from_input (input1);
convert_from_input (input2); convert_from_input (input2);
@ -1849,9 +1850,9 @@ edit_replace_cmd (WEdit *edit, int again)
goto cleanup; goto cleanup;
} }
mhl_mem_free (saved1), saved1 = mhl_str_dup (input1); g_free (saved1), saved1 = mhl_str_dup (input1);
mhl_mem_free (saved2), saved2 = mhl_str_dup (input2); g_free (saved2), saved2 = mhl_str_dup (input2);
mhl_mem_free (saved3), saved3 = mhl_str_dup (input3); g_free (saved3), saved3 = mhl_str_dup (input3);
} }
{ {
@ -2042,9 +2043,9 @@ edit_replace_cmd (WEdit *edit, int again)
edit->force = REDRAW_COMPLETELY; edit->force = REDRAW_COMPLETELY;
edit_scroll_screen_over_cursor (edit); edit_scroll_screen_over_cursor (edit);
cleanup: cleanup:
mhl_mem_free (input1); g_free (input1);
mhl_mem_free (input2); g_free (input2);
mhl_mem_free (input3); g_free (input3);
} }
@ -2056,7 +2057,7 @@ void edit_search_cmd (WEdit * edit, int again)
char *exp = ""; char *exp = "";
if (!edit) { if (!edit) {
mhl_mem_free (old); g_free (old);
old = NULL; old = NULL;
return; return;
} }
@ -2086,7 +2087,7 @@ void edit_search_cmd (WEdit * edit, int again)
if (exp) { if (exp) {
if (*exp) { if (*exp) {
int len = 0; int len = 0;
mhl_mem_free (old); g_free (old);
old = mhl_str_dup (exp); old = mhl_str_dup (exp);
if (search_create_bookmark) { if (search_create_bookmark) {
@ -2143,7 +2144,7 @@ void edit_search_cmd (WEdit * edit, int again)
} }
} }
} }
mhl_mem_free (exp); g_free (exp);
} }
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
edit_scroll_screen_over_cursor (edit); edit_scroll_screen_over_cursor (edit);
@ -2182,7 +2183,7 @@ edit_ok_to_exit (WEdit *edit)
#define TEMP_BUF_LEN 1024 #define TEMP_BUF_LEN 1024
/* Return a null terminated length of text. Result must be mhl_mem_free'd */ /* Return a null terminated length of text. Result must be g_free'd */
static unsigned char * static unsigned char *
edit_get_block (WEdit *edit, long start, long finish, int *l) edit_get_block (WEdit *edit, long start, long finish, int *l)
{ {
@ -2235,7 +2236,7 @@ edit_save_block (WEdit * edit, const char *filename, long start,
p += r; p += r;
len -= r; len -= r;
} }
mhl_mem_free (block); g_free (block);
} else { } else {
unsigned char *buf; unsigned char *buf;
int i = start, end; int i = start, end;
@ -2248,7 +2249,7 @@ edit_save_block (WEdit * edit, const char *filename, long start,
len -= mc_write (file, (char *) buf, end - start); len -= mc_write (file, (char *) buf, end - start);
start = end; start = end;
} }
mhl_mem_free (buf); g_free (buf);
} }
mc_close (file); mc_close (file);
if (len) if (len)
@ -2322,13 +2323,13 @@ edit_goto_cmd (WEdit *edit)
return; return;
if (!*f) { if (!*f) {
mhl_mem_free (f); g_free (f);
return; return;
} }
l = strtol (f, &error, 0); l = strtol (f, &error, 0);
if (*error) { if (*error) {
mhl_mem_free (f); g_free (f);
return; return;
} }
@ -2338,7 +2339,7 @@ edit_goto_cmd (WEdit *edit)
edit_move_display (edit, l - edit->num_widget_lines / 2 - 1); edit_move_display (edit, l - edit->num_widget_lines / 2 - 1);
edit_move_to_line (edit, l - 1); edit_move_to_line (edit, l - 1);
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
mhl_mem_free (f); g_free (f);
} }
@ -2357,15 +2358,15 @@ edit_save_block_cmd (WEdit *edit)
edit_push_action (edit, KEY_PRESS + edit->start_display); edit_push_action (edit, KEY_PRESS + edit->start_display);
if (exp) { if (exp) {
if (!*exp) { if (!*exp) {
mhl_mem_free (exp); g_free (exp);
return 0; return 0;
} else { } else {
if (edit_save_block (edit, exp, start_mark, end_mark)) { if (edit_save_block (edit, exp, start_mark, end_mark)) {
mhl_mem_free (exp); g_free (exp);
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
return 1; return 1;
} else { } else {
mhl_mem_free (exp); g_free (exp);
edit_error_dialog (_(" Save Block "), edit_error_dialog (_(" Save Block "),
get_sys_error (_ get_sys_error (_
(" Cannot save file. "))); (" Cannot save file. ")));
@ -2387,15 +2388,15 @@ edit_insert_file_cmd (WEdit *edit)
edit_push_action (edit, KEY_PRESS + edit->start_display); edit_push_action (edit, KEY_PRESS + edit->start_display);
if (exp) { if (exp) {
if (!*exp) { if (!*exp) {
mhl_mem_free (exp); g_free (exp);
return 0; return 0;
} else { } else {
if (edit_insert_file (edit, exp)) { if (edit_insert_file (edit, exp)) {
mhl_mem_free (exp); g_free (exp);
edit->force |= REDRAW_COMPLETELY; edit->force |= REDRAW_COMPLETELY;
return 1; return 1;
} else { } else {
mhl_mem_free (exp); g_free (exp);
edit_error_dialog (_(" Insert File "), edit_error_dialog (_(" Insert File "),
get_sys_error (_ get_sys_error (_
(" Cannot insert file. "))); (" Cannot insert file. ")));
@ -2426,7 +2427,7 @@ int edit_sort_cmd (WEdit * edit)
if (!exp) if (!exp)
return 1; return 1;
mhl_mem_free (old); g_free (old);
old = exp; old = exp;
e = system (catstrs (" sort ", exp, " ", home_dir, PATH_SEP_STR BLOCK_FILE, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL)); e = system (catstrs (" sort ", exp, " ", home_dir, PATH_SEP_STR BLOCK_FILE, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL));
@ -2470,7 +2471,7 @@ edit_ext_cmd (WEdit *edit)
return 1; return 1;
e = system (catstrs (exp, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL)); e = system (catstrs (exp, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL));
mhl_mem_free (exp); g_free (exp);
if (e) { if (e) {
edit_error_dialog (_("External command"), edit_error_dialog (_("External command"),
@ -2566,7 +2567,7 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block)
system (catstrs (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ", system (catstrs (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ",
quoted_name, (char *) NULL)); quoted_name, (char *) NULL));
} }
mhl_mem_free (quoted_name); g_free (quoted_name);
close_error_pipe (D_NORMAL, NULL); close_error_pipe (D_NORMAL, NULL);
edit_refresh_cmd (edit); edit_refresh_cmd (edit);
@ -2607,13 +2608,13 @@ static void pipe_mail (WEdit *edit, char *to, char *subject, char *cc)
subject = name_quote (subject, 0); subject = name_quote (subject, 0);
cc = name_quote (cc, 0); cc = name_quote (cc, 0);
s = g_strconcat ("mail -s ", subject, *cc ? " -c " : "" , cc, " ", to, (char *) NULL); s = g_strconcat ("mail -s ", subject, *cc ? " -c " : "" , cc, " ", to, (char *) NULL);
mhl_mem_free (to); g_free (to);
mhl_mem_free (subject); g_free (subject);
mhl_mem_free (cc); g_free (cc);
if (s) { if (s) {
p = popen (s, "w"); p = popen (s, "w");
mhl_mem_free (s); g_free (s);
} }
if (p) { if (p) {
@ -2672,9 +2673,9 @@ void edit_mail_dialog (WEdit * edit)
Quick_input.widgets = quick_widgets; Quick_input.widgets = quick_widgets;
if (quick_dialog (&Quick_input) != B_CANCEL) { if (quick_dialog (&Quick_input) != B_CANCEL) {
mhl_mem_free (mail_cc_last); g_free (mail_cc_last);
mhl_mem_free (mail_subject_last); g_free (mail_subject_last);
mhl_mem_free (mail_to_last); g_free (mail_to_last);
mail_cc_last = tmail_cc; mail_cc_last = tmail_cc;
mail_subject_last = tmail_subject; mail_subject_last = tmail_subject;
mail_to_last = tmail_to; mail_to_last = tmail_to;
@ -2916,10 +2917,10 @@ edit_complete_word_cmd (WEdit *edit)
} }
} }
mhl_mem_free (match_expr); g_free (match_expr);
/* release memory before return */ /* release memory before return */
for (i = 0; i < num_compl; i++) for (i = 0; i < num_compl; i++)
mhl_mem_free (compl[i].text); g_free (compl[i].text);
/* restore search parameters */ /* restore search parameters */
edit_set_search_parameters (old_rs, old_rb, old_rr, old_rw, old_rc); edit_set_search_parameters (old_rs, old_rb, old_rr, old_rw, old_rc);

View File

@ -34,8 +34,6 @@
#include <errno.h> #include <errno.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <mhl/memory.h>
#include "../src/global.h" #include "../src/global.h"
#include "edit.h" #include "edit.h"
@ -147,7 +145,7 @@ edit_status (WEdit *edit)
printwstr (status, w - (fname_len + gap)); printwstr (status, w - (fname_len + gap));
attrset (EDITOR_NORMAL_COLOR); attrset (EDITOR_NORMAL_COLOR);
mhl_mem_free (status); g_free (status);
} }
/* this scrolls the text so that cursor is on the screen */ /* this scrolls the text so that cursor is on the screen */

View File

@ -22,8 +22,8 @@
*/ */
#include <config.h> #include <config.h>
#include <signal.h> /* kill() */ #include <signal.h> /* kill() */
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h> #include <sys/types.h>
@ -101,7 +101,7 @@ lock_build_symlink_name (const char *fname)
fname_copy = mhl_str_dup (fname); fname_copy = mhl_str_dup (fname);
absolute_fname[fname - absolute_fname] = '\0'; absolute_fname[fname - absolute_fname] = '\0';
symlink_name = g_strconcat (absolute_fname, ".#", fname_copy, (char *) NULL); symlink_name = g_strconcat (absolute_fname, ".#", fname_copy, (char *) NULL);
mhl_mem_free (fname_copy); g_free (fname_copy);
return symlink_name; return symlink_name;
} }
@ -176,7 +176,7 @@ edit_lock_file (const char *fname)
if (lstat (lockfname, &statbuf) == 0) { if (lstat (lockfname, &statbuf) == 0) {
lock = lock_get_info (lockfname); lock = lock_get_info (lockfname);
if (!lock) { if (!lock) {
mhl_mem_free (lockfname); g_free (lockfname);
return 0; return 0;
} }
lockinfo = lock_extract_info (lock); lockinfo = lock_extract_info (lock);
@ -197,11 +197,11 @@ edit_lock_file (const char *fname)
break; break;
case 1: case 1:
case -1: case -1:
mhl_mem_free (lockfname); g_free (lockfname);
mhl_mem_free (msg); g_free (msg);
return 0; return 0;
} }
mhl_mem_free (msg); g_free (msg);
} }
unlink (lockfname); unlink (lockfname);
} }
@ -209,13 +209,13 @@ edit_lock_file (const char *fname)
/* Create lock symlink */ /* Create lock symlink */
newlock = lock_build_name (); newlock = lock_build_name ();
if (symlink (newlock, lockfname) == -1) { if (symlink (newlock, lockfname) == -1) {
mhl_mem_free (lockfname); g_free (lockfname);
mhl_mem_free (newlock); g_free (newlock);
return 0; return 0;
} }
mhl_mem_free (lockfname); g_free (lockfname);
mhl_mem_free (newlock); g_free (newlock);
return 1; return 1;
} }
@ -237,7 +237,7 @@ edit_unlock_file (const char *fname)
/* Check if lock exists */ /* Check if lock exists */
if (lstat (lockfname, &statbuf) == -1) { if (lstat (lockfname, &statbuf) == -1) {
mhl_mem_free (lockfname); g_free (lockfname);
return 0; return 0;
} }
@ -245,13 +245,13 @@ edit_unlock_file (const char *fname)
if (lock) { if (lock) {
/* Don't touch if lock is not ours */ /* Don't touch if lock is not ours */
if (lock_extract_info (lock)->pid != getpid ()) { if (lock_extract_info (lock)->pid != getpid ()) {
mhl_mem_free (lockfname); g_free (lockfname);
return 0; return 0;
} }
} }
/* Remove lock */ /* Remove lock */
unlink (lockfname); unlink (lockfname);
mhl_mem_free (lockfname); g_free (lockfname);
return 0; return 0;
} }

View File

@ -33,9 +33,8 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h>
#include <mhl/memory.h> #include <stdlib.h>
#include "../src/global.h" #include "../src/global.h"
@ -476,7 +475,7 @@ edit_done_menu (struct WMenu *wmenu)
for (i = 0; i < N_menus; i++) for (i = 0; i < N_menus; i++)
destroy_menu (wmenu->menu[i]); destroy_menu (wmenu->menu[i]);
mhl_mem_free(wmenu->menu); g_free(wmenu->menu);
} }

View File

@ -33,9 +33,8 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h>
#include <mhl/memory.h> #include <stdlib.h>
#include "../src/global.h" #include "../src/global.h"
@ -187,13 +186,13 @@ edit_options_dialog (void)
if (p) { if (p) {
option_word_wrap_line_length = atoi (p); option_word_wrap_line_length = atoi (p);
mhl_mem_free (p); g_free (p);
} }
if (q) { if (q) {
option_tab_spacing = atoi (q); option_tab_spacing = atoi (q);
if (option_tab_spacing <= 0) if (option_tab_spacing <= 0)
option_tab_spacing = 8; option_tab_spacing = 8;
mhl_mem_free (q); g_free (q);
} }
option_syntax_highlighting = tedit_syntax_highlighting; option_syntax_highlighting = tedit_syntax_highlighting;

View File

@ -178,7 +178,7 @@ edit_file (const char *_file, int line)
if (!made_directory) { if (!made_directory) {
char *dir = mhl_str_dir_plus_file (home_dir, EDIT_DIR); char *dir = mhl_str_dir_plus_file (home_dir, EDIT_DIR);
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST); made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
mhl_mem_free (dir); g_free (dir);
} }
if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, line))) { if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, line))) {

View File

@ -111,10 +111,10 @@ mc_defines_destroy (gpointer key, gpointer value, gpointer data)
(void) data; (void) data;
mhl_mem_free (key); g_free (key);
while (*values) while (*values)
mhl_mem_free (*values++); g_free (*values++);
mhl_mem_free (value); g_free (value);
return FALSE; return FALSE;
} }
@ -671,14 +671,14 @@ static FILE *open_include_file (const char *filename)
if (*filename == PATH_SEP) if (*filename == PATH_SEP)
return fopen (filename, "r"); return fopen (filename, "r");
mhl_mem_free (error_file_name); g_free (error_file_name);
error_file_name = g_strconcat (home_dir, PATH_SEP_STR EDIT_DIR PATH_SEP_STR, error_file_name = g_strconcat (home_dir, PATH_SEP_STR EDIT_DIR PATH_SEP_STR,
filename, (char *) NULL); filename, (char *) NULL);
f = fopen (error_file_name, "r"); f = fopen (error_file_name, "r");
if (f) if (f)
return f; return f;
mhl_mem_free (error_file_name); g_free (error_file_name);
error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR, error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR,
filename, (char *) NULL); filename, (char *) NULL);
return fopen (error_file_name, "r"); return fopen (error_file_name, "r");
@ -958,7 +958,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size)
c->keyword_first_chars = mhl_str_dup (first_chars); c->keyword_first_chars = mhl_str_dup (first_chars);
} }
mhl_mem_free (first_chars); g_free (first_chars);
} }
return result; return result;
@ -1028,7 +1028,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
if (!f){ if (!f){
lib_file = mhl_str_dir_plus_file (mc_home, "syntax" PATH_SEP_STR "Syntax"); lib_file = mhl_str_dir_plus_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
f = fopen (lib_file, "r"); f = fopen (lib_file, "r");
mhl_mem_free (lib_file); g_free (lib_file);
if (!f) if (!f)
return -1; return -1;
} }
@ -1204,5 +1204,5 @@ edit_load_syntax (WEdit *edit, char ***pnames, const char *type)
} else { } else {
/* succeeded */ /* succeeded */
} }
mhl_mem_free (f); g_free (f);
} }

View File

@ -244,7 +244,7 @@ cfg_free_maps(config_t *cfg)
cfg->ext_keymap = NULL; cfg->ext_keymap = NULL;
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
mhl_mem_free(cfg->labels[i]); g_free(cfg->labels[i]);
} }
/* Returns an array containing the words in str. WARNING: As long as /* Returns an array containing the words in str. WARNING: As long as
@ -556,7 +556,7 @@ parse_file(config_t *cfg, const char *file, const command_t *cmd)
char *ss = mhl_str_dup(error_msg); char *ss = mhl_str_dup(error_msg);
snprintf(error_msg, sizeof(error_msg), snprintf(error_msg, sizeof(error_msg),
_("%s:%d: %s"), file, line, ss); _("%s:%d: %s"), file, line, ss);
mhl_mem_free(ss); g_free(ss);
g_ptr_array_free(args, TRUE); g_ptr_array_free(args, TRUE);
fclose(fp); fclose(fp);
return false; return false;
@ -604,8 +604,8 @@ edit_load_user_map(WEdit *edit)
if (stat(file, &s) < 0) { if (stat(file, &s) < 0) {
char *msg = g_strdup_printf(_("%s not found!"), file); char *msg = g_strdup_printf(_("%s not found!"), file);
edit_error_dialog(_("Error"), msg); edit_error_dialog(_("Error"), msg);
mhl_mem_free(msg); g_free(msg);
mhl_mem_free(file); g_free(file);
return false; return false;
} }
@ -616,7 +616,7 @@ edit_load_user_map(WEdit *edit)
if (!load_user_keymap(&new_cfg, file)) { if (!load_user_keymap(&new_cfg, file)) {
edit_error_dialog(_("Error"), error_msg); edit_error_dialog(_("Error"), error_msg);
cfg_free_maps(&new_cfg); cfg_free_maps(&new_cfg);
mhl_mem_free(file); g_free(file);
return false; return false;
} else { } else {
cfg_free_maps(&cfg); cfg_free_maps(&cfg);
@ -628,7 +628,7 @@ edit_load_user_map(WEdit *edit)
edit->ext_map = (edit_key_map_type *) cfg.ext_keymap->data; edit->ext_map = (edit_key_map_type *) cfg.ext_keymap->data;
memcpy(edit->labels, cfg.labels, sizeof(edit->labels)); memcpy(edit->labels, cfg.labels, sizeof(edit->labels));
mhl_mem_free(file); g_free(file);
return true; return true;
} }

View File

@ -30,9 +30,8 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h>
#include <mhl/memory.h> #include <stdlib.h>
#include "../src/global.h" #include "../src/global.h"
@ -350,13 +349,13 @@ format_paragraph (WEdit *edit, int force)
if (!force) { if (!force) {
int i; int i;
if (strchr (NO_FORMAT_CHARS_START, *t)) { if (strchr (NO_FORMAT_CHARS_START, *t)) {
mhl_mem_free (t); g_free (t);
return; return;
} }
for (i = 0; i < size - 1; i++) { for (i = 0; i < size - 1; i++) {
if (t[i] == '\n') { if (t[i] == '\n') {
if (strchr (NO_FORMAT_CHARS_START "\t ", t[i + 1])) { if (strchr (NO_FORMAT_CHARS_START "\t ", t[i + 1])) {
mhl_mem_free (t); g_free (t);
return; return;
} }
} }
@ -364,7 +363,7 @@ format_paragraph (WEdit *edit, int force)
} }
format_this (t, q - p, indent); format_this (t, q - p, indent);
put_paragraph (edit, t, p, indent, size); put_paragraph (edit, t, p, indent, size);
mhl_mem_free (t); g_free (t);
/* Scroll left as much as possible to show the formatted paragraph */ /* Scroll left as much as possible to show the formatted paragraph */
edit_scroll_left (edit, -edit->start_col); edit_scroll_left (edit, -edit->start_col);

View File

@ -20,7 +20,7 @@ mhl/memory.h: Memory management functions
Allocate sz bytes on stack, zero'ed Allocate sz bytes on stack, zero'ed
* mhl_mem_free(ptr) [INLINE-FUNC] * g_free(ptr) [INLINE-FUNC]
Free chunk @ptr (MUST be allocated w/ mhl_mem_alloc_*()), Free chunk @ptr (MUST be allocated w/ mhl_mem_alloc_*()),
passing NULL is graciously allowed passing NULL is graciously allowed
@ -31,8 +31,8 @@ mhl/memory.h: Memory management functions
* MHL_PTR_FREE(ptr) [MACRO-ONLY] * MHL_PTR_FREE(ptr) [MACRO-ONLY]
like mhl_mem_free(), but with ptr as a variable that gets cleared like g_free(), but with ptr as a variable that gets cleared
(use this as shortcut to "mhl_mem_free(foo); foo = NULL") (use this as shortcut to "g_free(foo); foo = NULL")
mhl/string.h: String helpers mhl/string.h: String helpers
@ -58,7 +58,7 @@ mhl/string.h: String helpers
* mhl_str_concat_1(const char* base, const char* one) -> char* * mhl_str_concat_1(const char* base, const char* one) -> char*
[INLINE-FUNC] Concatenates the string one onto the string base and returns the [INLINE-FUNC] Concatenates the string one onto the string base and returns the
result in a newly allocated buffer (free it w/ mhl_mem_free()). result in a newly allocated buffer (free it w/ g_free()).
For NULL strings, "" is assumed. For NULL strings, "" is assumed.
* mhl_str_concat_2(const char* base,const char* one,const char* two) -> char* * mhl_str_concat_2(const char* base,const char* one,const char* two) -> char*

View File

@ -11,13 +11,13 @@
#define mhl_mem_alloc_z(sz) (calloc(1,sz)) #define mhl_mem_alloc_z(sz) (calloc(1,sz))
/* free a chunk of memory from stack, passing NULL does no harm */ /* free a chunk of memory from stack, passing NULL does no harm */
static inline void mhl_mem_free(void* ptr) static inline void g_free(void* ptr)
{ {
if (ptr) free(ptr); if (ptr) free(ptr);
} }
/* free an ptr and NULL it */ /* free an ptr and NULL it */
#define MHL_PTR_FREE(ptr) do { mhl_mem_free(ptr); (ptr) = NULL; } while (0) #define MHL_PTR_FREE(ptr) do { g_free(ptr); (ptr) = NULL; } while (0)
/* allocate a chunk on stack - automatically free'd on function exit */ /* allocate a chunk on stack - automatically free'd on function exit */
#define mhl_stack_alloc(sz) (alloca(sz)) #define mhl_stack_alloc(sz) (alloca(sz))

View File

@ -6,7 +6,7 @@
static void __mhl_strhash_free_key(void* ptr) static void __mhl_strhash_free_key(void* ptr)
{ {
mhl_mem_free(ptr); g_free(ptr);
} }
static void __mhl_strhash_free_dummy(void* ptr) static void __mhl_strhash_free_dummy(void* ptr)

View File

@ -22,12 +22,11 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <mhl/memory.h>
#include "global.h" #include "global.h"
#include "tty.h" #include "tty.h"
#include "win.h" #include "win.h"
@ -597,7 +596,7 @@ init_chown_advanced (void)
static void static void
chown_advanced_done (void) chown_advanced_done (void)
{ {
mhl_mem_free (sf_stat); g_free (sf_stat);
if (need_update) if (need_update)
update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen (); repaint_screen ();

View File

@ -31,12 +31,11 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <mhl/memory.h>
#include "global.h" #include "global.h"
#include "background.h" #include "background.h"
#include "tty.h" /* doupdate() */ #include "tty.h" /* doupdate() */
@ -90,8 +89,8 @@ unregister_task_running (pid_t pid, int fd)
prev->next = p->next; prev->next = p->next;
else else
task_list = p->next; task_list = p->next;
mhl_mem_free (p->info); g_free (p->info);
mhl_mem_free (p); g_free (p);
break; break;
} }
prev = p; prev = p;
@ -322,7 +321,7 @@ background_attention (int fd, void *closure)
write (fd, &len, sizeof (len)); write (fd, &len, sizeof (len));
if (len){ if (len){
write (fd, resstr, len); write (fd, resstr, len);
mhl_mem_free (resstr); g_free (resstr);
} }
} else { } else {
len = 0; len = 0;
@ -330,7 +329,7 @@ background_attention (int fd, void *closure)
} }
} }
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
mhl_mem_free (data [i]); g_free (data [i]);
do_refresh (); do_refresh ();
mc_refresh (); mc_refresh ();

View File

@ -235,11 +235,11 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n
panel->user_status_format[i] = mhl_str_dup (DEFAULT_USER_FORMAT); panel->user_status_format[i] = mhl_str_dup (DEFAULT_USER_FORMAT);
section = g_strconcat ("Temporal:", p, (char *) NULL); section = g_strconcat ("Temporal:", p, (char *) NULL);
if (!profile_has_section (section, profile_name)) { if (!profile_has_section (section, profile_name)) {
mhl_mem_free (section); g_free (section);
section = mhl_str_dup (p); section = mhl_str_dup (p);
} }
panel_load_setup (panel, section); panel_load_setup (panel, section);
mhl_mem_free (section); g_free (section);
} }
current_mode = panel->list_type; current_mode = panel->list_type;
@ -251,10 +251,10 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n
result = -1; result = -1;
if (section) { if (section) {
mhl_mem_free (panel->user_format); g_free (panel->user_format);
for (i = 0; i < LIST_TYPES; i++) for (i = 0; i < LIST_TYPES; i++)
mhl_mem_free (panel->user_status_format [i]); g_free (panel->user_status_format [i]);
mhl_mem_free (panel); g_free (panel);
} }
if (dd->ret_value != B_CANCEL){ if (dd->ret_value != B_CANCEL){
@ -784,19 +784,19 @@ configure_vfs (void)
if (quick_dialog (&confvfs_dlg) != B_CANCEL) { if (quick_dialog (&confvfs_dlg) != B_CANCEL) {
vfs_timeout = atoi (ret_timeout); vfs_timeout = atoi (ret_timeout);
mhl_mem_free (ret_timeout); g_free (ret_timeout);
if (vfs_timeout < 0 || vfs_timeout > 10000) if (vfs_timeout < 0 || vfs_timeout > 10000)
vfs_timeout = 10; vfs_timeout = 10;
#if defined(USE_NETCODE) #if defined(USE_NETCODE)
mhl_mem_free (ftpfs_anonymous_passwd); g_free (ftpfs_anonymous_passwd);
ftpfs_anonymous_passwd = ret_passwd; ftpfs_anonymous_passwd = ret_passwd;
mhl_mem_free (ftpfs_proxy_host); g_free (ftpfs_proxy_host);
ftpfs_proxy_host = ret_ftp_proxy; ftpfs_proxy_host = ret_ftp_proxy;
ftpfs_directory_timeout = atoi(ret_directory_timeout); ftpfs_directory_timeout = atoi(ret_directory_timeout);
use_netrc = ret_use_netrc; use_netrc = ret_use_netrc;
ftpfs_use_passive_connections = ret_ftpfs_use_passive_connections; ftpfs_use_passive_connections = ret_ftpfs_use_passive_connections;
ftpfs_use_passive_connections_over_proxy = ret_ftpfs_use_passive_connections_over_proxy; ftpfs_use_passive_connections_over_proxy = ret_ftpfs_use_passive_connections_over_proxy;
mhl_mem_free (ret_directory_timeout); g_free (ret_directory_timeout);
#endif #endif
} }
} }
@ -907,7 +907,7 @@ jobs_fill_listbox (void)
s = g_strconcat (state_str [tl->state], " ", tl->info, (char *) NULL); s = g_strconcat (state_str [tl->state], " ", tl->info, (char *) NULL);
listbox_add_item (bg_list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl); listbox_add_item (bg_list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl);
mhl_mem_free (s); g_free (s);
tl = tl->next; tl = tl->next;
} }
} }
@ -1085,7 +1085,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL, auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL,
"[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE); "[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE);
mhl_mem_free (title); g_free (title);
in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT); in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT);
add_widget (auth_dlg, in_user); add_widget (auth_dlg, in_user);

View File

@ -53,10 +53,10 @@ load_codepages_list (void)
fname = mhl_str_dir_plus_file (mc_home, CHARSETS_INDEX); fname = mhl_str_dir_plus_file (mc_home, CHARSETS_INDEX);
if (!(f = fopen (fname, "r"))) { if (!(f = fopen (fname, "r"))) {
fprintf (stderr, _("Warning: file %s not found\n"), fname); fprintf (stderr, _("Warning: file %s not found\n"), fname);
mhl_mem_free (fname); g_free (fname);
return -1; return -1;
} }
mhl_mem_free (fname); g_free (fname);
for (n_codepages = 0; fgets (buf, sizeof (buf), f);) for (n_codepages = 0; fgets (buf, sizeof (buf), f);)
if (buf[0] != '\n' && buf[0] != '\0' && buf[0] != '#') if (buf[0] != '\n' && buf[0] != '\0' && buf[0] != '#')
@ -99,7 +99,7 @@ load_codepages_list (void)
if (default_codepage) { if (default_codepage) {
display_codepage = get_codepage_index (default_codepage); display_codepage = get_codepage_index (default_codepage);
mhl_mem_free (default_codepage); g_free (default_codepage);
} }
result = n_codepages; result = n_codepages;
@ -114,11 +114,11 @@ free_codepages_list (void)
if (n_codepages > 0) { if (n_codepages > 0) {
int i; int i;
for (i = 0; i < n_codepages; i++) { for (i = 0; i < n_codepages; i++) {
mhl_mem_free (codepages[i].id); g_free (codepages[i].id);
mhl_mem_free (codepages[i].name); g_free (codepages[i].name);
} }
n_codepages = 0; n_codepages = 0;
mhl_mem_free (codepages); g_free (codepages);
codepages = 0; codepages = 0;
} }
} }

View File

@ -23,6 +23,7 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
@ -241,7 +242,7 @@ view_file_cmd (void)
return; return;
view_file (filename, 0, use_internal_view); view_file (filename, 0, use_internal_view);
mhl_mem_free (filename); g_free (filename);
} }
/* Run plain internal viewer on the currently selected file */ /* Run plain internal viewer on the currently selected file */
@ -266,7 +267,7 @@ filtered_view_cmd (void)
mc_internal_viewer (command, "", NULL, 0); mc_internal_viewer (command, "", NULL, 0);
mhl_mem_free (command); g_free (command);
} }
void do_edit_at_line (const char *what, int start_line) void do_edit_at_line (const char *what, int start_line)
@ -384,8 +385,8 @@ mkdir_cmd (void)
message (D_ERROR, MSG_ERROR, " %s ", unix_error_string (errno)); message (D_ERROR, MSG_ERROR, " %s ", unix_error_string (errno));
} }
mhl_mem_free (absdir); g_free (absdir);
mhl_mem_free (dir); g_free (dir);
} }
void delete_cmd (void) void delete_cmd (void)
@ -417,13 +418,13 @@ void find_cmd (void)
static void static void
set_panel_filter_to (WPanel *p, char *allocated_filter_string) set_panel_filter_to (WPanel *p, char *allocated_filter_string)
{ {
mhl_mem_free (p->filter); g_free (p->filter);
p->filter = 0; p->filter = 0;
if (!(allocated_filter_string [0] == '*' && allocated_filter_string [1] == 0)) if (!(allocated_filter_string [0] == '*' && allocated_filter_string [1] == 0))
p->filter = allocated_filter_string; p->filter = allocated_filter_string;
else else
mhl_mem_free (allocated_filter_string); g_free (allocated_filter_string);
reread_cmd (); reread_cmd ();
} }
@ -495,7 +496,7 @@ select_unselect_cmd (const char *title, const char *history_name, int cmd)
if (!reg_exp) if (!reg_exp)
return; return;
if (!*reg_exp) { if (!*reg_exp) {
mhl_mem_free (reg_exp); g_free (reg_exp);
return; return;
} }
@ -525,14 +526,14 @@ select_unselect_cmd (const char *title, const char *history_name, int cmd)
match_file); match_file);
if (c == -1) { if (c == -1) {
message (D_ERROR, MSG_ERROR, _(" Malformed regular expression ")); message (D_ERROR, MSG_ERROR, _(" Malformed regular expression "));
mhl_mem_free (reg_exp); g_free (reg_exp);
return; return;
} }
if (c) { if (c) {
do_file_mark (current_panel, i, cmd); do_file_mark (current_panel, i, cmd);
} }
} }
mhl_mem_free (reg_exp); g_free (reg_exp);
} }
void select_cmd (void) void select_cmd (void)
@ -585,11 +586,11 @@ void ext_cmd (void)
buffer = mhl_str_dir_plus_file (home_dir, MC_USER_EXT); buffer = mhl_str_dir_plus_file (home_dir, MC_USER_EXT);
check_for_default (extdir, buffer); check_for_default (extdir, buffer);
do_edit (buffer); do_edit (buffer);
mhl_mem_free (buffer); g_free (buffer);
} else if (dir == 1) } else if (dir == 1)
do_edit (extdir); do_edit (extdir);
mhl_mem_free (extdir); g_free (extdir);
flush_extension_file (); flush_extension_file ();
} }
@ -627,14 +628,14 @@ menu_edit_cmd (int where)
break; break;
default: default:
mhl_mem_free (menufile); g_free (menufile);
return; return;
} }
do_edit (buffer); do_edit (buffer);
if (dir == 0) if (dir == 0)
chmod(buffer, 0600); chmod(buffer, 0600);
mhl_mem_free (buffer); g_free (buffer);
mhl_mem_free (menufile); g_free (menufile);
} }
void quick_chdir_cmd (void) void quick_chdir_cmd (void)
@ -650,7 +651,7 @@ void quick_chdir_cmd (void)
else else
if (!do_cd (target, cd_exact)) if (!do_cd (target, cd_exact))
message (D_ERROR, MSG_ERROR, _("Cannot change directory") ); message (D_ERROR, MSG_ERROR, _("Cannot change directory") );
mhl_mem_free (target); g_free (target);
} }
/* edit file menu for mc */ /* edit file menu for mc */
@ -688,11 +689,11 @@ edit_syntax_cmd (void)
buffer = mhl_str_dir_plus_file (home_dir, SYNTAX_FILE); buffer = mhl_str_dir_plus_file (home_dir, SYNTAX_FILE);
check_for_default (extdir, buffer); check_for_default (extdir, buffer);
do_edit (buffer); do_edit (buffer);
mhl_mem_free (buffer); g_free (buffer);
} else if (dir == 1) } else if (dir == 1)
do_edit (extdir); do_edit (extdir);
mhl_mem_free (extdir); g_free (extdir);
} }
#endif #endif
@ -707,7 +708,7 @@ void reselect_vfs (void)
if (!do_cd (target, cd_exact)) if (!do_cd (target, cd_exact))
message (D_ERROR, MSG_ERROR, _("Cannot change directory") ); message (D_ERROR, MSG_ERROR, _("Cannot change directory") );
mhl_mem_free (target); g_free (target);
} }
#endif /* USE_VFS */ #endif /* USE_VFS */
@ -820,8 +821,8 @@ compare_dir (WPanel *panel, WPanel *other, enum CompareMode mode)
dst_name = mhl_str_dir_plus_file (other->cwd, target->fname); dst_name = mhl_str_dir_plus_file (other->cwd, target->fname);
if (compare_files (src_name, dst_name, source->st.st_size)) if (compare_files (src_name, dst_name, source->st.st_size))
do_file_mark (panel, i, 1); do_file_mark (panel, i, 1);
mhl_mem_free (src_name); g_free (src_name);
mhl_mem_free (dst_name); g_free (dst_name);
} }
} /* for (i ...) */ } /* for (i ...) */
} }
@ -880,7 +881,7 @@ history_cmd (void)
else else
current = listbox->list->current->data; current = listbox->list->current->data;
destroy_dlg (listbox->dlg); destroy_dlg (listbox->dlg);
mhl_mem_free (listbox); g_free (listbox);
if (!current) if (!current)
return; return;
@ -940,8 +941,8 @@ do_link (int symbolic_link, const char *fname)
} }
symlink_dialog (s, d, &dest, &src); symlink_dialog (s, d, &dest, &src);
mhl_mem_free (d); g_free (d);
mhl_mem_free (s); g_free (s);
if (!dest || !*dest || !src || !*src) if (!dest || !*dest || !src || !*src)
goto cleanup; goto cleanup;
@ -954,8 +955,8 @@ do_link (int symbolic_link, const char *fname)
repaint_screen (); repaint_screen ();
cleanup: cleanup:
mhl_mem_free (src); g_free (src);
mhl_mem_free (dest); g_free (dest);
} }
void link_cmd (void) void link_cmd (void)
@ -1003,10 +1004,10 @@ void edit_symlink_cmd (void)
update_panels (UP_OPTIMIZE, UP_KEEPSEL); update_panels (UP_OPTIMIZE, UP_KEEPSEL);
repaint_screen (); repaint_screen ();
} }
mhl_mem_free (dest); g_free (dest);
} }
} }
mhl_mem_free (q); g_free (q);
} else { } else {
message (D_ERROR, MSG_ERROR, _("`%s' is not a symbolic link"), message (D_ERROR, MSG_ERROR, _("`%s' is not a symbolic link"),
selection (current_panel)->fname); selection (current_panel)->fname);
@ -1025,7 +1026,7 @@ user_file_menu_cmd (void)
} }
/* partly taken from dcigettext.c, returns "" for default locale */ /* partly taken from dcigettext.c, returns "" for default locale */
/* value should be freed by calling function mhl_mem_free() */ /* value should be freed by calling function g_free() */
char *guess_message_value (void) char *guess_message_value (void)
{ {
static const char * const var[] = { static const char * const var[] = {
@ -1095,7 +1096,7 @@ get_random_hint (int force)
if (eol) if (eol)
*eol = 0; *eol = 0;
result = mhl_str_dup (&data[start]); result = mhl_str_dup (&data[start]);
mhl_mem_free (data); g_free (data);
return result; return result;
} }
@ -1126,8 +1127,8 @@ nice_cd (const char *text, const char *xtext, const char *help,
directory_history_add (MENU_PANEL, (MENU_PANEL)->cwd); directory_history_add (MENU_PANEL, (MENU_PANEL)->cwd);
else else
message (D_ERROR, MSG_ERROR, _(" Cannot chdir to %s "), cd_path); message (D_ERROR, MSG_ERROR, _(" Cannot chdir to %s "), cd_path);
mhl_mem_free (cd_path); g_free (cd_path);
mhl_mem_free (machine); g_free (machine);
} }
#endif /* USE_NETCODE || USE_EXT2FSLIB */ #endif /* USE_NETCODE || USE_EXT2FSLIB */
@ -1187,9 +1188,9 @@ void quick_cd_cmd (void)
char *q = g_strconcat ("cd ", p, (char *) NULL); char *q = g_strconcat ("cd ", p, (char *) NULL);
do_cd_command (q); do_cd_command (q);
mhl_mem_free (q); g_free (q);
} }
mhl_mem_free (p); g_free (p);
} }
void void
@ -1255,17 +1256,17 @@ configure_panel_listing (WPanel *p, int view_type, int use_msformat, char *user,
p->list_type = view_type; p->list_type = view_type;
if (view_type == list_user || use_msformat){ if (view_type == list_user || use_msformat){
mhl_mem_free (p->user_format); g_free (p->user_format);
p->user_format = user; p->user_format = user;
mhl_mem_free (p->user_status_format [view_type]); g_free (p->user_status_format [view_type]);
p->user_status_format [view_type] = status; p->user_status_format [view_type] = status;
set_panel_formats (p); set_panel_formats (p);
} }
else { else {
mhl_mem_free (user); g_free (user);
mhl_mem_free (status); g_free (status);
} }
set_panel_formats (p); set_panel_formats (p);

View File

@ -255,7 +255,7 @@ static void configure_colors_string (const char *the_color_string)
color_string++; color_string++;
} }
} }
mhl_mem_free (p); g_free (p);
} }
static void configure_colors (void) static void configure_colors (void)
@ -467,9 +467,9 @@ done_colors (void)
for (p = c.next; p; p = next) { for (p = c.next; p; p = next) {
next = p->next; next = p->next;
mhl_mem_free (p->fg); g_free (p->fg);
mhl_mem_free (p->bg); g_free (p->bg);
mhl_mem_free (p); g_free (p);
} }
c.next = NULL; c.next = NULL;
} }

View File

@ -130,15 +130,15 @@ examine_cd (char *path)
if (*p) { if (*p) {
r = mhl_str_dir_plus_file (p, q); r = mhl_str_dir_plus_file (p, q);
result = do_cd (r, cd_parse_command); result = do_cd (r, cd_parse_command);
mhl_mem_free (r); g_free (r);
} }
*s = c; *s = c;
p = s + 1; p = s + 1;
} }
mhl_mem_free (cdpath); g_free (cdpath);
} }
mhl_mem_free (q); g_free (q);
mhl_mem_free (path_tilde); g_free (path_tilde);
return result; return result;
} }
@ -182,14 +182,14 @@ void do_cd_command (char *cmd)
char *new; char *new;
new = mhl_str_dir_plus_file (old, cmd+3); new = mhl_str_dir_plus_file (old, cmd+3);
sync_tree (new); sync_tree (new);
mhl_mem_free (new); g_free (new);
} }
} else } else
if (!examine_cd (&cmd [3])) { if (!examine_cd (&cmd [3])) {
char *d = strip_password (mhl_str_dup (&cmd [3]), 1); char *d = strip_password (mhl_str_dup (&cmd [3]), 1);
message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "), message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "),
d, unix_error_string (errno)); d, unix_error_string (errno));
mhl_mem_free (d); g_free (d);
return; return;
} }
} }
@ -243,7 +243,7 @@ enter (WInput *cmdline)
s = expand_format (NULL, cmd[i], 1); s = expand_format (NULL, cmd[i], 1);
command = g_realloc (command, j + strlen (s) + cmd_len - i + 1); command = g_realloc (command, j + strlen (s) + cmd_len - i + 1);
strcpy (command + j, s); strcpy (command + j, s);
mhl_mem_free (s); g_free (s);
j = strlen (command); j = strlen (command);
} else { } else {
command[j] = cmd[i]; command[j] = cmd[i];
@ -253,7 +253,7 @@ enter (WInput *cmdline)
} }
new_input (cmdline); new_input (cmdline);
shell_execute (command, 0); shell_execute (command, 0);
mhl_mem_free (command); g_free (command);
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef HAVE_SUBSHELL_SUPPORT
if (quit & SUBSHELL_EXIT) { if (quit & SUBSHELL_EXIT) {
@ -315,6 +315,6 @@ command_insert (WInput * in, const char *text, int insert_extra_space)
quoted_text = name_quote (text, 1); quoted_text = name_quote (text, 1);
stuff (in, quoted_text, insert_extra_space); stuff (in, quoted_text, insert_extra_space);
mhl_mem_free (quoted_text); g_free (quoted_text);
} }

View File

@ -92,9 +92,9 @@ filename_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
if (!state){ if (!state){
const char *temp; const char *temp;
mhl_mem_free (dirname); g_free (dirname);
mhl_mem_free (filename); g_free (filename);
mhl_mem_free (users_dirname); g_free (users_dirname);
if ((*text) && (temp = strrchr (text, PATH_SEP))){ if ((*text) && (temp = strrchr (text, PATH_SEP))){
filename = mhl_str_dup (++temp); filename = mhl_str_dup (++temp);
@ -159,7 +159,7 @@ filename_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
isexec = 1; isexec = 1;
} }
} }
mhl_mem_free (tmp); g_free (tmp);
} }
if ((flags & INPUT_COMPLETE_COMMANDS) if ((flags & INPUT_COMPLETE_COMMANDS)
&& (isexec || isdir)) && (isexec || isdir))
@ -177,11 +177,11 @@ filename_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
mc_closedir (directory); mc_closedir (directory);
directory = NULL; directory = NULL;
} }
mhl_mem_free (dirname); g_free (dirname);
dirname = NULL; dirname = NULL;
mhl_mem_free (filename); g_free (filename);
filename = NULL; filename = NULL;
mhl_mem_free (users_dirname); g_free (users_dirname);
users_dirname = NULL; users_dirname = NULL;
return NULL; return NULL;
} else { } else {
@ -207,7 +207,7 @@ filename_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
if (temp && (flags & INPUT_COMPLETE_SHELL_ESC)) if (temp && (flags & INPUT_COMPLETE_SHELL_ESC))
{ {
SHELL_ESCAPED_STR e_temp = mhl_shell_escape_dup(temp); SHELL_ESCAPED_STR e_temp = mhl_shell_escape_dup(temp);
mhl_mem_free (temp); g_free (temp);
temp = e_temp.s; temp = e_temp.s;
} }
return temp; return temp;
@ -368,7 +368,7 @@ static void fetch_hosts (const char *filename)
*(hosts_p++) = name; *(hosts_p++) = name;
*hosts_p = NULL; *hosts_p = NULL;
} else } else
mhl_mem_free (name); g_free (name);
} }
} }
} }
@ -388,8 +388,8 @@ hostname_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
if (hosts != NULL){ if (hosts != NULL){
for (host_p = hosts; *host_p; host_p++) for (host_p = hosts; *host_p; host_p++)
mhl_mem_free (*host_p); g_free (*host_p);
mhl_mem_free (hosts); g_free (hosts);
} }
hosts = g_new (char *, (hosts_alloclen = 30) + 1); hosts = g_new (char *, (hosts_alloclen = 30) + 1);
*hosts = NULL; *hosts = NULL;
@ -410,8 +410,8 @@ hostname_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
if (!*host_p){ if (!*host_p){
for (host_p = hosts; *host_p; host_p++) for (host_p = hosts; *host_p; host_p++)
mhl_mem_free (*host_p); g_free (*host_p);
mhl_mem_free (hosts); g_free (hosts);
hosts = NULL; hosts = NULL;
return NULL; return NULL;
} else { } else {
@ -487,7 +487,7 @@ command_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
if (!p) if (!p)
return 0; return 0;
SHELL_ESCAPED_STR e_p = mhl_shell_escape_dup(p); SHELL_ESCAPED_STR e_p = mhl_shell_escape_dup(p);
mhl_mem_free(p); g_free(p);
return e_p.s; return e_p.s;
} }
@ -521,7 +521,7 @@ command_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
break; break;
expanded = tilde_expand (*cur_path ? cur_path : "."); expanded = tilde_expand (*cur_path ? cur_path : ".");
cur_word = mhl_str_dir_plus_file (expanded, text); cur_word = mhl_str_dir_plus_file (expanded, text);
mhl_mem_free (expanded); g_free (expanded);
canonicalize_pathname (cur_word); canonicalize_pathname (cur_word);
cur_path = strchr (cur_path, 0) + 1; cur_path = strchr (cur_path, 0) + 1;
init_state = state; init_state = state;
@ -530,21 +530,21 @@ command_completion_function (char *text, int state, INPUT_COMPLETE_FLAGS flags)
filename_completion_function (cur_word, filename_completion_function (cur_word,
state - init_state, flags); state - init_state, flags);
if (!found) { if (!found) {
mhl_mem_free (cur_word); g_free (cur_word);
cur_word = NULL; cur_word = NULL;
} }
} }
} }
if (!found) { if (!found) {
mhl_mem_free (path); g_free (path);
path = NULL; path = NULL;
return NULL; return NULL;
} }
if ((p = strrchr (found, PATH_SEP)) != NULL) { if ((p = strrchr (found, PATH_SEP)) != NULL) {
p++; p++;
SHELL_ESCAPED_STR e_p = mhl_shell_escape_dup(p); SHELL_ESCAPED_STR e_p = mhl_shell_escape_dup(p);
mhl_mem_free(found); g_free(found);
return e_p.s; return e_p.s;
} }
return found; return found;
@ -617,7 +617,7 @@ completion_matches (char *text, CompletionFunction entry_function, INPUT_COMPLET
if (c1 != c2) break; if (c1 != c2) break;
if (!c1 && !match_list [j][si]){ /* Two equal strings */ if (!c1 && !match_list [j][si]){ /* Two equal strings */
mhl_mem_free (match_list [j]); g_free (match_list [j]);
j++; j++;
if (j > matches) if (j > matches)
break; break;
@ -633,7 +633,7 @@ completion_matches (char *text, CompletionFunction entry_function, INPUT_COMPLET
match_list[0] = g_strndup(match_list[1], low); match_list[0] = g_strndup(match_list[1], low);
} }
} else { /* There were no matches. */ } else { /* There were no matches. */
mhl_mem_free (match_list); g_free (match_list);
match_list = NULL; match_list = NULL;
} }
return match_list; return match_list;
@ -817,17 +817,17 @@ try_complete (char *text, int *start, int *end, INPUT_COMPLETE_FLAGS flags)
r = mhl_str_dir_plus_file (cdpath, word); r = mhl_str_dir_plus_file (cdpath, word);
SHOW_C_CTX("try_complete:filename_subst_2"); SHOW_C_CTX("try_complete:filename_subst_2");
matches = completion_matches (r, filename_completion_function, flags); matches = completion_matches (r, filename_completion_function, flags);
mhl_mem_free (r); g_free (r);
} }
*s = c; *s = c;
cdpath = s + 1; cdpath = s + 1;
} }
mhl_mem_free (cdpath_ref); g_free (cdpath_ref);
} }
} }
} }
mhl_mem_free (word); g_free (word);
return matches; return matches;
} }
@ -839,8 +839,8 @@ void free_completions (WInput *in)
if (!in->completions) if (!in->completions)
return; return;
for (p=in->completions; *p; p++) for (p=in->completions; *p; p++)
mhl_mem_free (*p); g_free (*p);
mhl_mem_free (in->completions); g_free (in->completions);
in->completions = NULL; in->completions = NULL;
} }

View File

@ -267,7 +267,7 @@ console_shutdown (void)
if (!console_flag) if (!console_flag)
return; return;
mhl_mem_free (screen_shot.buf); g_free (screen_shot.buf);
console_flag = 0; console_flag = 0;
} }

View File

@ -221,7 +221,7 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set,
char *t; char *t;
t = g_strstrip (mhl_str_dup (title)); t = g_strstrip (mhl_str_dup (title));
new_d->title = g_strconcat (" ", t, " ", (char *) NULL); new_d->title = g_strconcat (" ", t, " ", (char *) NULL);
mhl_mem_free (t); g_free (t);
} }
return (new_d); return (new_d);
@ -816,11 +816,11 @@ destroy_dlg (Dlg_head *h)
c = h->current; c = h->current;
for (i = 0; i < h->count; i++) { for (i = 0; i < h->count; i++) {
c = c->next; c = c->next;
mhl_mem_free (h->current); g_free (h->current);
h->current = c; h->current = c;
} }
mhl_mem_free (h->title); g_free (h->title);
mhl_mem_free (h); g_free (h);
do_refresh (); do_refresh ();
} }

View File

@ -256,7 +256,7 @@ clean_dir (dir_list *list, int count)
int i; int i;
for (i = 0; i < count; i++){ for (i = 0; i < count; i++){
mhl_mem_free (list->list [i].fname); g_free (list->list [i].fname);
list->list [i].fname = 0; list->list [i].fname = 0;
} }
} }
@ -473,9 +473,9 @@ alloc_dir_copy (int size)
if (dir_copy.list){ if (dir_copy.list){
for (i = 0; i < dir_copy.size; i++) { for (i = 0; i < dir_copy.size; i++) {
mhl_mem_free (dir_copy.list [i].fname); g_free (dir_copy.list [i].fname);
} }
mhl_mem_free (dir_copy.list); g_free (dir_copy.list);
dir_copy.list = 0; dir_copy.list = 0;
} }

View File

@ -77,12 +77,12 @@ test_locale_en_US_UTF_8(void)
valid = ecs_mbstr_to_str(&ecs, teststr_mb); valid = ecs_mbstr_to_str(&ecs, teststr_mb);
assert(valid); assert(valid);
assert(ecs_strlen(ecs) == 10); assert(ecs_strlen(ecs) == 10);
mhl_mem_free(ecs); g_free(ecs);
valid = ecs_str_to_mbstr(&mbs, teststr_ecs); valid = ecs_str_to_mbstr(&mbs, teststr_ecs);
assert(valid); assert(valid);
assert(strlen(mbs) == 11); assert(strlen(mbs) == 11);
mhl_mem_free(mbs); g_free(mbs);
} }
#endif #endif

View File

@ -48,7 +48,7 @@ extern bool ecs_mbstr_to_str(ecs_char **ret_str, const char *s)
str = g_new(ecs_char, maxlen + 1); str = g_new(ecs_char, maxlen + 1);
len = mbstowcs(str, s, maxlen + 1); len = mbstowcs(str, s, maxlen + 1);
if (len == (size_t) -1) { if (len == (size_t) -1) {
mhl_mem_free(str); g_free(str);
return FALSE; 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); str = g_new(char, maxlen + 1);
len = wcstombs(str, s, maxlen + 1); len = wcstombs(str, s, maxlen + 1);
if (len == (size_t) -1) { if (len == (size_t) -1) {
mhl_mem_free(str); g_free(str);
return FALSE; return FALSE;
} }

View File

@ -49,7 +49,7 @@ typedef char ecs_char;
/* /*
* String conversion functions between the wide character encoding and * String conversion functions between the wide character encoding and
* the multibyte encoding. The returned strings should be freed using * the multibyte encoding. The returned strings should be freed using
* mhl_mem_free after use. The return value is TRUE if the string is valid * g_free after use. The return value is TRUE if the string is valid
* and has been converted, FALSE otherwise. * and has been converted, FALSE otherwise.
*/ */

View File

@ -164,7 +164,7 @@ do_execute (const char *shell, const char *command, int flags)
#ifdef USE_VFS #ifdef USE_VFS
if (old_vfs_dir) { if (old_vfs_dir) {
mc_chdir (old_vfs_dir); mc_chdir (old_vfs_dir);
mhl_mem_free (old_vfs_dir); g_free (old_vfs_dir);
} }
#endif /* USE_VFS */ #endif /* USE_VFS */
@ -198,7 +198,7 @@ shell_execute (const char *command, int flags)
#endif /* HAVE_SUBSHELL_SUPPORT */ #endif /* HAVE_SUBSHELL_SUPPORT */
do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL); do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
mhl_mem_free (cmd); g_free (cmd);
} }
@ -371,6 +371,6 @@ execute_with_vfs_arg (const char *command, const char *filename)
do_execute (command, localcopy, EXECUTE_INTERNAL); do_execute (command, localcopy, EXECUTE_INTERNAL);
mc_stat (localcopy, &st); mc_stat (localcopy, &st);
mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime); mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime);
mhl_mem_free (localcopy); g_free (localcopy);
mhl_mem_free (fn); g_free (fn);
} }

View File

@ -54,7 +54,7 @@ static char *data = NULL;
void void
flush_extension_file (void) flush_extension_file (void)
{ {
mhl_mem_free (data); g_free (data);
data = NULL; data = NULL;
} }
@ -123,14 +123,14 @@ exec_extension (const char *filename, const char *data, int *move_dir,
unlink (file_name); unlink (file_name);
if (localcopy) { if (localcopy) {
mc_ungetlocalcopy (filename, localcopy, 0); mc_ungetlocalcopy (filename, localcopy, 0);
mhl_mem_free (localcopy); g_free (localcopy);
} }
mhl_mem_free (file_name); g_free (file_name);
return; return;
} }
fputs (parameter, cmd_file); fputs (parameter, cmd_file);
written_nonspace = 1; written_nonspace = 1;
mhl_mem_free (parameter); g_free (parameter);
} else { } else {
size_t len = strlen (prompt); size_t len = strlen (prompt);
@ -158,7 +158,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
data += i - 1; data += i - 1;
} else if ((i = check_format_var (data, &v)) > 0 && v) { } else if ((i = check_format_var (data, &v)) > 0 && v) {
fputs (v, cmd_file); fputs (v, cmd_file);
mhl_mem_free (v); g_free (v);
data += i; data += i;
} else { } else {
char *text; char *text;
@ -169,7 +169,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
if (localcopy == NULL) { if (localcopy == NULL) {
fclose (cmd_file); fclose (cmd_file);
unlink (file_name); unlink (file_name);
mhl_mem_free (file_name); g_free (file_name);
return; return;
} }
mc_stat (localcopy, &mystat); mc_stat (localcopy, &mystat);
@ -186,7 +186,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
strcpy (p, text); strcpy (p, text);
p = strchr (p, 0); p = strchr (p, 0);
} }
mhl_mem_free (text); g_free (text);
written_nonspace = 1; written_nonspace = 1;
} }
} }
@ -217,7 +217,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
if ((run_view && !written_nonspace) || is_cd) { if ((run_view && !written_nonspace) || is_cd) {
unlink (file_name); unlink (file_name);
mhl_mem_free (file_name); g_free (file_name);
file_name = NULL; file_name = NULL;
} else { } else {
/* Set executable flag on the command file ... */ /* Set executable flag on the command file ... */
@ -276,14 +276,14 @@ exec_extension (const char *filename, const char *data, int *move_dir,
} }
} }
mhl_mem_free (file_name); g_free (file_name);
mhl_mem_free (cmd); g_free (cmd);
if (localcopy) { if (localcopy) {
mc_stat (localcopy, &mystat); mc_stat (localcopy, &mystat);
mc_ungetlocalcopy (filename, localcopy, mc_ungetlocalcopy (filename, localcopy,
localmtime != mystat.st_mtime); localmtime != mystat.st_mtime);
mhl_mem_free (localcopy); g_free (localcopy);
} }
} }
@ -306,8 +306,8 @@ get_file_type_local (const char *filename, char *buf, int buflen)
char *command = g_strconcat (FILE_CMD, tmp, " 2>/dev/null", (char *) 0); char *command = g_strconcat (FILE_CMD, tmp, " 2>/dev/null", (char *) 0);
FILE *f = popen (command, "r"); FILE *f = popen (command, "r");
mhl_mem_free (tmp); g_free (tmp);
mhl_mem_free (command); g_free (command);
if (f != NULL) { if (f != NULL) {
#ifdef __QNXNTO__ #ifdef __QNXNTO__
if (setvbuf (f, NULL, _IOFBF, 0) != 0) { if (setvbuf (f, NULL, _IOFBF, 0) != 0) {
@ -388,7 +388,7 @@ regex_check_type (const char *filename, const char *ptr, int *have_type)
/* No data */ /* No data */
content_string[0] = 0; content_string[0] = 0;
} }
mhl_mem_free (realname); g_free (realname);
} }
if (got_data == -1) { if (got_data == -1) {
@ -444,20 +444,20 @@ regex_command (const char *filename, const char *action, int *move_dir)
extension_file = mhl_str_dir_plus_file (home_dir, MC_USER_EXT); extension_file = mhl_str_dir_plus_file (home_dir, MC_USER_EXT);
if (!exist_file (extension_file)) { if (!exist_file (extension_file)) {
mhl_mem_free (extension_file); g_free (extension_file);
check_stock_mc_ext: check_stock_mc_ext:
extension_file = mhl_str_dir_plus_file (mc_home, MC_LIB_EXT); extension_file = mhl_str_dir_plus_file (mc_home, MC_LIB_EXT);
mc_user_ext = 0; mc_user_ext = 0;
} }
data = load_file (extension_file); data = load_file (extension_file);
mhl_mem_free (extension_file); g_free (extension_file);
if (data == NULL) if (data == NULL)
return 0; return 0;
if (!strstr (data, "default/")) { if (!strstr (data, "default/")) {
if (!strstr (data, "regex/") && !strstr (data, "shell/") if (!strstr (data, "regex/") && !strstr (data, "shell/")
&& !strstr (data, "type/")) { && !strstr (data, "type/")) {
mhl_mem_free (data); g_free (data);
data = NULL; data = NULL;
if (mc_user_ext) { if (mc_user_ext) {
home_error = 1; home_error = 1;
@ -471,7 +471,7 @@ regex_command (const char *filename, const char *action, int *move_dir)
"the installation failed. Please fetch a fresh " "the installation failed. Please fetch a fresh "
"copy from the Midnight Commander package."), "copy from the Midnight Commander package."),
mc_home); mc_home);
mhl_mem_free (title); g_free (title);
return 0; return 0;
} }
} }
@ -483,7 +483,7 @@ regex_command (const char *filename, const char *action, int *move_dir)
"changed with version 3.0. You may either want to copy " "changed with version 3.0. You may either want to copy "
"it from %smc.ext or use that file as an example of how " "it from %smc.ext or use that file as an example of how "
"to write it."), MC_USER_EXT, mc_home); "to write it."), MC_USER_EXT, mc_home);
mhl_mem_free (title); g_free (title);
} }
} }
mc_stat (filename, &mystat); mc_stat (filename, &mystat);
@ -596,7 +596,7 @@ regex_command (const char *filename, const char *action, int *move_dir)
exec_extension (filename_copy, r + 1, move_dir, exec_extension (filename_copy, r + 1, move_dir,
view_at_line_number); view_at_line_number);
mhl_mem_free (filename_copy); g_free (filename_copy);
ret = 1; ret = 1;
} }

View File

@ -256,7 +256,7 @@ transform_source (FileOpContext *ctx, const char *source)
*q = ' '; *q = ' ';
} }
p = do_transform_source (ctx, s); p = do_transform_source (ctx, s);
mhl_mem_free (s); g_free (s);
return p; return p;
} }
@ -267,7 +267,7 @@ free_linklist (struct link **linklist)
for (lp = *linklist; lp != NULL; lp = lp2) { for (lp = *linklist; lp != NULL; lp = lp2) {
lp2 = lp->next; lp2 = lp->next;
mhl_mem_free (lp); g_free (lp);
} }
*linklist = NULL; *linklist = NULL;
} }
@ -399,17 +399,17 @@ make_symlink (FileOpContext *ctx, const char *src_path, const char *dst_path)
if (s) { if (s) {
s[1] = 0; s[1] = 0;
s = g_strconcat (p, link_target, (char *) NULL); s = g_strconcat (p, link_target, (char *) NULL);
mhl_mem_free (p); g_free (p);
g_strlcpy (link_target, s, sizeof (link_target)); g_strlcpy (link_target, s, sizeof (link_target));
mhl_mem_free (s); g_free (s);
s = diff_two_paths (q, link_target); s = diff_two_paths (q, link_target);
if (s) { if (s) {
g_strlcpy (link_target, s, sizeof (link_target)); g_strlcpy (link_target, s, sizeof (link_target));
mhl_mem_free (s); g_free (s);
} }
} else } else
mhl_mem_free (p); g_free (p);
mhl_mem_free (q); g_free (q);
} }
} }
retry_dst_symlink: 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 */ dst_status = DEST_FULL; /* copy successful, don't remove target file */
ret: ret:
mhl_mem_free (buf); g_free (buf);
while (src_desc != -1 && mc_close (src_desc) < 0) { while (src_desc != -1 && mc_close (src_desc) < 0) {
temp_status = file_error ( 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 (move_over) {
if (mc_rename (s, d) == 0) { if (mc_rename (s, d) == 0) {
mhl_mem_free (parent_dirs); g_free (parent_dirs);
return FILE_CONT; 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); _(" Destination \"%s\" must be a directory \n %s "), d);
if (return_status == FILE_RETRY) if (return_status == FILE_RETRY)
goto retry_dst_stat; goto retry_dst_stat;
mhl_mem_free (parent_dirs); g_free (parent_dirs);
return return_status; return return_status;
} }
/* Dive into subdir if exists */ /* 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, return_status = copy_dir_dir (ctx, path, mdpath, 0, 0, delete,
parent_dirs, progress_count, progress_bytes); parent_dirs, progress_count, progress_bytes);
mhl_mem_free (mdpath); g_free (mdpath);
} else { } else {
dest_file = mhl_str_dir_plus_file (dest_dir, x_basename (path)); dest_file = mhl_str_dir_plus_file (dest_dir, x_basename (path));
return_status = copy_file_file (ctx, path, dest_file, 1, return_status = copy_file_file (ctx, path, dest_file, 1,
progress_count, progress_bytes, 0); progress_count, progress_bytes, 0);
mhl_mem_free (dest_file); g_free (dest_file);
} }
if (delete && return_status == FILE_CONT) { if (delete && return_status == FILE_CONT) {
if (ctx->erase_at_end) { 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); return_status = erase_file (ctx, path, 0, 0, 0);
} }
} }
mhl_mem_free (path); g_free (path);
} }
mc_closedir (reading); mc_closedir (reading);
@ -1019,8 +1019,8 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
} }
ret: ret:
mhl_mem_free (dest_dir); g_free (dest_dir);
mhl_mem_free (parent_dirs); g_free (parent_dirs);
return return_status; return return_status;
} }
@ -1215,7 +1215,7 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
if (return_status == FILE_RETRY) if (return_status == FILE_RETRY)
goto retry_dst_stat; goto retry_dst_stat;
} }
mhl_mem_free (destdir); g_free (destdir);
return return_status; 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); erase_file (ctx, erase_list->name, 0, 0, 0);
lp = erase_list; lp = erase_list;
erase_list = erase_list->next; erase_list = erase_list->next;
mhl_mem_free (lp); g_free (lp);
} }
} }
erase_dir_iff_empty (ctx, s); erase_dir_iff_empty (ctx, s);
ret: ret:
mhl_mem_free (destdir); g_free (destdir);
while (erase_list) { while (erase_list) {
lp = erase_list; lp = erase_list;
erase_list = erase_list->next; erase_list = erase_list->next;
mhl_mem_free (lp); g_free (lp);
} }
return return_status; return return_status;
} }
@ -1332,7 +1332,7 @@ recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count,
continue; continue;
path = mhl_str_dir_plus_file (s, next->d_name); path = mhl_str_dir_plus_file (s, next->d_name);
if (mc_lstat (path, &buf)) { if (mc_lstat (path, &buf)) {
mhl_mem_free (path); g_free (path);
mc_closedir (reading); mc_closedir (reading);
return 1; return 1;
} }
@ -1344,7 +1344,7 @@ recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count,
else else
return_status = return_status =
erase_file (ctx, path, progress_count, progress_bytes, 0); erase_file (ctx, path, progress_count, progress_bytes, 0);
mhl_mem_free (path); g_free (path);
} }
mc_closedir (reading); mc_closedir (reading);
if (return_status != FILE_CONT) 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); res = mc_lstat (fullname, &s);
if (res != 0) { if (res != 0) {
mhl_mem_free (fullname); g_free (fullname);
continue; continue;
} }
@ -1542,7 +1542,7 @@ compute_dir_size (const char *dirname, off_t *ret_marked, double *ret_total)
(*ret_marked)++; (*ret_marked)++;
*ret_total += s.st_size; *ret_total += s.st_size;
} }
mhl_mem_free (fullname); g_free (fullname);
} }
mc_closedir (dir); mc_closedir (dir);
@ -1583,7 +1583,7 @@ panel_compute_totals (WPanel *panel, off_t *ret_marked, double *ret_total)
*ret_marked += subdir_count; *ret_marked += subdir_count;
*ret_total += subdir_bytes; *ret_total += subdir_bytes;
mhl_mem_free (dir_name); g_free (dir_name);
} else { } else {
(*ret_marked)++; (*ret_marked)++;
*ret_total += s->st_size; *ret_total += s->st_size;
@ -1821,7 +1821,7 @@ panel_operate (void *source_panel, FileOperation operation,
dest = dest =
file_mask_dialog (ctx, operation, cmd_buf, dest_dir_, file_mask_dialog (ctx, operation, cmd_buf, dest_dir_,
single_entry, &do_bg); single_entry, &do_bg);
mhl_mem_free(dest_dir_); g_free(dest_dir_);
if (!dest) { if (!dest) {
file_op_context_destroy (ctx); file_op_context_destroy (ctx);
@ -1829,7 +1829,7 @@ panel_operate (void *source_panel, FileOperation operation,
} }
if (!*dest) { if (!*dest) {
file_op_context_destroy (ctx); file_op_context_destroy (ctx);
mhl_mem_free (dest); g_free (dest);
return 0; return 0;
} }
} }
@ -1902,7 +1902,7 @@ panel_operate (void *source_panel, FileOperation operation,
value = transform_error; value = transform_error;
} else { } else {
char *temp2 = mhl_str_dir_plus_file (dest, temp); char *temp2 = mhl_str_dir_plus_file (dest, temp);
mhl_mem_free (dest); g_free (dest);
dest = temp2; dest = temp2;
temp = NULL; temp = NULL;
@ -1978,7 +1978,7 @@ panel_operate (void *source_panel, FileOperation operation,
src_stat = panel->dir.list[i].st; src_stat = panel->dir.list[i].st;
#ifdef WITH_FULL_PATHS #ifdef WITH_FULL_PATHS
mhl_mem_free (source_with_path); g_free (source_with_path);
source_with_path = mhl_str_dir_plus_file (panel->cwd, source); source_with_path = mhl_str_dir_plus_file (panel->cwd, source);
#endif /* WITH_FULL_PATHS */ #endif /* WITH_FULL_PATHS */
@ -2033,7 +2033,7 @@ panel_operate (void *source_panel, FileOperation operation,
/* Unknown file operation */ /* Unknown file operation */
abort (); abort ();
} }
mhl_mem_free (temp2); g_free (temp2);
} }
} /* Copy or move operation */ } /* Copy or move operation */
@ -2065,20 +2065,20 @@ panel_operate (void *source_panel, FileOperation operation,
if (save_cwd) { if (save_cwd) {
mc_setctl (save_cwd, VFS_SETCTL_STALE_DATA, NULL); mc_setctl (save_cwd, VFS_SETCTL_STALE_DATA, NULL);
mhl_mem_free (save_cwd); g_free (save_cwd);
} }
if (save_dest) { if (save_dest) {
mc_setctl (save_dest, VFS_SETCTL_STALE_DATA, NULL); mc_setctl (save_dest, VFS_SETCTL_STALE_DATA, NULL);
mhl_mem_free (save_dest); g_free (save_dest);
} }
free_linklist (&linklist); free_linklist (&linklist);
free_linklist (&dest_dirs); free_linklist (&dest_dirs);
#ifdef WITH_FULL_PATHS #ifdef WITH_FULL_PATHS
mhl_mem_free (source_with_path); g_free (source_with_path);
#endif /* WITH_FULL_PATHS */ #endif /* WITH_FULL_PATHS */
mhl_mem_free (dest); g_free (dest);
mhl_mem_free (ctx->dest_mask); g_free (ctx->dest_mask);
ctx->dest_mask = NULL; ctx->dest_mask = NULL;
#ifdef WITH_BACKGROUND #ifdef WITH_BACKGROUND
/* Let our parent know we are saying bye bye */ /* 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) if (ctx->recursive_result != RECURSIVE_ABORT)
do_refresh (); do_refresh ();
mhl_mem_free (text); g_free (text);
} }
switch (ctx->recursive_result) { switch (ctx->recursive_result) {

View File

@ -258,7 +258,7 @@ file_op_context_destroy_ui (FileOpContext *ctx)
dlg_run_done (ui->op_dlg); dlg_run_done (ui->op_dlg);
destroy_dlg (ui->op_dlg); destroy_dlg (ui->op_dlg);
mhl_mem_free (ui); g_free (ui);
} }
the_hint->widget.y = last_hint_line; the_hint->widget.y = last_hint_line;
@ -906,10 +906,10 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
ask_file_mask: ask_file_mask:
if ((val = quick_dialog_skip (&Quick_input, SKIP)) == B_CANCEL) { if ((val = quick_dialog_skip (&Quick_input, SKIP)) == B_CANCEL) {
mhl_mem_free (def_text_secure); g_free (def_text_secure);
return 0; return 0;
} }
mhl_mem_free (def_text_secure); g_free (def_text_secure);
if (ctx->follow_links) if (ctx->follow_links)
ctx->stat_func = mc_stat; ctx->stat_func = mc_stat;
@ -930,7 +930,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
orig_mask = source_mask; orig_mask = source_mask;
if (!dest_dir || !*dest_dir) { if (!dest_dir || !*dest_dir) {
mhl_mem_free (source_mask); g_free (source_mask);
return dest_dir; return dest_dir;
} }
if (source_easy_patterns) { if (source_easy_patterns) {
@ -941,7 +941,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
error = error =
re_compile_pattern (source_mask, strlen (source_mask), re_compile_pattern (source_mask, strlen (source_mask),
&ctx->rx); &ctx->rx);
mhl_mem_free (source_mask); g_free (source_mask);
} else } else
error = error =
re_compile_pattern (source_mask, strlen (source_mask), re_compile_pattern (source_mask, strlen (source_mask),
@ -950,14 +950,14 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
if (error) { if (error) {
message (D_ERROR, MSG_ERROR, _("Invalid source pattern `%s' \n %s "), message (D_ERROR, MSG_ERROR, _("Invalid source pattern `%s' \n %s "),
orig_mask, error); orig_mask, error);
mhl_mem_free (orig_mask); g_free (orig_mask);
goto ask_file_mask; goto ask_file_mask;
} }
mhl_mem_free (orig_mask); g_free (orig_mask);
tmpdest = dest_dir; tmpdest = dest_dir;
dest_dir = tilde_expand(tmpdest); dest_dir = tilde_expand(tmpdest);
mhl_mem_free(tmpdest); g_free(tmpdest);
ctx->dest_mask = strrchr (dest_dir, PATH_SEP); ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
if (ctx->dest_mask == NULL) if (ctx->dest_mask == NULL)
@ -979,7 +979,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
*orig_mask = 0; *orig_mask = 0;
} }
if (!*dest_dir) { if (!*dest_dir) {
mhl_mem_free (dest_dir); g_free (dest_dir);
dest_dir = mhl_str_dup ("./"); dest_dir = mhl_str_dup ("./");
} }
if (val == B_USER) if (val == B_USER)

View File

@ -65,12 +65,12 @@ my_mkdir_rec (char *s, mode_t mode)
p = mhl_str_dir_plus_file (s, ".."); p = mhl_str_dir_plus_file (s, "..");
q = vfs_canon (p); q = vfs_canon (p);
mhl_mem_free (p); g_free (p);
if (!(result = my_mkdir_rec (q, mode))) if (!(result = my_mkdir_rec (q, mode)))
result = mc_mkdir (s, mode); result = mc_mkdir (s, mode);
mhl_mem_free (q); g_free (q);
return result; return result;
} }
@ -85,7 +85,7 @@ my_mkdir (const char *s, mode_t mode)
char *p = vfs_canon (s); char *p = vfs_canon (s);
result = my_mkdir_rec (p, mode); result = my_mkdir_rec (p, mode);
mhl_mem_free (p); g_free (p);
} }
if (result == 0) { if (result == 0) {
my_s = get_absolute_name (s); my_s = get_absolute_name (s);
@ -94,7 +94,7 @@ my_mkdir (const char *s, mode_t mode)
tree_add_entry (tree, my_s); tree_add_entry (tree, my_s);
#endif #endif
mhl_mem_free (my_s); g_free (my_s);
} }
return result; return result;
} }
@ -117,7 +117,7 @@ my_rmdir (const char *s)
tree_remove_entry (tree, my_s); tree_remove_entry (tree, my_s);
#endif #endif
mhl_mem_free (my_s); g_free (my_s);
} }
return result; return result;
} }

View File

@ -25,8 +25,6 @@
#include <unistd.h> #include <unistd.h>
#include <mhl/memory.h>
#include "global.h" #include "global.h"
#include "fileopctx.h" #include "fileopctx.h"
@ -79,5 +77,5 @@ file_op_context_destroy (FileOpContext *ctx)
/* FIXME: do we need to free ctx->dest_mask? */ /* FIXME: do we need to free ctx->dest_mask? */
mhl_mem_free (ctx); g_free (ctx);
} }

View File

@ -309,14 +309,14 @@ find_parameters (char **start_dir, char **pattern, char **content)
find_regex_flag = find_regex_cbox->state & C_BOOL; find_regex_flag = find_regex_cbox->state & C_BOOL;
find_recursively = recursively_cbox->state & C_BOOL; find_recursively = recursively_cbox->state & C_BOOL;
destroy_dlg (find_dlg); destroy_dlg (find_dlg);
mhl_mem_free (in_start_dir); g_free (in_start_dir);
if (strcmp (temp_dir, ".") == 0) { if (strcmp (temp_dir, ".") == 0) {
mhl_mem_free (temp_dir); g_free (temp_dir);
temp_dir = mhl_str_dup (current_panel->cwd); temp_dir = mhl_str_dup (current_panel->cwd);
} }
in_start_dir = tree_box (temp_dir); in_start_dir = tree_box (temp_dir);
if (in_start_dir) if (in_start_dir)
mhl_mem_free (temp_dir); g_free (temp_dir);
else else
in_start_dir = temp_dir; in_start_dir = temp_dir;
/* Warning: Dreadful goto */ /* Warning: Dreadful goto */
@ -324,7 +324,7 @@ find_parameters (char **start_dir, char **pattern, char **content)
break; break;
default: default:
mhl_mem_free (in_contents); g_free (in_contents);
if (in_with->buffer[0]) { if (in_with->buffer[0]) {
*content = mhl_str_dup (in_with->buffer); *content = mhl_str_dup (in_with->buffer);
in_contents = mhl_str_dup (*content); in_contents = mhl_str_dup (*content);
@ -340,9 +340,9 @@ find_parameters (char **start_dir, char **pattern, char **content)
*start_dir = mhl_str_dup (in_start->buffer); *start_dir = mhl_str_dup (in_start->buffer);
*pattern = mhl_str_dup (in_name->buffer); *pattern = mhl_str_dup (in_name->buffer);
mhl_mem_free (in_start_dir); g_free (in_start_dir);
in_start_dir = mhl_str_dup (*start_dir); in_start_dir = mhl_str_dup (*start_dir);
mhl_mem_free (in_start_name); g_free (in_start_name);
in_start_name = mhl_str_dup (*pattern); in_start_name = mhl_str_dup (*pattern);
} }
@ -371,7 +371,7 @@ pop_directory (void)
if (dir_stack_base){ if (dir_stack_base){
name = dir_stack_base->name; name = dir_stack_base->name;
next = dir_stack_base->prev; next = dir_stack_base->prev;
mhl_mem_free (dir_stack_base); g_free (dir_stack_base);
dir_stack_base = next; dir_stack_base = next;
return name; return name;
} else } else
@ -389,7 +389,7 @@ insert_file (const char *dir, const char *file)
if (old_dir){ if (old_dir){
if (strcmp (old_dir, dir)){ if (strcmp (old_dir, dir)){
mhl_mem_free (old_dir); g_free (old_dir);
old_dir = mhl_str_dup (dir); old_dir = mhl_str_dup (dir);
dirname = add_to_list (dir, NULL); dirname = add_to_list (dir, NULL);
} }
@ -400,7 +400,7 @@ insert_file (const char *dir, const char *file)
tmp_name = g_strconcat (" ", file, (char *) NULL); tmp_name = g_strconcat (" ", file, (char *) NULL);
add_to_list (tmp_name, dirname); add_to_list (tmp_name, dirname);
mhl_mem_free (tmp_name); g_free (tmp_name);
} }
static void static void
@ -522,12 +522,12 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
fname = mhl_str_dir_plus_file (directory, filename); fname = mhl_str_dir_plus_file (directory, filename);
if (mc_stat (fname, &s) != 0 || !S_ISREG (s.st_mode)){ if (mc_stat (fname, &s) != 0 || !S_ISREG (s.st_mode)){
mhl_mem_free (fname); g_free (fname);
return 0; return 0;
} }
file_fd = mc_open (fname, O_RDONLY); file_fd = mc_open (fname, O_RDONLY);
mhl_mem_free (fname); g_free (fname);
if (file_fd == -1) if (file_fd == -1)
return 0; return 0;
@ -563,7 +563,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
if (found == 0){ /* Search in binary line once */ if (found == 0){ /* Search in binary line once */
if (find_regex_flag) { if (find_regex_flag) {
if (regexec (r, p, 1, 0, 0) == 0){ if (regexec (r, p, 1, 0, 0) == 0){
mhl_mem_free (p); g_free (p);
p = g_strdup_printf ("%d:%s", line, filename); p = g_strdup_printf ("%d:%s", line, filename);
find_add_match (h, directory, p); find_add_match (h, directory, p);
found = 1; found = 1;
@ -580,7 +580,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
line++; line++;
found = 0; found = 0;
} }
mhl_mem_free (p); g_free (p);
if ((line & 0xff) == 0) { if ((line & 0xff) == 0) {
FindProgressStatus res; FindProgressStatus res;
@ -623,7 +623,7 @@ do_search (struct Dlg_head *h)
mc_closedir (dirp); mc_closedir (dirp);
dirp = 0; dirp = 0;
} }
mhl_mem_free (directory); g_free (directory);
directory = NULL; directory = NULL;
dp = 0; dp = 0;
return 1; return 1;
@ -653,16 +653,16 @@ do_search (struct Dlg_head *h)
char *temp_dir = g_strconcat (":", tmp, ":", (char *) NULL); char *temp_dir = g_strconcat (":", tmp, ":", (char *) NULL);
found = strstr (find_ignore_dirs, temp_dir) != 0; found = strstr (find_ignore_dirs, temp_dir) != 0;
mhl_mem_free (temp_dir); g_free (temp_dir);
if (found) if (found)
mhl_mem_free (tmp); g_free (tmp);
else else
break; break;
} else } else
break; break;
} }
mhl_mem_free (directory); g_free (directory);
directory = tmp; directory = tmp;
if (verbose){ if (verbose){
@ -701,7 +701,7 @@ do_search (struct Dlg_head *h)
push_directory (tmp_name); push_directory (tmp_name);
subdirs_left--; subdirs_left--;
} }
mhl_mem_free (tmp_name); g_free (tmp_name);
} }
if (regexp_match (find_pattern, dp->d_name, match_file)){ if (regexp_match (find_pattern, dp->d_name, match_file)){
@ -738,14 +738,14 @@ init_find_vars (void)
{ {
char *dir; char *dir;
mhl_mem_free (old_dir); g_free (old_dir);
old_dir = 0; old_dir = 0;
count = 0; count = 0;
matches = 0; matches = 0;
/* Remove all the items in the stack */ /* Remove all the items in the stack */
while ((dir = pop_directory ()) != NULL) while ((dir = pop_directory ()) != NULL)
mhl_mem_free (dir); g_free (dir);
} }
static char * static char *
@ -779,7 +779,7 @@ find_do_view_edit (int unparsed_view, int edit, char *dir, char *file)
do_edit_at_line (fullname, line); do_edit_at_line (fullname, line);
else else
view_file_at_line (fullname, unparsed_view, use_internal_view, line); view_file_at_line (fullname, unparsed_view, use_internal_view, line);
mhl_mem_free (fullname); g_free (fullname);
} }
static int static int
@ -979,7 +979,7 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname,
/* Remove all the items in the stack */ /* Remove all the items in the stack */
while ((dir = pop_directory ()) != NULL) while ((dir = pop_directory ()) != NULL)
mhl_mem_free (dir); g_free (dir);
get_list_info (&file_tmp, &dir_tmp); get_list_info (&file_tmp, &dir_tmp);
@ -1014,18 +1014,18 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname,
handle_path (list, name, &st, next_free, &link_to_dir, handle_path (list, name, &st, next_free, &link_to_dir,
&stale_link); &stale_link);
if (status == 0) { if (status == 0) {
mhl_mem_free (name); g_free (name);
continue; continue;
} }
if (status == -1) { if (status == -1) {
mhl_mem_free (name); g_free (name);
break; break;
} }
/* don't add files more than once to the panel */ /* don't add files more than once to the panel */
if (content_pattern && next_free > 0) { if (content_pattern && next_free > 0) {
if (strcmp (list->list[next_free - 1].fname, name) == 0) { if (strcmp (list->list[next_free - 1].fname, name) == 0) {
mhl_mem_free (name); g_free (name);
continue; continue;
} }
} }
@ -1062,7 +1062,7 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname,
kill_gui (); kill_gui ();
do_search (0); /* force do_search to release resources */ do_search (0); /* force do_search to release resources */
mhl_mem_free (old_dir); g_free (old_dir);
old_dir = 0; old_dir = 0;
return return_value; return return_value;
@ -1081,8 +1081,8 @@ do_find (void)
dirname = filename = NULL; dirname = filename = NULL;
is_start = 0; is_start = 0;
v = find_file (start_dir, pattern, content, &dirname, &filename); v = find_file (start_dir, pattern, content, &dirname, &filename);
mhl_mem_free (start_dir); g_free (start_dir);
mhl_mem_free (pattern); g_free (pattern);
if (find_regex_flag && r) if (find_regex_flag && r)
regfree (r); regfree (r);
@ -1097,14 +1097,14 @@ do_find (void)
do_cd (filename, cd_exact); do_cd (filename, cd_exact);
select_item (current_panel); select_item (current_panel);
} }
mhl_mem_free (dirname); g_free (dirname);
mhl_mem_free (filename); g_free (filename);
break; break;
} }
mhl_mem_free (content); g_free (content);
dir_and_file_set = dirname && filename; dir_and_file_set = dirname && filename;
mhl_mem_free (dirname); g_free (dirname);
mhl_mem_free (filename); g_free (filename);
if (v == B_CANCEL) if (v == B_CANCEL)
break; break;

View File

@ -129,7 +129,7 @@ search_string (const char *start, const char *text)
} }
} }
cleanup: cleanup:
mhl_mem_free (local_text); g_free (local_text);
return result; return result;
} }
@ -329,7 +329,7 @@ static void clear_link_areas (void)
while (link_area){ while (link_area){
current = link_area; current = link_area;
link_area = current -> next; link_area = current -> next;
mhl_mem_free (current); g_free (current);
} }
inside_link_area = 0; inside_link_area = 0;
} }
@ -755,7 +755,7 @@ static void
interactive_display_finish (void) interactive_display_finish (void)
{ {
clear_link_areas (); clear_link_areas ();
mhl_mem_free (data); g_free (data);
} }
void void
@ -776,7 +776,7 @@ interactive_display (const char *filename, const char *node)
} }
if (!filename) if (!filename)
mhl_mem_free (hlpfile); g_free (hlpfile);
if (!data) if (!data)
return; return;

View File

@ -201,7 +201,7 @@ update_path_name (void)
else else
label_set_text (movelist_group, label_set_text (movelist_group,
name_trunc (p, dlg->cols - (UX * 2 + 4))); name_trunc (p, dlg->cols - (UX * 2 + 4)));
mhl_mem_free (p); g_free (p);
dlg_redraw (dlg); dlg_redraw (dlg);
} }
@ -211,7 +211,7 @@ do { \
int i; \ int i; \
\ \
if ((i = strlen (current->label) + 3) > buflen) { \ if ((i = strlen (current->label) + 3) > buflen) { \
mhl_mem_free (buf); \ g_free (buf); \
buf = g_malloc (buflen = 1024 * (i/1024 + 1)); \ buf = g_malloc (buflen = 1024 * (i/1024 + 1)); \
} \ } \
buf[0] = '\0'; \ buf[0] = '\0'; \
@ -465,7 +465,7 @@ hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm)
char *tmp = char *tmp =
g_strconcat ("cd ", hlp->directory, (char *) NULL); g_strconcat ("cd ", hlp->directory, (char *) NULL);
stuff (cmdline, tmp, 0); stuff (cmdline, tmp, 0);
mhl_mem_free (tmp); g_free (tmp);
dlg_stop (h); dlg_stop (h);
h->ret_value = B_CANCEL; h->ret_value = B_CANCEL;
return MSG_HANDLED; return MSG_HANDLED;
@ -688,7 +688,7 @@ init_movelist (int list_type, struct hotlist *item)
movelist_dlg = movelist_dlg =
create_dlg (0, 0, LINES - 6, movelist_cols, dialog_colors, create_dlg (0, 0, LINES - 6, movelist_cols, dialog_colors,
hotlist_callback, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE); hotlist_callback, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE);
mhl_mem_free (hdr); g_free (hdr);
for (i = 0; i < BUTTONS; i++) { for (i = 0; i < BUTTONS; i++) {
if (hotlist_but[i].type & list_type) if (hotlist_but[i].type & list_type)
@ -813,7 +813,7 @@ add2hotlist (char *label, char *directory, enum HotListType type, int pos)
char *lbl = g_strconcat ("->", new->label, (char *) NULL); char *lbl = g_strconcat ("->", new->label, (char *) NULL);
listbox_add_item (l_hotlist, pos, 0, lbl, new); listbox_add_item (l_hotlist, pos, 0, lbl, new);
mhl_mem_free (lbl); g_free (lbl);
} else } else
listbox_add_item (l_hotlist, pos, 0, new->label, new); listbox_add_item (l_hotlist, pos, 0, new->label, new);
listbox_select_entry (l_hotlist, l_hotlist->current); listbox_select_entry (l_hotlist, l_hotlist->current);
@ -939,13 +939,13 @@ static void add_new_entry_cmd (void)
ret = add_new_entry_input (_("New hotlist entry"), _("Directory label"), ret = add_new_entry_input (_("New hotlist entry"), _("Directory label"),
_("Directory path"), "[Hotlist]", &title, &url); _("Directory path"), "[Hotlist]", &title, &url);
mhl_mem_free (to_free); g_free (to_free);
if (!ret) if (!ret)
return; return;
if (!title || !*title || !url || !*url) { if (!title || !*title || !url || !*url) {
mhl_mem_free (title); g_free (title);
mhl_mem_free (url); g_free (url);
return; return;
} }
@ -1046,11 +1046,11 @@ void add2hotlist_cmd (void)
prompt = g_strdup_printf (cp, path_trunc (current_panel->cwd, COLS-2*UX-(l+8))); 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); label = input_dialog (_(" Add to hotlist "), prompt, MC_HISTORY_HOTLIST_ADD, label_string);
mhl_mem_free (prompt); g_free (prompt);
if (!label || !*label) { if (!label || !*label) {
mhl_mem_free (label_string); g_free (label_string);
mhl_mem_free (label); g_free (label);
return; return;
} }
add2hotlist (label, label_string, HL_TYPE_ENTRY, 0); add2hotlist (label, label_string, HL_TYPE_ENTRY, 0);
@ -1067,9 +1067,9 @@ static void remove_group (struct hotlist *grp)
if (current->type == HL_TYPE_GROUP) if (current->type == HL_TYPE_GROUP)
remove_group (current); remove_group (current);
mhl_mem_free (current->label); g_free (current->label);
mhl_mem_free (current->directory); g_free (current->directory);
mhl_mem_free (current); g_free (current);
current = next; current = next;
} }
@ -1096,7 +1096,7 @@ static void remove_from_hotlist (struct hotlist *entry)
_("\n Are you sure you want to remove this entry?"), _("\n Are you sure you want to remove this entry?"),
D_ERROR, 2, _("&Yes"), _("&No")); D_ERROR, 2, _("&Yes"), _("&No"));
mhl_mem_free (title); g_free (title);
if (result != 0) if (result != 0)
return; return;
@ -1114,7 +1114,7 @@ static void remove_from_hotlist (struct hotlist *entry)
result = query_dialog (header, _("\n Group not empty.\n Remove it?"), result = query_dialog (header, _("\n Group not empty.\n Remove it?"),
D_ERROR, 2, D_ERROR, 2,
_("&Yes"), _("&No")); _("&Yes"), _("&No"));
mhl_mem_free (header); g_free (header);
if (result != 0) if (result != 0)
return; return;
@ -1125,9 +1125,9 @@ static void remove_from_hotlist (struct hotlist *entry)
unlink_entry (entry); unlink_entry (entry);
mhl_mem_free (entry->label); g_free (entry->label);
mhl_mem_free (entry->directory); g_free (entry->directory);
mhl_mem_free (entry); g_free (entry);
/* now remove list entry from screen */ /* now remove list entry from screen */
listbox_remove_current (l_hotlist, 1); listbox_remove_current (l_hotlist, 1);
hotlist_state.modified = 1; hotlist_state.modified = 1;
@ -1185,7 +1185,7 @@ load_group (struct hotlist *grp)
profile_keys = profile_iterator_next (profile_keys, &key, &value); profile_keys = profile_iterator_next (profile_keys, &key, &value);
add2hotlist (mhl_str_dup (value), mhl_str_dup (key), HL_TYPE_GROUP, 0); add2hotlist (mhl_str_dup (value), mhl_str_dup (key), HL_TYPE_GROUP, 0);
} }
mhl_mem_free (group_section); g_free (group_section);
profile_keys = profile_init_iterator (grp->directory, profile_name); profile_keys = profile_init_iterator (grp->directory, profile_name);
@ -1429,7 +1429,7 @@ clean_up_hotlist_groups (const char *section)
} }
profile_clean_section (grp_section, profile_name); profile_clean_section (grp_section, profile_name);
} }
mhl_mem_free (grp_section); g_free (grp_section);
} }
@ -1574,7 +1574,7 @@ int save_hotlist (void)
hotlist_state.modified = 0; hotlist_state.modified = 0;
} else } else
rename (fbak, hotlist_file_name); rename (fbak, hotlist_file_name);
mhl_mem_free (fbak); g_free (fbak);
} }
return saved; return saved;
@ -1588,20 +1588,20 @@ void done_hotlist (void)
{ {
if (hotlist){ if (hotlist){
remove_group (hotlist); remove_group (hotlist);
mhl_mem_free (hotlist->label); g_free (hotlist->label);
mhl_mem_free (hotlist->directory); g_free (hotlist->directory);
mhl_mem_free (hotlist); g_free (hotlist);
hotlist = 0; hotlist = 0;
} }
hotlist_state.loaded = 0; hotlist_state.loaded = 0;
mhl_mem_free (hotlist_file_name); g_free (hotlist_file_name);
hotlist_file_name = 0; hotlist_file_name = 0;
l_hotlist = 0; l_hotlist = 0;
current_group = 0; current_group = 0;
if (tkn_buf){ if (tkn_buf){
mhl_mem_free (tkn_buf); g_free (tkn_buf);
tkn_buf_length = 0; tkn_buf_length = 0;
tkn_length = 0; tkn_length = 0;
tkn_buf = NULL; tkn_buf = NULL;

View File

@ -155,7 +155,7 @@ void delete_select_channel (int fd)
else else
select_list = p_next; select_list = p_next;
mhl_mem_free (p); g_free (p);
p = p_next; p = p_next;
continue; continue;
} }
@ -1398,7 +1398,7 @@ static void k_dispose (key_def *k)
return; return;
k_dispose (k->child); k_dispose (k->child);
k_dispose (k->next); k_dispose (k->next);
mhl_mem_free (k); g_free (k);
} }
static void s_dispose (SelectList *sel) static void s_dispose (SelectList *sel)
@ -1407,7 +1407,7 @@ static void s_dispose (SelectList *sel)
return; return;
s_dispose (sel->next); s_dispose (sel->next);
mhl_mem_free (sel); g_free (sel);
} }
void done_key () void done_key ()

View File

@ -26,6 +26,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -1053,13 +1054,13 @@ void swap_panels ()
if (panels [0].type == view_listing) { if (panels [0].type == view_listing) {
if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) { if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) {
mhl_mem_free (panel1->panel_name); g_free (panel1->panel_name);
panel1->panel_name = mhl_str_dup (get_nth_panel_name (1)); panel1->panel_name = mhl_str_dup (get_nth_panel_name (1));
} }
} }
if (panels [1].type == view_listing) { if (panels [1].type == view_listing) {
if (!strcmp (panel2->panel_name, get_nth_panel_name (1))) { if (!strcmp (panel2->panel_name, get_nth_panel_name (1))) {
mhl_mem_free (panel2->panel_name); g_free (panel2->panel_name);
panel2->panel_name = mhl_str_dup (get_nth_panel_name (0)); panel2->panel_name = mhl_str_dup (get_nth_panel_name (0));
} }
} }

View File

@ -25,12 +25,11 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <mhl/memory.h>
#include "global.h" #include "global.h"
#include "tty.h" #include "tty.h"
#include "win.h" #include "win.h"
@ -89,7 +88,7 @@ _("Please press the %s\n"
_(key_name_conv_tab [action - B_USER].longname)); _(key_name_conv_tab [action - B_USER].longname));
mc_refresh (); mc_refresh ();
if (learnkeys [action - B_USER].sequence != NULL) { if (learnkeys [action - B_USER].sequence != NULL) {
mhl_mem_free (learnkeys [action - B_USER].sequence); g_free (learnkeys [action - B_USER].sequence);
learnkeys [action - B_USER].sequence = NULL; learnkeys [action - B_USER].sequence = NULL;
} }
seq = learn_key (); seq = learn_key ();
@ -118,7 +117,7 @@ _("Please press the %s\n"
_(" You have entered \"%s\""), seq); _(" You have entered \"%s\""), seq);
} }
mhl_mem_free (seq); g_free (seq);
} }
dlg_run_done (d); dlg_run_done (d);
@ -328,7 +327,7 @@ learn_save (void)
if (profile_changed) if (profile_changed)
sync_profiles (); sync_profiles ();
mhl_mem_free (section); g_free (section);
} }
void learn_keys (void) void learn_keys (void)

View File

@ -290,7 +290,7 @@ listmode_edit (char *oldlistformat)
s = mhl_str_dup (oldlistformat); s = mhl_str_dup (oldlistformat);
listmode_dlg = init_listmode (s); listmode_dlg = init_listmode (s);
mhl_mem_free (s); g_free (s);
if (run_dlg (listmode_dlg) == B_ENTER) { if (run_dlg (listmode_dlg) == B_ENTER) {
newformat = collect_new_format (); newformat = collect_new_format ();

View File

@ -46,7 +46,7 @@ is_logging_enabled(void)
mc_ini = g_strdup_printf("%s/%s", home_dir, PROFILE_NAME); mc_ini = g_strdup_printf("%s/%s", home_dir, PROFILE_NAME);
logging_enabled = logging_enabled =
get_int(mc_ini, "development.enable_logging", FALSE); get_int(mc_ini, "development.enable_logging", FALSE);
mhl_mem_free(mc_ini); g_free(mc_ini);
logging_initialized = TRUE; logging_initialized = TRUE;
} }
return logging_enabled; return logging_enabled;
@ -68,6 +68,6 @@ mc_log(const char *fmt, ...)
(void)vfprintf(f, fmt, args); (void)vfprintf(f, fmt, args);
(void)fclose(f); (void)fclose(f);
} }
mhl_mem_free(logfilename); g_free(logfilename);
} }
} }

View File

@ -302,7 +302,7 @@ reload_panelized (WPanel *panel)
do_file_mark (panel, i, 0); do_file_mark (panel, i, 0);
} }
if (mc_lstat (list->list[i].fname, &list->list[i].st)) { if (mc_lstat (list->list[i].fname, &list->list[i].st)) {
mhl_mem_free (list->list[i].fname); g_free (list->list[i].fname);
continue; continue;
} }
if (list->list[i].f.marked) if (list->list[i].f.marked)
@ -350,7 +350,7 @@ update_one_panel_widget (WPanel *panel, int force_update,
panel->dirty = 1; panel->dirty = 1;
if (free_pointer) if (free_pointer)
mhl_mem_free (my_current_file); g_free (my_current_file);
} }
void void
@ -590,11 +590,11 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type)
if (mc_chdir (directory) == -1) { if (mc_chdir (directory) == -1) {
strcpy (panel->cwd, olddir); strcpy (panel->cwd, olddir);
mhl_mem_free (olddir); g_free (olddir);
mhl_mem_free (translated_url); g_free (translated_url);
return 0; return 0;
} }
mhl_mem_free (translated_url); g_free (translated_url);
/* Success: save previous directory, shutdown status of previous dir */ /* Success: save previous directory, shutdown status of previous dir */
strcpy (panel->lwd, olddir); strcpy (panel->lwd, olddir);
@ -617,7 +617,7 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type)
panel->dirty = 1; panel->dirty = 1;
update_xterm_title_path (); update_xterm_title_path ();
mhl_mem_free (olddir); g_free (olddir);
return 1; return 1;
} }
@ -688,7 +688,7 @@ directory_history_list (WPanel *panel)
directory_history_add (panel, panel->cwd); directory_history_add (panel, panel->cwd);
else else
message (D_ERROR, MSG_ERROR, _("Cannot change directory")); message (D_ERROR, MSG_ERROR, _("Cannot change directory"));
mhl_mem_free (s); g_free (s);
} }
#ifdef HAVE_SUBSHELL_SUPPORT #ifdef HAVE_SUBSHELL_SUPPORT
@ -777,7 +777,7 @@ treebox_cmd (void)
sel_dir = tree_box (selection (current_panel)->fname); sel_dir = tree_box (selection (current_panel)->fname);
if (sel_dir) { if (sel_dir) {
do_cd (sel_dir, cd_exact); do_cd (sel_dir, cd_exact);
mhl_mem_free (sel_dir); g_free (sel_dir);
} }
} }
@ -794,7 +794,7 @@ listmode_cmd (void)
if (!newmode) if (!newmode)
return; return;
mhl_mem_free (current_panel->user_format); g_free (current_panel->user_format);
current_panel->list_type = list_user; current_panel->list_type = list_user;
current_panel->user_format = newmode; current_panel->user_format = newmode;
set_panel_formats (current_panel); set_panel_formats (current_panel);
@ -1036,7 +1036,7 @@ translated_mc_chdir (char *dir)
newdir = vfs_translate_url (dir); newdir = vfs_translate_url (dir);
mc_chdir (newdir); mc_chdir (newdir);
mhl_mem_free (newdir); g_free (newdir);
} }
static void static void
@ -1142,7 +1142,7 @@ copy_readlink (WPanel *panel)
int i; int i;
i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1); i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1);
mhl_mem_free (p); g_free (p);
if (i > 0) { if (i > 0) {
buffer[i] = 0; buffer[i] = 0;
command_insert (cmdline, buffer, 1); command_insert (cmdline, buffer, 1);
@ -1622,7 +1622,7 @@ update_xterm_title_path (void)
numeric_keypad_mode (); numeric_keypad_mode ();
fprintf (stdout, "\33]0;mc - %s\7", p); fprintf (stdout, "\33]0;mc - %s\7", p);
fflush (stdout); fflush (stdout);
mhl_mem_free (p); g_free (p);
} }
} }
@ -1646,7 +1646,7 @@ load_hint (int force)
if ((hint = get_random_hint (force))) { if ((hint = get_random_hint (force))) {
if (*hint) if (*hint)
set_hintbar (hint); set_hintbar (hint);
mhl_mem_free (hint); g_free (hint);
} else { } else {
char text[BUF_SMALL]; char text[BUF_SMALL];
@ -1714,7 +1714,7 @@ mc_maybe_editor_or_viewer (void)
char *path = NULL; char *path = NULL;
path = prepend_cwd_on_local (view_one_file); path = prepend_cwd_on_local (view_one_file);
view_file (path, 0, 1); view_file (path, 0, 1);
mhl_mem_free (path); g_free (path);
} }
#ifdef USE_INTERNAL_EDIT #ifdef USE_INTERNAL_EDIT
else { else {
@ -2079,7 +2079,7 @@ handle_args (int argc, char *argv[])
edit_one_file = fname; edit_one_file = fname;
edit_one_file_start_line = atoi (p); edit_one_file_start_line = atoi (p);
} else { } else {
mhl_mem_free (fname); g_free (fname);
goto try_plus_filename; goto try_plus_filename;
} }
} else { } else {
@ -2248,15 +2248,15 @@ main (int argc, char *argv[])
close (last_wd_fd); close (last_wd_fd);
} }
} }
mhl_mem_free (last_wd_string); g_free (last_wd_string);
mhl_mem_free (mc_home); g_free (mc_home);
done_key (); done_key ();
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
free_codepages_list (); free_codepages_list ();
#endif #endif
mhl_mem_free (this_dir); g_free (this_dir);
mhl_mem_free (other_dir); g_free (other_dir);
return 0; return 0;
} }

View File

@ -533,9 +533,9 @@ menubar_arrange(WMenu* menubar)
void void
destroy_menu (Menu *menu) destroy_menu (Menu *menu)
{ {
mhl_mem_free (menu->name); g_free (menu->name);
mhl_mem_free (menu->help_node); g_free (menu->help_node);
mhl_mem_free (menu); g_free (menu);
} }
WMenu * WMenu *

View File

@ -234,7 +234,7 @@ add2panelize_cmd (void)
if (!label) if (!label)
return; return;
if (!*label) { if (!*label) {
mhl_mem_free (label); g_free (label);
return; return;
} }
@ -256,9 +256,9 @@ static void remove_from_panelize (struct panelize *entry)
} }
} }
mhl_mem_free (entry->label); g_free (entry->label);
mhl_mem_free (entry->command); g_free (entry->command);
mhl_mem_free (entry); g_free (entry);
} }
} }
@ -298,7 +298,7 @@ external_panelize (void)
char *cmd = mhl_str_dup (target); char *cmd = mhl_str_dup (target);
destroy_dlg (panelize_dlg); destroy_dlg (panelize_dlg);
do_external_panelize (cmd); do_external_panelize (cmd);
mhl_mem_free (cmd); g_free (cmd);
repaint_screen (); repaint_screen ();
return; return;
} }
@ -352,9 +352,9 @@ void done_panelize (void)
for (; current; current = next){ for (; current; current = next){
next = current->next; next = current->next;
mhl_mem_free (current->label); g_free (current->label);
mhl_mem_free (current->command); g_free (current->command);
mhl_mem_free (current); g_free (current);
} }
} }

View File

@ -250,7 +250,7 @@ static TSecHeader *load (const char *file)
break; break;
case OnSecHeader: { /* Broken initialization file */ case OnSecHeader: { /* Broken initialization file */
TSecHeader *link = SecHeader->link; TSecHeader *link = SecHeader->link;
mhl_mem_free (SecHeader); g_free (SecHeader);
SecHeader = link; SecHeader = link;
fprintf (stderr, "Warning: Corrupted initialization file `%s'\n", fprintf (stderr, "Warning: Corrupted initialization file `%s'\n",
file); file);
@ -300,7 +300,7 @@ GetSetProfileChar (int set, const char *AppName, const char *KeyName,
if ( g_strcasecmp (key->KeyName, KeyName)) if ( g_strcasecmp (key->KeyName, KeyName))
continue; continue;
if (set){ if (set){
mhl_mem_free (key->Value); g_free (key->Value);
key->Value = mhl_str_dup (Default); key->Value = mhl_str_dup (Default);
} }
return key->Value; return key->Value;
@ -384,7 +384,7 @@ static void dump_keys (FILE * profile, TKeys * p)
dump_keys (profile, p->link); dump_keys (profile, p->link);
t = str_untranslate_newline_dup (p->Value); t = str_untranslate_newline_dup (p->Value);
fprintf (profile, "%s=%s\n", p->KeyName, t); fprintf (profile, "%s=%s\n", p->KeyName, t);
mhl_mem_free (t); g_free (t);
} }
static void dump_sections (FILE *profile, TSecHeader *p) static void dump_sections (FILE *profile, TSecHeader *p)
@ -427,9 +427,9 @@ static void free_keys (TKeys *p)
if (!p) if (!p)
return; return;
free_keys (p->link); free_keys (p->link);
mhl_mem_free (p->KeyName); g_free (p->KeyName);
mhl_mem_free (p->Value); g_free (p->Value);
mhl_mem_free (p); g_free (p);
} }
static void free_sections (TSecHeader *p) static void free_sections (TSecHeader *p)
@ -438,10 +438,10 @@ static void free_sections (TSecHeader *p)
return; return;
free_sections (p->link); free_sections (p->link);
free_keys (p->Keys); free_keys (p->Keys);
mhl_mem_free (p->AppName); g_free (p->AppName);
p->link = 0; p->link = 0;
p->Keys = 0; p->Keys = 0;
mhl_mem_free (p); g_free (p);
} }
static void free_profile (TProfile *p) static void free_profile (TProfile *p)
@ -450,8 +450,8 @@ static void free_profile (TProfile *p)
return; return;
free_profile (p->link); free_profile (p->link);
free_sections (p->Section); free_sections (p->Section);
mhl_mem_free (p->FileName); g_free (p->FileName);
mhl_mem_free (p); g_free (p);
} }
void free_profile_name (const char *s) void free_profile_name (const char *s)

View File

@ -21,11 +21,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <mhl/memory.h>
#include "global.h" #include "global.h"
#include "tty.h" /* move, addch */ #include "tty.h" /* move, addch */
#include "cons.saver.h" #include "cons.saver.h"
@ -114,6 +113,6 @@ void show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
move (starty + (i / cols), 0); move (starty + (i / cols), 0);
addch (is_printable (k[i]) ? k[i] : ' '); addch (is_printable (k[i]) ? k[i] : ' ');
} }
mhl_mem_free (k); g_free (k);
} }

View File

@ -133,7 +133,7 @@ delete_format (format_e *format)
while (format){ while (format){
next = format->next; next = format->next;
mhl_mem_free (format); g_free (format);
format = next; format = next;
} }
} }
@ -713,7 +713,7 @@ display_mini_info (WPanel *panel)
link = mhl_str_dir_plus_file (panel->cwd, panel->dir.list [panel->selected].fname); link = mhl_str_dir_plus_file (panel->cwd, panel->dir.list [panel->selected].fname);
len = mc_readlink (link, link_target, MC_MAXPATHLEN - 1); len = mc_readlink (link, link_target, MC_MAXPATHLEN - 1);
mhl_mem_free (link); g_free (link);
if (len > 0){ if (len > 0){
link_target[len] = 0; link_target[len] = 0;
tty_printf ("-> %-*s", panel->widget.cols - 5, tty_printf ("-> %-*s", panel->widget.cols - 5,
@ -798,7 +798,7 @@ show_dir (WPanel *panel)
trim (strip_home_and_password (panel->cwd), tmp, trim (strip_home_and_password (panel->cwd), tmp,
max (panel->widget.cols - 9, 0)); max (panel->widget.cols - 9, 0));
addstr (tmp); addstr (tmp);
mhl_mem_free (tmp); g_free (tmp);
addch (' '); addch (' ');
widget_move (&panel->widget, 0, 1); widget_move (&panel->widget, 0, 1);
@ -894,7 +894,7 @@ do_try_to_select (WPanel *panel, const char *name)
for (i = 0; i < panel->count; i++){ for (i = 0; i < panel->count; i++){
if (strcmp (subdir, panel->dir.list [i].fname) == 0) { if (strcmp (subdir, panel->dir.list [i].fname) == 0) {
do_select (panel, i); do_select (panel, i);
mhl_mem_free (subdir); g_free (subdir);
return; return;
} }
} }
@ -902,7 +902,7 @@ do_try_to_select (WPanel *panel, const char *name)
/* Try to select a file near the file that is missing */ /* Try to select a file near the file that is missing */
if (panel->selected >= panel->count) if (panel->selected >= panel->count)
do_select (panel, panel->count-1); do_select (panel, panel->count-1);
mhl_mem_free (subdir); g_free (subdir);
} }
void void
@ -966,21 +966,21 @@ panel_destroy (WPanel *p)
history_put (p->hist_name, p->dir_history); history_put (p->hist_name, p->dir_history);
p->dir_history = g_list_first (p->dir_history); p->dir_history = g_list_first (p->dir_history);
g_list_foreach (p->dir_history, (GFunc) mhl_mem_free, NULL); g_list_foreach (p->dir_history, (GFunc) g_free, NULL);
g_list_free (p->dir_history); g_list_free (p->dir_history);
} }
mhl_mem_free (p->hist_name); g_free (p->hist_name);
delete_format (p->format); delete_format (p->format);
delete_format (p->status_format); delete_format (p->status_format);
mhl_mem_free (p->user_format); g_free (p->user_format);
for (i = 0; i < LIST_TYPES; i++) for (i = 0; i < LIST_TYPES; i++)
mhl_mem_free (p->user_status_format[i]); g_free (p->user_status_format[i]);
mhl_mem_free (p->dir.list); g_free (p->dir.list);
mhl_mem_free (p->panel_name); g_free (p->panel_name);
mhl_mem_free (name); g_free (name);
} }
static void static void
@ -1041,11 +1041,11 @@ panel_new (const char *panel_name)
panel->frame_size = frame_half; panel->frame_size = frame_half;
section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL); section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
if (!profile_has_section (section, profile_name)) { if (!profile_has_section (section, profile_name)) {
mhl_mem_free (section); g_free (section);
section = mhl_str_dup (panel->panel_name); section = mhl_str_dup (panel->panel_name);
} }
panel_load_setup (panel, section); panel_load_setup (panel, section);
mhl_mem_free (section); g_free (section);
/* Load format strings */ /* Load format strings */
err = set_panel_formats (panel); err = set_panel_formats (panel);
@ -1328,7 +1328,7 @@ parse_display_format (WPanel *panel, const char *format, char **error, int issta
delete_format (home); delete_format (home);
tmp_format [pos] = 0; tmp_format [pos] = 0;
*error = g_strconcat (_("Unknown tag on display format: "), tmp_format, (char *) NULL); *error = g_strconcat (_("Unknown tag on display format: "), tmp_format, (char *) NULL);
mhl_mem_free (tmp_format); g_free (tmp_format);
return 0; return 0;
} }
total_cols += darr->requested_field_len; total_cols += darr->requested_field_len;
@ -1417,7 +1417,7 @@ set_panel_formats (WPanel *p)
form = use_display_format (p, panel_format (p), &err, 0); form = use_display_format (p, panel_format (p), &err, 0);
if (err){ if (err){
mhl_mem_free (err); g_free (err);
retcode = 1; retcode = 1;
} }
else { else {
@ -1432,7 +1432,7 @@ set_panel_formats (WPanel *p)
form = use_display_format (p, mini_status_format (p), &err, 1); form = use_display_format (p, mini_status_format (p), &err, 1);
if (err){ if (err){
mhl_mem_free (err); g_free (err);
retcode += 2; retcode += 2;
} }
else { else {
@ -1449,11 +1449,11 @@ set_panel_formats (WPanel *p)
if (retcode) if (retcode)
message( 1, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) ); message( 1, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) );
if (retcode & 0x01){ if (retcode & 0x01){
mhl_mem_free (p->user_format); g_free (p->user_format);
p->user_format = mhl_str_dup (DEFAULT_USER_FORMAT); p->user_format = mhl_str_dup (DEFAULT_USER_FORMAT);
} }
if (retcode & 0x02){ if (retcode & 0x02){
mhl_mem_free (p->user_status_format [p->list_type]); g_free (p->user_status_format [p->list_type]);
p->user_status_format [p->list_type] = mhl_str_dup (DEFAULT_USER_FORMAT); p->user_status_format [p->list_type] = mhl_str_dup (DEFAULT_USER_FORMAT);
} }
@ -1978,10 +1978,10 @@ do_enter_on_file_entry (file_entry *fe)
/* Check if the file is executable */ /* Check if the file is executable */
full_name = mhl_str_dir_plus_file (current_panel->cwd, fe->fname); 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)) { if (!is_exe (fe->st.st_mode) || !if_link_is_exe (full_name, fe)) {
mhl_mem_free (full_name); g_free (full_name);
return 0; return 0;
} }
mhl_mem_free (full_name); g_free (full_name);
if (confirm_execute) { if (confirm_execute) {
if (query_dialog if (query_dialog
@ -1997,7 +1997,7 @@ do_enter_on_file_entry (file_entry *fe)
tmp = mhl_str_dir_plus_file (vfs_get_current_dir (), fe->fname); tmp = mhl_str_dir_plus_file (vfs_get_current_dir (), fe->fname);
ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL); ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL);
mhl_mem_free (tmp); g_free (tmp);
/* We took action only if the dialog was shown or the execution /* We took action only if the dialog was shown or the execution
* was successful */ * was successful */
return confirm_execute || (ret == 0); return confirm_execute || (ret == 0);
@ -2007,9 +2007,9 @@ do_enter_on_file_entry (file_entry *fe)
{ {
char *tmp = name_quote (fe->fname, 0); char *tmp = name_quote (fe->fname, 0);
char *cmd = g_strconcat (".", PATH_SEP_STR, tmp, (char *) NULL); char *cmd = g_strconcat (".", PATH_SEP_STR, tmp, (char *) NULL);
mhl_mem_free (tmp); g_free (tmp);
shell_execute (cmd, 0); shell_execute (cmd, 0);
mhl_mem_free (cmd); g_free (cmd);
} }
return 1; return 1;
@ -2045,7 +2045,7 @@ chdir_other_panel (WPanel *panel)
move_down (panel); move_down (panel);
mhl_mem_free (new_dir); g_free (new_dir);
} }
/* /*
@ -2109,7 +2109,7 @@ chdir_to_readlink (WPanel *panel)
move_down (panel); move_down (panel);
mhl_mem_free (new_dir); g_free (new_dir);
} }
} }
@ -2256,7 +2256,7 @@ panel_callback (Widget *w, widget_msg_t msg, int parm)
char *cwd = strip_password (mhl_str_dup (panel->cwd), 1); char *cwd = strip_password (mhl_str_dup (panel->cwd), 1);
message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "), message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "),
cwd, unix_error_string (errno)); cwd, unix_error_string (errno));
mhl_mem_free(cwd); g_free(cwd);
} else } else
subshell_chdir (panel->cwd); subshell_chdir (panel->cwd);
@ -2476,7 +2476,7 @@ panel_re_sort (WPanel *panel)
break; break;
} }
} }
mhl_mem_free (filename); g_free (filename);
panel->top_file = panel->selected - ITEMS (panel)/2; panel->top_file = panel->selected - ITEMS (panel)/2;
if (panel->top_file < 0) if (panel->top_file < 0)
panel->top_file = 0; panel->top_file = 0;
@ -2499,7 +2499,7 @@ panel_set_sort_order (WPanel *panel, sortfn *sort_order)
current_file = mhl_str_dup (panel->dir.list [panel->selected].fname); current_file = mhl_str_dup (panel->dir.list [panel->selected].fname);
panel_reload (panel); panel_reload (panel);
try_to_select (panel, current_file); try_to_select (panel, current_file);
mhl_mem_free (current_file); g_free (current_file);
} }
panel_re_sort (panel); panel_re_sort (panel);
} }

View File

@ -294,7 +294,7 @@ save_layout (void)
save_string ("Layout", layout [i].opt_name, buffer, profile); save_string ("Layout", layout [i].opt_name, buffer, profile);
} }
mhl_mem_free (profile); g_free (profile);
} }
void void
@ -314,7 +314,7 @@ save_configure (void)
set_config_string (profile, str_options[i].opt_name, set_config_string (profile, str_options[i].opt_name,
*str_options[i].opt_addr); *str_options[i].opt_addr);
mhl_mem_free (profile); g_free (profile);
} }
static void static void
@ -381,7 +381,7 @@ save_setup (void)
get_codepage_id( display_codepage ), profile_name ); get_codepage_id( display_codepage ), profile_name );
#endif /* HAVE_CHARSET */ #endif /* HAVE_CHARSET */
mhl_mem_free (profile); g_free (profile);
saving_setup = 0; saving_setup = 0;
} }
@ -414,12 +414,12 @@ panel_load_setup (WPanel *panel, const char *section)
} }
/* User formats */ /* User formats */
mhl_mem_free (panel->user_format); g_free (panel->user_format);
panel->user_format = mhl_str_dup (get_profile_string (section, "user_format", panel->user_format = mhl_str_dup (get_profile_string (section, "user_format",
DEFAULT_USER_FORMAT, DEFAULT_USER_FORMAT,
profile_name)); profile_name));
for (i = 0; i < LIST_TYPES; i++){ for (i = 0; i < LIST_TYPES; i++){
mhl_mem_free (panel->user_status_format [i]); g_free (panel->user_status_format [i]);
snprintf (buffer, sizeof (buffer), "user_status%d", i); snprintf (buffer, sizeof (buffer), "user_status%d", i);
panel->user_status_format [i] = panel->user_status_format [i] =
mhl_str_dup (get_profile_string (section, buffer, mhl_str_dup (get_profile_string (section, buffer,
@ -472,7 +472,7 @@ do_load_string (const char *s, const char *ss, const char *def)
load_string (s, ss, def, buffer, BUF_SMALL); load_string (s, ss, def, buffer, BUF_SMALL);
p = mhl_str_dup (buffer); p = mhl_str_dup (buffer);
mhl_mem_free (buffer); g_free (buffer);
return p; return p;
} }
#endif /* !USE_NETCODE */ #endif /* !USE_NETCODE */
@ -490,10 +490,10 @@ setup_init (void)
if (!exist_file (profile)){ if (!exist_file (profile)){
inifile = mhl_str_dir_plus_file (mc_home, "mc.ini"); inifile = mhl_str_dir_plus_file (mc_home, "mc.ini");
if (exist_file (inifile)){ if (exist_file (inifile)){
mhl_mem_free (profile); g_free (profile);
profile = inifile; profile = inifile;
} else } else
mhl_mem_free (inifile); g_free (inifile);
} }
profile_name = profile; profile_name = profile;
@ -543,7 +543,7 @@ load_setup (void)
if (vfs_file_is_local (buffer)) if (vfs_file_is_local (buffer))
other_dir = buffer; other_dir = buffer;
else else
mhl_mem_free (buffer); g_free (buffer);
} }
boot_current_is_left = boot_current_is_left =
@ -604,8 +604,8 @@ load_anon_passwd ()
void done_setup (void) void done_setup (void)
{ {
mhl_mem_free (profile_name); g_free (profile_name);
mhl_mem_free (global_profile_name); g_free (global_profile_name);
done_hotlist (); done_hotlist ();
done_panelize (); done_panelize ();
/* directory_history_free (); */ /* directory_history_free (); */
@ -624,7 +624,7 @@ load_keys_from_section (const char *terminal, const char *profile_name)
section_name = g_strconcat ("terminal:", terminal, (char *) NULL); section_name = g_strconcat ("terminal:", terminal, (char *) NULL);
profile_keys = profile_init_iterator (section_name, profile_name); profile_keys = profile_init_iterator (section_name, profile_name);
mhl_mem_free (section_name); g_free (section_name);
while (profile_keys){ while (profile_keys){
profile_keys = profile_iterator_next (profile_keys, &key, &value); profile_keys = profile_iterator_next (profile_keys, &key, &value);
@ -638,7 +638,7 @@ load_keys_from_section (const char *terminal, const char *profile_name)
if (key_code){ if (key_code){
valcopy = convert_controls (value); valcopy = convert_controls (value);
define_sequence (key_code, valcopy, MCKEY_NOACTION); define_sequence (key_code, valcopy, MCKEY_NOACTION);
mhl_mem_free (valcopy); g_free (valcopy);
} }
} }
} }

View File

@ -673,8 +673,8 @@ exit_subshell (void)
tcsh_fifo, unix_error_string (errno)); tcsh_fifo, unix_error_string (errno));
} }
mhl_mem_free (subshell_prompt); g_free (subshell_prompt);
mhl_mem_free (pty_buffer); g_free (pty_buffer);
subshell_prompt = NULL; subshell_prompt = NULL;
pty_buffer = NULL; pty_buffer = NULL;
} }
@ -765,7 +765,7 @@ do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
char *temp = subshell_name_quote (directory); char *temp = subshell_name_quote (directory);
if (temp) { if (temp) {
write_all (subshell_pty, temp, strlen (temp)); write_all (subshell_pty, temp, strlen (temp));
mhl_mem_free (temp); g_free (temp);
} else { } else {
/* Should not happen unless the directory name is so long /* Should not happen unless the directory name is so long
that we don't have memory to quote it. */ that we don't have memory to quote it. */
@ -801,7 +801,7 @@ do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
if (bPathNotEq && strcmp (current_panel->cwd, ".")) { if (bPathNotEq && strcmp (current_panel->cwd, ".")) {
char *cwd = strip_password (mhl_str_dup (current_panel->cwd), 1); char *cwd = strip_password (mhl_str_dup (current_panel->cwd), 1);
fprintf (stderr, _("Warning: Cannot change to %s.\n"), cwd); fprintf (stderr, _("Warning: Cannot change to %s.\n"), cwd);
mhl_mem_free (cwd); g_free (cwd);
} }
} }

View File

@ -33,8 +33,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <mhl/memory.h>
#include "global.h" #include "global.h"
#include "tty.h" #include "tty.h"
#include "color.h" #include "color.h"
@ -128,7 +126,7 @@ static void tree_destroy (WTree *tree)
tree_store_remove_entry_remove_hook (remove_callback); tree_store_remove_entry_remove_hook (remove_callback);
save_tree (tree); save_tree (tree);
mhl_mem_free (tree->tree_shown); g_free (tree->tree_shown);
tree->tree_shown = 0; tree->tree_shown = 0;
tree->selected_ptr = NULL; tree->selected_ptr = NULL;
} }
@ -208,7 +206,7 @@ static void show_tree (WTree *tree)
x = y = 1; x = y = 1;
} }
mhl_mem_free (tree->tree_shown); g_free (tree->tree_shown);
tree->tree_shown = g_new (tree_entry*, tree_lines); tree->tree_shown = g_new (tree_entry*, tree_lines);
for (i = 0; i < tree_lines; i++) for (i = 0; i < tree_lines; i++)
@ -607,7 +605,7 @@ static void tree_copy (WTree *tree, const char *default_dest)
return; return;
if (!*dest){ if (!*dest){
mhl_mem_free (dest); g_free (dest);
return; return;
} }
@ -616,7 +614,7 @@ static void tree_copy (WTree *tree, const char *default_dest)
copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes); copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes);
file_op_context_destroy (ctx); file_op_context_destroy (ctx);
mhl_mem_free (dest); g_free (dest);
} }
static void static void
@ -648,19 +646,19 @@ static void tree_move (WTree *tree, const char *default_dest)
if (!dest) if (!dest)
return; return;
if (!*dest){ if (!*dest){
mhl_mem_free (dest); g_free (dest);
return; return;
} }
if (stat (dest, &buf)){ if (stat (dest, &buf)){
message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "), message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "),
unix_error_string (errno)); unix_error_string (errno));
mhl_mem_free (dest); g_free (dest);
return; return;
} }
if (!S_ISDIR (buf.st_mode)){ if (!S_ISDIR (buf.st_mode)){
file_error (_(" Destination \"%s\" must be a directory \n %s "), file_error (_(" Destination \"%s\" must be a directory \n %s "),
dest); dest);
mhl_mem_free (dest); g_free (dest);
return; return;
} }
@ -669,7 +667,7 @@ static void tree_move (WTree *tree, const char *default_dest)
move_dir_dir (ctx, tree->selected_ptr->name, dest, &count, &bytes); move_dir_dir (ctx, tree->selected_ptr->name, dest, &count, &bytes);
file_op_context_destroy (ctx); file_op_context_destroy (ctx);
mhl_mem_free (dest); g_free (dest);
} }
static void static void
@ -718,7 +716,7 @@ tree_rmdir_cmd (WTree *tree)
tree->selected_ptr->name); tree->selected_ptr->name);
result = result =
query_dialog (_(" Delete "), buf, D_ERROR, 2, _("&Yes"), _("&No")); query_dialog (_(" Delete "), buf, D_ERROR, 2, _("&Yes"), _("&No"));
mhl_mem_free (buf); g_free (buf);
if (result != 0) if (result != 0)
return; return;
} }

View File

@ -239,7 +239,7 @@ tree_store_load_from(char *name)
} }
strcpy(oldname, name); strcpy(oldname, name);
} }
mhl_mem_free(name); g_free(name);
} }
fclose(file); fclose(file);
} }
@ -270,7 +270,7 @@ tree_store_load(void)
name = mhl_str_dir_plus_file(home_dir, MC_TREE); name = mhl_str_dir_plus_file(home_dir, MC_TREE);
retval = tree_store_load_from(name); retval = tree_store_load_from(name);
mhl_mem_free(name); g_free(name);
return retval; return retval;
} }
@ -337,12 +337,12 @@ tree_store_save_to(char *name)
i = fprintf(file, "%d:%d %s\n", current->scanned, common, i = fprintf(file, "%d:%d %s\n", current->scanned, common,
encoded); encoded);
mhl_mem_free(encoded); g_free(encoded);
} else { } else {
char *encoded = encode(current->name); char *encoded = encode(current->name);
i = fprintf(file, "%d:%s\n", current->scanned, encoded); i = fprintf(file, "%d:%s\n", current->scanned, encoded);
mhl_mem_free(encoded); g_free(encoded);
} }
if (i == EOF) { if (i == EOF) {
@ -378,15 +378,15 @@ tree_store_save(void)
retval = tree_store_save_to(tmp); retval = tree_store_save_to(tmp);
if (retval) { if (retval) {
mhl_mem_free(tmp); g_free(tmp);
return retval; return retval;
} }
name = mhl_str_dir_plus_file(home_dir, MC_TREE); name = mhl_str_dir_plus_file(home_dir, MC_TREE);
retval = rename(tmp, name); retval = rename(tmp, name);
mhl_mem_free(tmp); g_free(tmp);
mhl_mem_free(name); g_free(name);
if (retval) if (retval)
return errno; return errno;
@ -484,7 +484,7 @@ tree_store_add_entry(const char *name)
break; break;
} }
} }
mhl_mem_free(parent); g_free(parent);
} }
tree_store_dirty(TRUE); tree_store_dirty(TRUE);
@ -549,8 +549,8 @@ remove_entry(tree_entry * entry)
ts.tree_last = entry->prev; ts.tree_last = entry->prev;
/* Free the memory used by the entry */ /* Free the memory used by the entry */
mhl_mem_free(entry->name); g_free(entry->name);
mhl_mem_free(entry); g_free(entry);
return ret; return ret;
} }
@ -620,7 +620,7 @@ tree_store_mark_checked(const char *subname)
current = tree_store_add_entry(name); current = tree_store_add_entry(name);
ts.add_queue = g_list_prepend(ts.add_queue, mhl_str_dup(name)); ts.add_queue = g_list_prepend(ts.add_queue, mhl_str_dup(name));
} }
mhl_mem_free(name); g_free(name);
/* Clear the deletion mark from the subdirectory and its children */ /* Clear the deletion mark from the subdirectory and its children */
base = current; base = current;
@ -719,11 +719,11 @@ tree_store_end_check(void)
ts.add_queue = g_list_reverse(ts.add_queue); ts.add_queue = g_list_reverse(ts.add_queue);
the_queue = ts.add_queue; the_queue = ts.add_queue;
ts.add_queue = NULL; ts.add_queue = NULL;
mhl_mem_free(ts.check_name); g_free(ts.check_name);
ts.check_name = NULL; ts.check_name = NULL;
for (l = the_queue; l; l = l->next) { for (l = the_queue; l; l = l->next) {
mhl_mem_free(l->data); g_free(l->data);
} }
g_list_free(the_queue); g_list_free(the_queue);
@ -743,7 +743,7 @@ process_special_dirs(GList ** special_dirs, char *file)
*special_dirs = g_list_prepend(*special_dirs, mhl_str_dup(token)); *special_dirs = g_list_prepend(*special_dirs, mhl_str_dup(token));
s = NULL; s = NULL;
} }
mhl_mem_free(buffer); g_free(buffer);
} }
static bool static bool
@ -803,7 +803,7 @@ tree_store_rescan(const char *dir)
if (S_ISDIR(buf.st_mode)) if (S_ISDIR(buf.st_mode))
tree_store_mark_checked(dp->d_name); tree_store_mark_checked(dp->d_name);
} }
mhl_mem_free(full_name); g_free(full_name);
} }
mc_closedir(dirp); mc_closedir(dirp);
} }

View File

@ -145,7 +145,7 @@ int check_format_var (const char *p, char **v)
var_name = g_strndup (p + 4, dots-2 - (p+3)); var_name = g_strndup (p + 4, dots-2 - (p+3));
value = getenv (var_name); value = getenv (var_name);
mhl_mem_free (var_name); g_free (var_name);
if (value){ if (value){
*v = mhl_str_dup (value); *v = mhl_str_dup (value);
return q-p; return q-p;
@ -224,7 +224,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
qstr = (*quote_func) (cwd, 0); qstr = (*quote_func) (cwd, 0);
mhl_mem_free (cwd); g_free (cwd);
return qstr; return qstr;
} }
@ -241,7 +241,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
if (edit_widget) { if (edit_widget) {
char *file = g_strconcat (home_dir, PATH_SEP_STR BLOCK_FILE, (char *) NULL); char *file = g_strconcat (home_dir, PATH_SEP_STR BLOCK_FILE, (char *) NULL);
fname = (*quote_func) (file, 0); fname = (*quote_func) (file, 0);
mhl_mem_free (file); g_free (file);
return fname; return fname;
} else if (c_lc == 'b') { } else if (c_lc == 'b') {
return strip_ext ((*quote_func) (fname, 0)); return strip_ext ((*quote_func) (fname, 0));
@ -281,7 +281,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
if (panel->dir.list[i].f.marked) { if (panel->dir.list[i].f.marked) {
strcat (block, tmp = strcat (block, tmp =
(*quote_func) (panel->dir.list[i].fname, 0)); (*quote_func) (panel->dir.list[i].fname, 0));
mhl_mem_free (tmp); g_free (tmp);
strcat (block, " "); strcat (block, " ");
if (c_lc == 'u') if (c_lc == 'u')
do_file_mark (panel, i, 0); do_file_mark (panel, i, 0);
@ -471,7 +471,7 @@ debug_out (char *start, char *end, int cond)
} }
debug_flag = 0; debug_flag = 0;
mhl_mem_free (msg); g_free (msg);
msg = NULL; msg = NULL;
} else { } else {
const char *type; const char *type;
@ -495,7 +495,7 @@ debug_out (char *start, char *end, int cond)
else else
p = g_strdup_printf ("%s%s%.*s \n", msg ? msg : "", type, p = g_strdup_printf ("%s%s%.*s \n", msg ? msg : "", type,
(int) (end - start), start); (int) (end - start), start);
mhl_mem_free (msg); g_free (msg);
msg = p; msg = p;
} }
} }
@ -613,15 +613,15 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
/* User canceled */ /* User canceled */
fclose (cmd_file); fclose (cmd_file);
unlink (file_name); unlink (file_name);
mhl_mem_free (file_name); g_free (file_name);
return; return;
} }
if (do_quote) { if (do_quote) {
fputs (tmp = name_quote (parameter, 0), cmd_file); fputs (tmp = name_quote (parameter, 0), cmd_file);
mhl_mem_free (tmp); g_free (tmp);
} else } else
fputs (parameter, cmd_file); fputs (parameter, cmd_file);
mhl_mem_free (parameter); g_free (parameter);
parameter = 0; parameter = 0;
} else { } else {
if (parameter < &prompt [sizeof (prompt) - 1]) { if (parameter < &prompt [sizeof (prompt) - 1]) {
@ -640,7 +640,7 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
else{ else{
char *text = expand_format (edit_widget, *commands, do_quote); char *text = expand_format (edit_widget, *commands, do_quote);
fputs (text, cmd_file); fputs (text, cmd_file);
mhl_mem_free (text); g_free (text);
} }
} else { } else {
if (*commands == '%') { if (*commands == '%') {
@ -666,10 +666,10 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
* on no-exec filesystems. */ * on no-exec filesystems. */
char *cmd = g_strconcat("/bin/sh ", file_name, (char *)NULL); char *cmd = g_strconcat("/bin/sh ", file_name, (char *)NULL);
shell_execute (cmd, EXECUTE_HIDE); shell_execute (cmd, EXECUTE_HIDE);
mhl_mem_free(cmd); g_free(cmd);
} }
unlink (file_name); unlink (file_name);
mhl_mem_free (file_name); g_free (file_name);
} }
/* /*
@ -723,11 +723,11 @@ user_menu_cmd (struct WEdit *edit_widget)
menu = mhl_str_dup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU); menu = mhl_str_dup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
if (!exist_file (menu) || !menu_file_own (menu)){ if (!exist_file (menu) || !menu_file_own (menu)){
mhl_mem_free (menu); g_free (menu);
menu = mhl_str_dir_plus_file \ menu = mhl_str_dir_plus_file \
(home_dir, edit_widget ? CEDIT_HOME_MENU : MC_HOME_MENU); (home_dir, edit_widget ? CEDIT_HOME_MENU : MC_HOME_MENU);
if (!exist_file (menu)){ if (!exist_file (menu)){
mhl_mem_free (menu); g_free (menu);
menu = mhl_str_dir_plus_file \ menu = mhl_str_dir_plus_file \
(mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
} }
@ -736,7 +736,7 @@ user_menu_cmd (struct WEdit *edit_widget)
if ((data = load_file (menu)) == NULL){ if ((data = load_file (menu)) == NULL){
message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "), message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "),
menu, unix_error_string (errno)); menu, unix_error_string (errno));
mhl_mem_free (menu); g_free (menu);
menu = NULL; menu = NULL;
return; return;
} }
@ -841,9 +841,9 @@ user_menu_cmd (struct WEdit *edit_widget)
} }
easy_patterns = old_patterns; easy_patterns = old_patterns;
mhl_mem_free (menu); g_free (menu);
menu = NULL; menu = NULL;
mhl_mem_free (entries); g_free (entries);
mhl_mem_free (data); g_free (data);
} }

View File

@ -271,7 +271,7 @@ path_trunc (const char *path, size_t trunc_len) {
char *secure_path = strip_password (mhl_str_dup (path), 1); char *secure_path = strip_password (mhl_str_dup (path), 1);
ret = name_trunc (secure_path, trunc_len); ret = name_trunc (secure_path, trunc_len);
mhl_mem_free (secure_path); g_free (secure_path);
return ret; return ret;
} }
@ -602,12 +602,12 @@ regexp_match (const char *pattern, const char *string, int match_type)
if (!old_pattern || STRCOMP (old_pattern, pattern) || old_type != match_type){ if (!old_pattern || STRCOMP (old_pattern, pattern) || old_type != match_type){
if (old_pattern){ if (old_pattern){
regfree (&r); regfree (&r);
mhl_mem_free (old_pattern); g_free (old_pattern);
old_pattern = NULL; old_pattern = NULL;
} }
my_pattern = convert_pattern (pattern, match_type, 0); my_pattern = convert_pattern (pattern, match_type, 0);
if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS)) { if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS)) {
mhl_mem_free (my_pattern); g_free (my_pattern);
return -1; return -1;
} }
old_pattern = my_pattern; old_pattern = my_pattern;
@ -682,7 +682,7 @@ load_file (const char *filename)
if (read_size > 0) if (read_size > 0)
return data; return data;
else { else {
mhl_mem_free (data); g_free (data);
return 0; return 0;
} }
} }
@ -701,7 +701,7 @@ load_mc_home_file (const char *filename, char **allocated_filename)
data = load_file (hintfile); data = load_file (hintfile);
if (!data) { if (!data) {
mhl_mem_free (hintfile); g_free (hintfile);
/* Fall back to the two-letter language code */ /* Fall back to the two-letter language code */
if (lang[0] && lang[1]) if (lang[0] && lang[1])
lang[2] = 0; lang[2] = 0;
@ -709,21 +709,21 @@ load_mc_home_file (const char *filename, char **allocated_filename)
data = load_file (hintfile); data = load_file (hintfile);
if (!data) { if (!data) {
mhl_mem_free (hintfile); g_free (hintfile);
hintfile = hintfile_base; hintfile = hintfile_base;
data = load_file (hintfile_base); data = load_file (hintfile_base);
} }
} }
mhl_mem_free (lang); g_free (lang);
if (hintfile != hintfile_base) if (hintfile != hintfile_base)
mhl_mem_free (hintfile_base); g_free (hintfile_base);
if (allocated_filename) if (allocated_filename)
*allocated_filename = hintfile; *allocated_filename = hintfile;
else else
mhl_mem_free (hintfile); g_free (hintfile);
return data; return data;
} }
@ -853,7 +853,7 @@ unix_error_string (int error_num)
strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, NULL, NULL, NULL); strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, NULL, NULL, NULL);
snprintf (buffer, sizeof (buffer), "%s (%d)", snprintf (buffer, sizeof (buffer), "%s (%d)",
strerror_currentlocale, error_num); strerror_currentlocale, error_num);
mhl_mem_free(strerror_currentlocale); g_free(strerror_currentlocale);
#else #else
snprintf (buffer, sizeof (buffer), "%s (%d)", snprintf (buffer, sizeof (buffer), "%s (%d)",
g_strerror (error_num), error_num); g_strerror (error_num), error_num);
@ -938,12 +938,12 @@ get_current_wd (char *buffer, int size)
len = strlen(p) + 1; len = strlen(p) + 1;
if (len > size) { if (len > size) {
mhl_mem_free (p); g_free (p);
return NULL; return NULL;
} }
memcpy (buffer, p, len); memcpy (buffer, p, len);
mhl_mem_free (p); g_free (p);
return buffer; return buffer;
} }
@ -1049,7 +1049,7 @@ execute_hooks (Hook *hook_list)
for (hook_list = p; hook_list;){ for (hook_list = p; hook_list;){
p = hook_list; p = hook_list;
hook_list = hook_list->next; hook_list = hook_list->next;
mhl_mem_free (p); g_free (p);
} }
} }
@ -1063,7 +1063,7 @@ delete_hook (Hook **hook_list, void (*hook_fn)(void *))
for (current = *hook_list; current; current = next){ for (current = *hook_list; current; current = next){
next = current->next; next = current->next;
if (current->hook_fn == hook_fn) if (current->hook_fn == hook_fn)
mhl_mem_free (current); g_free (current);
else else
add_hook (&new_list, current->hook_fn, current->hook_data); add_hook (&new_list, current->hook_fn, current->hook_data);
} }
@ -1090,7 +1090,7 @@ wipe_password (char *passwd)
return; return;
for (;*p ; p++) for (;*p ; p++)
*p = 0; *p = 0;
mhl_mem_free (passwd); g_free (passwd);
} }
/* Convert "\E" -> esc character and ^x to control-x key and ^^ to ^ key */ /* Convert "\E" -> esc character and ^x to control-x key and ^^ to ^ key */
@ -1155,8 +1155,8 @@ resolve_symlinks (const char *path)
c = *q; c = *q;
*q = 0; *q = 0;
if (mc_lstat (path, &mybuf) < 0) { if (mc_lstat (path, &mybuf) < 0) {
mhl_mem_free (buf); g_free (buf);
mhl_mem_free (buf2); g_free (buf2);
*q = c; *q = c;
return NULL; return NULL;
} }
@ -1165,8 +1165,8 @@ resolve_symlinks (const char *path)
else { else {
len = mc_readlink (path, buf2, MC_MAXPATHLEN - 1); len = mc_readlink (path, buf2, MC_MAXPATHLEN - 1);
if (len < 0) { if (len < 0) {
mhl_mem_free (buf); g_free (buf);
mhl_mem_free (buf2); g_free (buf2);
*q = c; *q = c;
return NULL; return NULL;
} }
@ -1191,7 +1191,7 @@ resolve_symlinks (const char *path)
strcpy (buf, PATH_SEP_STR); strcpy (buf, PATH_SEP_STR);
else if (*(r - 1) == PATH_SEP && r != buf + 1) else if (*(r - 1) == PATH_SEP && r != buf + 1)
*(r - 1) = 0; *(r - 1) = 0;
mhl_mem_free (buf2); g_free (buf2);
return buf; return buf;
} }
@ -1209,7 +1209,7 @@ diff_two_paths (const char *first, const char *second)
return NULL; return NULL;
my_second = resolve_symlinks (second); my_second = resolve_symlinks (second);
if (my_second == NULL) { if (my_second == NULL) {
mhl_mem_free (my_first); g_free (my_first);
return NULL; return NULL;
} }
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
@ -1235,10 +1235,10 @@ diff_two_paths (const char *first, const char *second)
currlen = (i + 1) * 3 + strlen (q) + 1; currlen = (i + 1) * 3 + strlen (q) + 1;
if (j) { if (j) {
if (currlen < prevlen) if (currlen < prevlen)
mhl_mem_free (buf); g_free (buf);
else { else {
mhl_mem_free (my_first); g_free (my_first);
mhl_mem_free (my_second); g_free (my_second);
return buf; return buf;
} }
} }
@ -1248,8 +1248,8 @@ diff_two_paths (const char *first, const char *second)
strcpy (p, "../"); strcpy (p, "../");
strcpy (p, q); strcpy (p, q);
} }
mhl_mem_free (my_first); g_free (my_first);
mhl_mem_free (my_second); g_free (my_second);
return buf; return buf;
} }
@ -1271,7 +1271,7 @@ list_append_unique (GList *list, char *text)
while (link) { while (link) {
newlink = g_list_previous (link); newlink = g_list_previous (link);
if (!strcmp ((char *) link->data, text)) { if (!strcmp ((char *) link->data, text)) {
mhl_mem_free (link->data); g_free (link->data);
g_list_remove_link (list, link); g_list_remove_link (list, link);
g_list_free_1 (link); g_list_free_1 (link);
} }
@ -1290,7 +1290,7 @@ list_append_unique (GList *list, char *text)
/* /*
* Arguments: * Arguments:
* pname (output) - pointer to the name of the temp file (needs mhl_mem_free). * pname (output) - pointer to the name of the temp file (needs g_free).
* NULL if the function fails. * NULL if the function fails.
* prefix - part of the filename before the random part. * prefix - part of the filename before the random part.
* Prepend $TMPDIR or /tmp if there are no path separators. * Prepend $TMPDIR or /tmp if there are no path separators.
@ -1321,7 +1321,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, (char *) NULL); tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, (char *) NULL);
*pname = tmpname; *pname = tmpname;
XXXXXX = &tmpname[strlen (tmpbase)]; XXXXXX = &tmpname[strlen (tmpbase)];
mhl_mem_free (tmpbase); g_free (tmpbase);
/* Get some more or less random data. */ /* Get some more or less random data. */
gettimeofday (&tv, NULL); gettimeofday (&tv, NULL);
@ -1358,7 +1358,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
} }
/* Unsuccessful. Free the filename. */ /* Unsuccessful. Free the filename. */
mhl_mem_free (tmpname); g_free (tmpname);
*pname = NULL; *pname = NULL;
return -1; return -1;
@ -1383,7 +1383,7 @@ load_file_position (const char *filename, long *line, long *column)
/* open file with positions */ /* open file with positions */
fn = mhl_str_dir_plus_file (home_dir, MC_FILEPOS); fn = mhl_str_dir_plus_file (home_dir, MC_FILEPOS);
f = fopen (fn, "r"); f = fopen (fn, "r");
mhl_mem_free (fn); g_free (fn);
if (!f) if (!f)
return; return;
@ -1434,8 +1434,8 @@ save_file_position (const char *filename, long line, long column)
/* open temporary file */ /* open temporary file */
t = fopen (tmp, "w"); t = fopen (tmp, "w");
if (!t) { if (!t) {
mhl_mem_free (tmp); g_free (tmp);
mhl_mem_free (fn); g_free (fn);
return; return;
} }
@ -1462,8 +1462,8 @@ save_file_position (const char *filename, long line, long column)
fclose (t); fclose (t);
rename (tmp, fn); rename (tmp, fn);
mhl_mem_free (tmp); g_free (tmp);
mhl_mem_free (fn); g_free (fn);
} }
extern const char * extern const char *

View File

@ -75,7 +75,7 @@ static char *i_cache_match (int id, int_cache *cache, int size)
static void i_cache_add (int id, int_cache *cache, int size, char *text, static void i_cache_add (int id, int_cache *cache, int size, char *text,
int *last) int *last)
{ {
mhl_mem_free (cache [*last].string); g_free (cache [*last].string);
cache [*last].string = mhl_str_dup (text); cache [*last].string = mhl_str_dup (text);
cache [*last].index = id; cache [*last].index = id;
*last = ((*last)+1) % size; *last = ((*last)+1) % size;
@ -206,7 +206,7 @@ tilde_expand (const char *directory)
name = g_strndup (p, q - p); name = g_strndup (p, q - p);
passwd = getpwnam (name); passwd = getpwnam (name);
q++; q++;
mhl_mem_free (name); g_free (name);
} }
} }
@ -296,7 +296,7 @@ mc_tmpdir (void)
/* Test if sys_tmp is suitable for temporary files */ /* Test if sys_tmp is suitable for temporary files */
fallback_prefix = g_strdup_printf ("%s/mctest", sys_tmp); fallback_prefix = g_strdup_printf ("%s/mctest", sys_tmp);
test_fd = mc_mkstemps (&test_fn, fallback_prefix, NULL); test_fd = mc_mkstemps (&test_fn, fallback_prefix, NULL);
mhl_mem_free (fallback_prefix); g_free (fallback_prefix);
if (test_fd != -1) { if (test_fd != -1) {
close (test_fd); close (test_fd);
test_fd = open (test_fn, O_RDONLY); test_fd = open (test_fn, O_RDONLY);

View File

@ -349,7 +349,7 @@ view_hexedit_free_change_list (WView *view)
for (curr = view->change_list; curr != NULL; curr = next) { for (curr = view->change_list; curr != NULL; curr = next) {
next = curr->next; next = curr->next;
mhl_mem_free (curr); g_free (curr);
} }
view->change_list = NULL; view->change_list = NULL;
view->dirty++; view->dirty++;
@ -375,8 +375,8 @@ view_growbuf_free (WView *view)
assert (view->growbuf_in_use); assert (view->growbuf_in_use);
for (i = 0; i < view->growbuf_blocks; i++) for (i = 0; i < view->growbuf_blocks; i++)
mhl_mem_free (view->growbuf_blockptr[i]); g_free (view->growbuf_blockptr[i]);
mhl_mem_free (view->growbuf_blockptr); g_free (view->growbuf_blockptr);
view->growbuf_blockptr = NULL; view->growbuf_blockptr = NULL;
view->growbuf_in_use = FALSE; view->growbuf_in_use = FALSE;
} }
@ -416,12 +416,12 @@ view_growbuf_read_until (WView *view, offset_type ofs)
byte *newblock = g_try_malloc (VIEW_PAGE_SIZE); byte *newblock = g_try_malloc (VIEW_PAGE_SIZE);
byte **newblocks = g_try_malloc (sizeof (*newblocks) * (view->growbuf_blocks + 1)); byte **newblocks = g_try_malloc (sizeof (*newblocks) * (view->growbuf_blocks + 1));
if (!newblock || !newblocks) { if (!newblock || !newblocks) {
mhl_mem_free (newblock); g_free (newblock);
mhl_mem_free (newblocks); g_free (newblocks);
return; return;
} }
memcpy (newblocks, view->growbuf_blockptr, sizeof (*newblocks) * view->growbuf_blocks); memcpy (newblocks, view->growbuf_blockptr, sizeof (*newblocks) * view->growbuf_blocks);
mhl_mem_free (view->growbuf_blockptr); g_free (view->growbuf_blockptr);
view->growbuf_blockptr = newblocks; view->growbuf_blockptr = newblocks;
view->growbuf_blockptr[view->growbuf_blocks++] = newblock; view->growbuf_blockptr[view->growbuf_blocks++] = newblock;
view->growbuf_lastindex = 0; view->growbuf_lastindex = 0;
@ -708,11 +708,11 @@ view_close_datasource (WView *view)
case DS_FILE: case DS_FILE:
(void) mc_close (view->ds_file_fd); (void) mc_close (view->ds_file_fd);
view->ds_file_fd = -1; view->ds_file_fd = -1;
mhl_mem_free (view->ds_file_data); g_free (view->ds_file_data);
view->ds_file_data = NULL; view->ds_file_data = NULL;
break; break;
case DS_STRING: case DS_STRING:
mhl_mem_free (view->ds_string_data); g_free (view->ds_string_data);
view->ds_string_data = NULL; view->ds_string_data = NULL;
break; break;
default: default:
@ -1400,8 +1400,8 @@ view_toggle_magic_mode (WView *view)
view_done (view); view_done (view);
view_load (view, command, filename, 0); view_load (view, command, filename, 0);
mhl_mem_free (filename); g_free (filename);
mhl_mem_free (command); g_free (command);
view->dpy_bbar_dirty = TRUE; view->dpy_bbar_dirty = TRUE;
view->dirty++; view->dirty++;
} }
@ -1419,7 +1419,7 @@ view_done (WView *view)
canon_fname = vfs_canon (view->filename); canon_fname = vfs_canon (view->filename);
view_offset_to_coord (view, &line, &col, view->dpy_start); view_offset_to_coord (view, &line, &col, view->dpy_start);
save_file_position (canon_fname, line + 1, col); save_file_position (canon_fname, line + 1, col);
mhl_mem_free (canon_fname); g_free (canon_fname);
} }
/* Write back the global viewer mode */ /* Write back the global viewer mode */
@ -1432,8 +1432,8 @@ view_done (WView *view)
/* view->widget needs no destructor */ /* view->widget needs no destructor */
mhl_mem_free (view->filename), view->filename = NULL; g_free (view->filename), view->filename = NULL;
mhl_mem_free (view->command), view->command = NULL; g_free (view->command), view->command = NULL;
view_close_datasource (view); view_close_datasource (view);
/* the growing buffer is freed with the datasource */ /* the growing buffer is freed with the datasource */
@ -1547,7 +1547,7 @@ view_load (WView *view, const char *command, const char *file,
type = get_compression_type (fd); type = get_compression_type (fd);
if (view->magic_mode && (type != COMPRESSION_NONE)) { if (view->magic_mode && (type != COMPRESSION_NONE)) {
mhl_mem_free (view->filename); g_free (view->filename);
view->filename = g_strconcat (file, decompress_extension (type), (char *) NULL); view->filename = g_strconcat (file, decompress_extension (type), (char *) NULL);
} }
view_set_datasource_file (view, fd, &st); view_set_datasource_file (view, fd, &st);
@ -1570,7 +1570,7 @@ view_load (WView *view, const char *command, const char *file,
canon_fname = vfs_canon (file); canon_fname = vfs_canon (file);
load_file_position (file, &line, &col); load_file_position (file, &line, &col);
mhl_mem_free (canon_fname); g_free (canon_fname);
view_moveto (view, offset_doz(line, 1), col); view_moveto (view, offset_doz(line, 1), col);
} else if (start_line > 0) { } else if (start_line > 0) {
view_moveto (view, start_line - 1, 0); view_moveto (view, start_line - 1, 0);
@ -2166,7 +2166,7 @@ view_hexedit_save_changes (WView *view)
view->change_list = next; view->change_list = next;
view->dirty++; view->dirty++;
view_set_byte (view, curr->offset, curr->value); view_set_byte (view, curr->offset, curr->value);
mhl_mem_free (curr); g_free (curr);
} }
if (mc_close (fp) == -1) { if (mc_close (fp) == -1) {
@ -2174,7 +2174,7 @@ view_hexedit_save_changes (WView *view)
message (D_ERROR, _(" Save file "), message (D_ERROR, _(" Save file "),
_(" Error while closing the file: \n %s \n" _(" Error while closing the file: \n %s \n"
" Data may have been written or not. "), error); " Data may have been written or not. "), error);
mhl_mem_free (error); g_free (error);
} }
view_update (view); view_update (view);
return TRUE; return TRUE;
@ -2182,12 +2182,12 @@ view_hexedit_save_changes (WView *view)
save_error: save_error:
error = mhl_str_dup (strerror (errno)); error = mhl_str_dup (strerror (errno));
text = g_strdup_printf (_(" Cannot save file: \n %s "), error); text = g_strdup_printf (_(" Cannot save file: \n %s "), error);
mhl_mem_free (error); g_free (error);
(void) mc_close (fp); (void) mc_close (fp);
answer = query_dialog (_(" Save file "), text, D_ERROR, answer = query_dialog (_(" Save file "), text, D_ERROR,
2, _("&Retry"), _("&Cancel")); 2, _("&Retry"), _("&Cancel"));
mhl_mem_free (text); g_free (text);
if (answer == 0) if (answer == 0)
goto retry_save; goto retry_save;
@ -2392,7 +2392,7 @@ search (WView *view, char *text,
view->update_activate = 0; view->update_activate = 0;
enable_interrupt_key (); enable_interrupt_key ();
for (;; mhl_mem_free (s)) { for (;; g_free (s)) {
if (p >= view->update_activate) { if (p >= view->update_activate) {
view->update_activate += view->update_steps; view->update_activate += view->update_steps;
if (verbose) { if (verbose) {
@ -2411,7 +2411,7 @@ search (WView *view, char *text,
search_status = (*search) (view, text, s + 1, match_normal); search_status = (*search) (view, text, s + 1, match_normal);
if (search_status < 0) { if (search_status < 0) {
mhl_mem_free (s); g_free (s);
break; break;
} }
@ -2439,7 +2439,7 @@ search (WView *view, char *text,
view->dpy_start = t; view->dpy_start = t;
} }
mhl_mem_free (s); g_free (s);
break; break;
} }
disable_interrupt_key (); disable_interrupt_key ();
@ -2600,7 +2600,7 @@ hex_search (WView *view, const char *text)
/* No valid bytes in the user input */ /* No valid bytes in the user input */
if (block_len <= 0 || parse_error) { if (block_len <= 0 || parse_error) {
message (D_NORMAL, _("Search"), _("Invalid hex search expression")); message (D_NORMAL, _("Search"), _("Invalid hex search expression"));
mhl_mem_free (buffer); g_free (buffer);
view->search_length = 0; view->search_length = 0;
return; return;
} }
@ -2608,7 +2608,7 @@ hex_search (WView *view, const char *text)
/* Then start the search */ /* Then start the search */
pos = block_search (view, buffer, block_len); pos = block_search (view, buffer, block_len);
mhl_mem_free (buffer); g_free (buffer);
if (pos == INVALID_OFFSET) { if (pos == INVALID_OFFSET) {
message (D_NORMAL, _("Search"), _(" Search string not found ")); message (D_NORMAL, _("Search"), _(" Search string not found "));
@ -2640,7 +2640,7 @@ regexp_view_search (WView *view, char *pattern, char *string,
|| old_type != match_type) { || old_type != match_type) {
if (old_pattern != NULL) { if (old_pattern != NULL) {
regfree (&r); regfree (&r);
mhl_mem_free (old_pattern); g_free (old_pattern);
old_pattern = 0; old_pattern = 0;
} }
for (i = 0; pattern[i] != '\0'; i++) { for (i = 0; pattern[i] != '\0'; i++) {
@ -2744,7 +2744,7 @@ view_moveto_line_cmd (WView *view)
if (*answer_end == '\0' && errno == 0 && line >= 1) if (*answer_end == '\0' && errno == 0 && line >= 1)
view_moveto (view, line - 1, 0); view_moveto (view, line - 1, 0);
} }
mhl_mem_free (answer); g_free (answer);
view->dirty++; view->dirty++;
view_update (view); view_update (view);
} }
@ -2768,7 +2768,7 @@ view_moveto_addr_cmd (WView *view)
message (D_ERROR, _("Warning"), _(" Invalid address ")); message (D_ERROR, _("Warning"), _(" Invalid address "));
} }
} }
mhl_mem_free (line); g_free (line);
} }
view->dirty++; view->dirty++;
view_update (view); view_update (view);
@ -2793,11 +2793,11 @@ regexp_search (WView *view, int direction)
regexp = input_dialog (_("Search"), _(" Enter regexp:"), MC_HISTORY_VIEW_SEARCH_REGEX, defval); regexp = input_dialog (_("Search"), _(" Enter regexp:"), MC_HISTORY_VIEW_SEARCH_REGEX, defval);
if (regexp == NULL || regexp[0] == '\0') { if (regexp == NULL || regexp[0] == '\0') {
mhl_mem_free (regexp); g_free (regexp);
return; return;
} }
mhl_mem_free (last_regexp); g_free (last_regexp);
view->search_exp = last_regexp = regexp; view->search_exp = last_regexp = regexp;
view->direction = direction; view->direction = direction;
@ -2866,7 +2866,7 @@ view_normal_search_cmd (WView *view)
convert_from_input (exp); convert_from_input (exp);
mhl_mem_free (last_search_string); g_free (last_search_string);
view->search_exp = last_search_string = exp; view->search_exp = last_search_string = exp;
exp = NULL; exp = NULL;
@ -2875,8 +2875,8 @@ view_normal_search_cmd (WView *view)
view->last_search = do_normal_search; view->last_search = do_normal_search;
cleanup: cleanup:
mhl_mem_free (exp); g_free (exp);
mhl_mem_free (defval); g_free (defval);
} }
static void static void

View File

@ -190,7 +190,7 @@ button_callback (Widget *w, widget_msg_t msg, int parm)
return MSG_HANDLED; return MSG_HANDLED;
case WIDGET_DESTROY: case WIDGET_DESTROY:
mhl_mem_free (b->text); g_free (b->text);
return MSG_HANDLED; return MSG_HANDLED;
default: default:
@ -283,7 +283,7 @@ button_get_text (WButton *b)
void void
button_set_text (WButton *b, const char *text) button_set_text (WButton *b, const char *text)
{ {
mhl_mem_free (b->text); g_free (b->text);
b->text = mhl_str_dup (text); b->text = mhl_str_dup (text);
b->widget.cols = button_len (text, b->flags); b->widget.cols = button_len (text, b->flags);
button_scan_hotkey(b); button_scan_hotkey(b);
@ -476,7 +476,7 @@ check_callback (Widget *w, widget_msg_t msg, int parm)
return MSG_HANDLED; return MSG_HANDLED;
case WIDGET_DESTROY: case WIDGET_DESTROY:
mhl_mem_free (c->text); g_free (c->text);
return MSG_HANDLED; return MSG_HANDLED;
default: default:
@ -588,7 +588,7 @@ label_callback (Widget *w, widget_msg_t msg, int parm)
} }
case WIDGET_DESTROY: case WIDGET_DESTROY:
mhl_mem_free (l->text); g_free (l->text);
return MSG_HANDLED; return MSG_HANDLED;
default: default:
@ -604,7 +604,7 @@ label_set_text (WLabel *label, const char *text)
if (label->text && text && !strcmp (label->text, text)) if (label->text && text && !strcmp (label->text, text))
return; /* Flickering is not nice */ return; /* Flickering is not nice */
mhl_mem_free (label->text); g_free (label->text);
if (text){ if (text){
label->text = mhl_str_dup (text); label->text = mhl_str_dup (text);
@ -880,7 +880,7 @@ history_get (const char *input_name)
hist = list_append_unique (hist, mhl_str_dup (this_entry)); hist = list_append_unique (hist, mhl_str_dup (this_entry));
} }
mhl_mem_free (profile); g_free (profile);
/* return pointer to the last entry in the list */ /* return pointer to the last entry in the list */
hist = g_list_last (hist); hist = g_list_last (hist);
@ -913,7 +913,7 @@ history_put (const char *input_name, GList *h)
/* Make sure the history is only readable by the user */ /* Make sure the history is only readable by the user */
if (chmod (profile, S_IRUSR | S_IWUSR) == -1 && errno != ENOENT) { if (chmod (profile, S_IRUSR | S_IWUSR) == -1 && errno != ENOENT) {
mhl_mem_free (profile); g_free (profile);
return; return;
} }
@ -942,7 +942,7 @@ history_put (const char *input_name, GList *h)
} }
} }
mhl_mem_free (profile); g_free (profile);
} }
/* }}} history saving and loading */ /* }}} history saving and loading */
@ -1053,7 +1053,7 @@ static void do_show_hist (WInput * in)
r = show_hist (in->history, in->widget.x, in->widget.y); r = show_hist (in->history, in->widget.x, in->widget.y);
if (r) { if (r) {
assign_text (in, r); assign_text (in, r);
mhl_mem_free (r); g_free (r);
} }
} }
@ -1074,13 +1074,13 @@ input_destroy (WInput *in)
history_put (in->history_name, in->history); history_put (in->history_name, in->history);
in->history = g_list_first (in->history); in->history = g_list_first (in->history);
g_list_foreach (in->history, (GFunc) mhl_mem_free, NULL); g_list_foreach (in->history, (GFunc) g_free, NULL);
g_list_free (in->history); g_list_free (in->history);
} }
mhl_mem_free (in->buffer); g_free (in->buffer);
free_completions (in); free_completions (in);
mhl_mem_free (in->history_name); g_free (in->history_name);
} }
void void
@ -1301,7 +1301,7 @@ copy_region (WInput *in, int x_first, int x_last)
if (last == first) if (last == first)
return; return;
mhl_mem_free (kill_buffer); g_free (kill_buffer);
kill_buffer = g_strndup(in->buffer+first,last-first); kill_buffer = g_strndup(in->buffer+first,last-first);
} }
@ -1382,7 +1382,7 @@ yank (WInput *in)
static void static void
kill_line (WInput *in) kill_line (WInput *in)
{ {
mhl_mem_free (kill_buffer); g_free (kill_buffer);
kill_buffer = mhl_str_dup (&in->buffer [in->point]); kill_buffer = mhl_str_dup (&in->buffer [in->point]);
in->buffer [in->point] = 0; in->buffer [in->point] = 0;
} }
@ -1391,7 +1391,7 @@ void
assign_text (WInput *in, const char *text) assign_text (WInput *in, const char *text)
{ {
free_completions (in); free_completions (in);
mhl_mem_free (in->buffer); g_free (in->buffer);
in->buffer = mhl_str_dup (text); /* was in->buffer->text */ in->buffer = mhl_str_dup (text); /* was in->buffer->text */
in->current_max_len = strlen (in->buffer) + 1; in->current_max_len = strlen (in->buffer) + 1;
in->point = strlen (in->buffer); in->point = strlen (in->buffer);
@ -1857,8 +1857,8 @@ listbox_remove_list (WListbox *l)
while (l->count--) { while (l->count--) {
q = p->next; q = p->next;
mhl_mem_free (p->text); g_free (p->text);
mhl_mem_free (p); g_free (p);
p = q; p = q;
} }
l->pos = l->count = 0; l->pos = l->count = 0;
@ -1899,8 +1899,8 @@ listbox_remove_current (WListbox *l, int force)
l->list = l->top = l->current = 0; l->list = l->top = l->current = 0;
} }
mhl_mem_free (p->text); g_free (p->text);
mhl_mem_free (p); g_free (p);
} }
/* Makes *e the selected entry (sets current and pos) */ /* Makes *e the selected entry (sets current and pos) */
@ -2022,8 +2022,8 @@ listbox_destroy (WListbox *l)
for (i = 0; i < l->count; i++){ for (i = 0; i < l->count; i++){
n = p->next; n = p->next;
mhl_mem_free (p->text); g_free (p->text);
mhl_mem_free (p); g_free (p);
p = n; p = n;
} }
} }
@ -2338,7 +2338,7 @@ buttonbar_callback (Widget *w, widget_msg_t msg, int parm)
case WIDGET_DESTROY: case WIDGET_DESTROY:
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
mhl_mem_free (bb->labels[i].text); g_free (bb->labels[i].text);
return MSG_HANDLED; return MSG_HANDLED;
default: default:
@ -2385,7 +2385,7 @@ buttonbar_new (int visible)
static void static void
set_label_text (WButtonBar * bb, int index, const char *text) set_label_text (WButtonBar * bb, int index, const char *text)
{ {
mhl_mem_free (bb->labels[index - 1].text); g_free (bb->labels[index - 1].text);
bb->labels[index - 1].text = mhl_str_dup (text); bb->labels[index - 1].text = mhl_str_dup (text);
} }
@ -2484,7 +2484,7 @@ groupbox_callback (Widget *w, widget_msg_t msg, int parm)
return MSG_HANDLED; return MSG_HANDLED;
case WIDGET_DESTROY: case WIDGET_DESTROY:
mhl_mem_free (g->title); g_free (g->title);
return MSG_HANDLED; return MSG_HANDLED;
default: default:
@ -2507,7 +2507,7 @@ groupbox_new (int x, int y, int width, int height, const char *title)
char *t; char *t;
t = g_strstrip (mhl_str_dup (title)); t = g_strstrip (mhl_str_dup (title));
g->title = g_strconcat (" ", t, " ", (char *) NULL); g->title = g_strconcat (" ", t, " ", (char *) NULL);
mhl_mem_free (t); g_free (t);
} }
return g; return g;

View File

@ -89,7 +89,7 @@ int run_listbox (Listbox *l)
else else
val = l->list->pos; val = l->list->pos;
destroy_dlg (l->dlg); destroy_dlg (l->dlg);
mhl_mem_free (l); g_free (l);
return val; return val;
} }
@ -209,7 +209,7 @@ do_create_message (int flags, const char *title, const char *text)
query_dialog (title, p, flags, 0); query_dialog (title, p, flags, 0);
d = last_query_dlg; d = last_query_dlg;
init_dlg (d); init_dlg (d);
mhl_mem_free (p); g_free (p);
return d; return d;
} }
@ -231,7 +231,7 @@ create_message (int flags, const char *title, const char *text, ...)
va_end (args); va_end (args);
d = do_create_message (flags, title, p); d = do_create_message (flags, title, p);
mhl_mem_free (p); g_free (p);
return d; return d;
} }
@ -261,7 +261,7 @@ bg_message (int dummy, int *flags, char *title, const char *text)
(void) dummy; (void) dummy;
title = g_strconcat (_("Background process:"), " ", title, (char *) NULL); title = g_strconcat (_("Background process:"), " ", title, (char *) NULL);
fg_message (*flags, title, text); fg_message (*flags, title, text);
mhl_mem_free (title); g_free (title);
} }
#endif /* WITH_BACKGROUND */ #endif /* WITH_BACKGROUND */
@ -288,7 +288,7 @@ message (int flags, const char *title, const char *text, ...)
#endif /* WITH_BACKGROUND */ #endif /* WITH_BACKGROUND */
fg_message (flags, title, p); fg_message (flags, title, p);
mhl_mem_free (p); g_free (p);
} }
@ -415,7 +415,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
} }
return_val = dd->ret_value; return_val = dd->ret_value;
destroy_dlg (dd); destroy_dlg (dd);
mhl_mem_free (widgets); g_free (widgets);
return return_val; return return_val;
} }
@ -516,7 +516,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
Quick_input.widgets = quick_widgets; Quick_input.widgets = quick_widgets;
ret = quick_dialog (&Quick_input); ret = quick_dialog (&Quick_input);
mhl_mem_free (p_text); g_free (p_text);
if (ret != B_CANCEL) { if (ret != B_CANCEL) {
return my_str; return my_str;
@ -563,7 +563,7 @@ input_expand_dialog (const char *header, const char *text,
result = input_dialog (header, text, history_name, def_text); result = input_dialog (header, text, history_name, def_text);
if (result) { if (result) {
expanded = tilde_expand (result); expanded = tilde_expand (result);
mhl_mem_free (result); g_free (result);
return expanded; return expanded;
} }
return result; return result;

View File

@ -35,9 +35,8 @@ typedef int dummy; /* C99 forbids empty compilation unit */
#else #else
#include <setjmp.h> #include <setjmp.h>
#include <X11/Xlib.h>
#include <mhl/memory.h> #include <X11/Xlib.h>
#include "../src/global.h" #include "../src/global.h"
@ -135,7 +134,7 @@ static bool x11_available(void)
if (x11_module == NULL) if (x11_module == NULL)
x11_module = g_module_open ("libX11.so.6", G_MODULE_BIND_LAZY); x11_module = g_module_open ("libX11.so.6", G_MODULE_BIND_LAZY);
mhl_mem_free (x11_module_fname); g_free (x11_module_fname);
if (x11_module == NULL) if (x11_module == NULL)
return FALSE; return FALSE;

View File

@ -147,7 +147,7 @@ static void cpio_free_archive(struct vfs_class *me, struct vfs_s_super *super)
super->u.arch.fd = -1; super->u.arch.fd = -1;
for (l = super->u.arch.deferred; l; l = lnext) { for (l = super->u.arch.deferred; l; l = lnext) {
lnext = l->next; lnext = l->next;
mhl_mem_free (l); g_free (l);
} }
super->u.arch.deferred = NULL; super->u.arch.deferred = NULL;
} }
@ -178,10 +178,10 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super,
s = g_strconcat (name, decompress_extension (type), (char *) NULL); s = g_strconcat (name, decompress_extension (type), (char *) NULL);
if ((fd = mc_open (s, O_RDONLY)) == -1) { if ((fd = mc_open (s, O_RDONLY)) == -1) {
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s); message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
mhl_mem_free (s); g_free (s);
return -1; return -1;
} }
mhl_mem_free (s); g_free (s);
} }
super->u.arch.fd = fd; super->u.arch.fd = fd;
@ -294,7 +294,7 @@ static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe
} }
name = g_malloc(u.buf.c_namesize); name = g_malloc(u.buf.c_namesize);
if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) { if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) {
mhl_mem_free(name); g_free(name);
return STATUS_EOF; return STATUS_EOF;
} }
name[u.buf.c_namesize - 1] = '\0'; name[u.buf.c_namesize - 1] = '\0';
@ -302,7 +302,7 @@ static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe
cpio_skip_padding(super); cpio_skip_padding(super);
if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */ if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
mhl_mem_free(name); g_free(name);
return STATUS_TRAIL; return STATUS_TRAIL;
} }
@ -353,7 +353,7 @@ static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup
name = g_malloc(hd.c_namesize); name = g_malloc(hd.c_namesize);
if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 || if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 ||
(unsigned long) len < hd.c_namesize) { (unsigned long) len < hd.c_namesize) {
mhl_mem_free (name); g_free (name);
return STATUS_EOF; return STATUS_EOF;
} }
name[hd.c_namesize - 1] = '\0'; name[hd.c_namesize - 1] = '\0';
@ -361,7 +361,7 @@ static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup
cpio_skip_padding(super); cpio_skip_padding(super);
if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */ if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
mhl_mem_free(name); g_free(name);
return STATUS_TRAIL; return STATUS_TRAIL;
} }
@ -418,7 +418,7 @@ static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *supe
name = g_malloc(hd.c_namesize); name = g_malloc(hd.c_namesize);
if((len = mc_read (super->u.arch.fd, name, hd.c_namesize)) == -1 || if((len = mc_read (super->u.arch.fd, name, hd.c_namesize)) == -1 ||
(unsigned long) len < hd.c_namesize) { (unsigned long) len < hd.c_namesize) {
mhl_mem_free (name); g_free (name);
return STATUS_EOF; return STATUS_EOF;
} }
name[hd.c_namesize - 1] = '\0'; name[hd.c_namesize - 1] = '\0';
@ -426,7 +426,7 @@ static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *supe
cpio_skip_padding(super); cpio_skip_padding(super);
if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */ if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
mhl_mem_free(name); g_free(name);
return STATUS_TRAIL; return STATUS_TRAIL;
} }
@ -549,7 +549,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super,
if (mc_read (super->u.arch.fd, inode->linkname, st->st_size) if (mc_read (super->u.arch.fd, inode->linkname, st->st_size)
< st->st_size) { < st->st_size) {
inode->linkname[0] = 0; inode->linkname[0] = 0;
mhl_mem_free (name); g_free (name);
return STATUS_EOF; return STATUS_EOF;
} }
inode->linkname[st->st_size] = 0; /* Linkname stored without terminating \0 !!! */ inode->linkname[st->st_size] = 0; /* Linkname stored without terminating \0 !!! */
@ -561,7 +561,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super,
} /* !entry */ } /* !entry */
mhl_mem_free (name); g_free (name);
return STATUS_OK; return STATUS_OK;
} }

View File

@ -99,14 +99,14 @@ vfs_s_free_inode (struct vfs_class *me, struct vfs_s_inode *ino)
} }
CALL (free_inode) (me, ino); CALL (free_inode) (me, ino);
mhl_mem_free (ino->linkname); g_free (ino->linkname);
if (ino->localname){ if (ino->localname){
unlink (ino->localname); unlink (ino->localname);
mhl_mem_free(ino->localname); g_free(ino->localname);
} }
total_inodes--; total_inodes--;
ino->super->ino_usage--; ino->super->ino_usage--;
mhl_mem_free(ino); g_free(ino);
} else ino->st.st_nlink--; } else ino->st.st_nlink--;
} }
@ -119,7 +119,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent)
ent->next->prevp = ent->prevp; ent->next->prevp = ent->prevp;
} }
mhl_mem_free (ent->name); g_free (ent->name);
ent->name = NULL; ent->name = NULL;
if (ent->ino){ if (ent->ino){
@ -129,7 +129,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent)
} }
total_entries--; total_entries--;
mhl_mem_free(ent); g_free(ent);
} }
void void
@ -231,14 +231,14 @@ vfs_s_resolve_symlink (struct vfs_class *me, struct vfs_s_entry *entry,
if (fullpath) { if (fullpath) {
fullname = g_strconcat (fullpath, "/", linkname, NULL); fullname = g_strconcat (fullpath, "/", linkname, NULL);
linkname = fullname; linkname = fullname;
mhl_mem_free (fullpath); g_free (fullpath);
} }
} }
target = target =
(MEDATA->find_entry) (me, entry->dir->super->root, linkname, (MEDATA->find_entry) (me, entry->dir->super->root, linkname,
follow - 1, 0); follow - 1, 0);
mhl_mem_free (fullname); g_free (fullname);
return target; return target;
} }
@ -262,7 +262,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root,
path++; path++;
if (!path[0]) { if (!path[0]) {
mhl_mem_free (pathref); g_free (pathref);
return ent; return ent;
} }
@ -293,7 +293,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root,
root = ent->ino; root = ent->ino;
} }
cleanup: cleanup:
mhl_mem_free (pathref); g_free (pathref);
return NULL; return NULL;
} }
@ -340,7 +340,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
if (save) if (save)
*save = PATH_SEP; *save = PATH_SEP;
retval = vfs_s_find_entry_tree (me, ino, name, follow, flags); retval = vfs_s_find_entry_tree (me, ino, name, follow, flags);
mhl_mem_free (path); g_free (path);
return retval; return retval;
} }
@ -365,7 +365,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
ent = vfs_s_new_entry (me, path, ino); ent = vfs_s_new_entry (me, path, ino);
if ((MEDATA->dir_load) (me, ino, path) == -1) { if ((MEDATA->dir_load) (me, ino, path) == -1) {
vfs_s_free_entry (me, ent); vfs_s_free_entry (me, ent);
mhl_mem_free (path); g_free (path);
return NULL; return NULL;
} }
vfs_s_insert_entry (me, root, ent); vfs_s_insert_entry (me, root, ent);
@ -379,11 +379,11 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
#if 0 #if 0
if (!vfs_s_resolve_symlink (me, ent, follow)) { if (!vfs_s_resolve_symlink (me, ent, follow)) {
mhl_mem_free (path); g_free (path);
return NULL; return NULL;
} }
#endif #endif
mhl_mem_free (path); g_free (path);
return ent; return ent;
} }
@ -450,8 +450,8 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super)
} }
CALL (free_archive) (me, super); CALL (free_archive) (me, super);
mhl_mem_free (super->name); g_free (super->name);
mhl_mem_free(super); g_free(super);
} }
@ -525,7 +525,7 @@ vfs_s_get_path (struct vfs_class *me, const char *inname,
buf = mhl_str_dup (inname); buf = mhl_str_dup (inname);
retval = mhl_str_dup (vfs_s_get_path_mangle (me, buf, archive, flags)); retval = mhl_str_dup (vfs_s_get_path_mangle (me, buf, archive, flags));
mhl_mem_free (buf); g_free (buf);
return retval; return retval;
} }
@ -553,7 +553,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino)
if (ino == ino->super->root) if (ino == ino->super->root)
break; break;
newpath = g_strconcat (ino->ent->name, "/", path, (char *) NULL); newpath = g_strconcat (ino->ent->name, "/", path, (char *) NULL);
mhl_mem_free (path); g_free (path);
path = newpath; path = newpath;
} }
return path; return path;
@ -591,7 +591,7 @@ vfs_s_inode_from_path (struct vfs_class *me, const char *name, int flags)
flags & FL_FOLLOW ? LINK_FOLLOW : flags & FL_FOLLOW ? LINK_FOLLOW :
LINK_NO_FOLLOW, LINK_NO_FOLLOW,
FL_DIR | (flags & ~FL_FOLLOW)); FL_DIR | (flags & ~FL_FOLLOW));
mhl_mem_free (q); g_free (q);
return ino; return ino;
} }
@ -652,7 +652,7 @@ vfs_s_closedir (void *data)
struct vfs_s_inode *dir = info->dir; struct vfs_s_inode *dir = info->dir;
vfs_s_free_inode (dir->super->me, dir); vfs_s_free_inode (dir->super->me, dir);
mhl_mem_free (data); g_free (data);
return 0; return 0;
} }
@ -735,7 +735,7 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
return NULL; return NULL;
ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE); ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE);
if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) { if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) {
mhl_mem_free (q); g_free (q);
ERRNOR (EEXIST, NULL); ERRNOR (EEXIST, NULL);
} }
if (!ino) { if (!ino) {
@ -746,7 +746,7 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
/* If the filesystem is read-only, disable file creation */ /* If the filesystem is read-only, disable file creation */
if (!(flags & O_CREAT) || !(me->write)) { if (!(flags & O_CREAT) || !(me->write)) {
mhl_mem_free (q); g_free (q);
return NULL; return NULL;
} }
@ -760,14 +760,14 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
vfs_s_insert_entry (me, dir, ent); vfs_s_insert_entry (me, dir, ent);
tmp_handle = vfs_mkstemps (&ino->localname, me->name, name); tmp_handle = vfs_mkstemps (&ino->localname, me->name, name);
if (tmp_handle == -1) { if (tmp_handle == -1) {
mhl_mem_free (q); g_free (q);
return NULL; return NULL;
} }
close (tmp_handle); close (tmp_handle);
was_changed = 1; was_changed = 1;
} }
mhl_mem_free (q); g_free (q);
if (S_ISDIR (ino->st.st_mode)) if (S_ISDIR (ino->st.st_mode))
ERRNOR (EISDIR, NULL); ERRNOR (EISDIR, NULL);
@ -786,14 +786,14 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
} }
} else if ((MEDATA->fh_open) } else if ((MEDATA->fh_open)
&& (MEDATA->fh_open (me, fh, flags, mode))) { && (MEDATA->fh_open (me, fh, flags, mode))) {
mhl_mem_free (fh); g_free (fh);
return NULL; return NULL;
} }
if (fh->ino->localname) { if (fh->ino->localname) {
fh->handle = open (fh->ino->localname, NO_LINEAR (flags), mode); fh->handle = open (fh->ino->localname, NO_LINEAR (flags), mode);
if (fh->handle == -1) { if (fh->handle == -1) {
mhl_mem_free (fh); g_free (fh);
ERRNOR (errno, NULL); ERRNOR (errno, NULL);
} }
} }
@ -902,7 +902,7 @@ vfs_s_close (void *fh)
res = -1; res = -1;
else { else {
res = MEDATA->file_store (me, fh, s, FH->ino->localname); res = MEDATA->file_store (me, fh, s, FH->ino->localname);
mhl_mem_free (s); g_free (s);
} }
vfs_s_invalidate (me, FH_SUPER); vfs_s_invalidate (me, FH_SUPER);
} }
@ -910,7 +910,7 @@ vfs_s_close (void *fh)
close (FH->handle); close (FH->handle);
vfs_s_free_inode (me, FH->ino); vfs_s_free_inode (me, FH->ino);
mhl_mem_free (fh); g_free (fh);
return res; return res;
} }
@ -996,7 +996,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
close (handle); close (handle);
unlink (ino->localname); unlink (ino->localname);
error_4: error_4:
mhl_mem_free (ino->localname); g_free (ino->localname);
ino->localname = NULL; ino->localname = NULL;
return -1; return -1;
} }
@ -1012,7 +1012,7 @@ vfs_s_fill_names (struct vfs_class *me, fill_names_f func)
while (a){ while (a){
name = g_strconcat ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL); name = g_strconcat ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL);
(*func)(name); (*func)(name);
mhl_mem_free (name); g_free (name);
a = a->next; a = a->next;
} }
} }
@ -1096,7 +1096,7 @@ vfs_s_getid (struct vfs_class *me, const char *path)
if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN))) if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN)))
return NULL; return NULL;
mhl_mem_free(p); g_free(p);
return (vfsid) archive; return (vfsid) archive;
} }

View File

@ -126,7 +126,7 @@ extfs_fill_names (struct vfs_class *me, fill_names_f func)
g_strconcat (a->name ? a->name : "", "#", g_strconcat (a->name ? a->name : "", "#",
extfs_prefixes[a->fstype], (char *) NULL); extfs_prefixes[a->fstype], (char *) NULL);
(*func) (name); (*func) (name);
mhl_mem_free (name); g_free (name);
a = a->next; a = a->next;
} }
} }
@ -219,10 +219,10 @@ static void extfs_free_archive (struct archive *archive)
mc_stat (archive->local_name, &my); mc_stat (archive->local_name, &my);
mc_ungetlocalcopy (archive->name, archive->local_name, mc_ungetlocalcopy (archive->name, archive->local_name,
archive->local_stat.st_mtime != my.st_mtime); archive->local_stat.st_mtime != my.st_mtime);
mhl_mem_free(archive->local_name); g_free(archive->local_name);
} }
mhl_mem_free (archive->name); g_free (archive->name);
mhl_mem_free (archive); g_free (archive);
} }
static FILE * static FILE *
@ -254,16 +254,16 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
cmd = cmd =
g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ", g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ",
local_name ? local_name : tmp, (char *) NULL); local_name ? local_name : tmp, (char *) NULL);
mhl_mem_free (tmp); g_free (tmp);
mhl_mem_free (mc_extfsdir); g_free (mc_extfsdir);
open_error_pipe (); open_error_pipe ();
result = popen (cmd, "r"); result = popen (cmd, "r");
mhl_mem_free (cmd); g_free (cmd);
if (result == NULL) { if (result == NULL) {
close_error_pipe (D_ERROR, NULL); close_error_pipe (D_ERROR, NULL);
if (local_name) { if (local_name) {
mc_ungetlocalcopy (name, local_name, 0); mc_ungetlocalcopy (name, local_name, 0);
mhl_mem_free(local_name); g_free(local_name);
} }
return NULL; return NULL;
} }
@ -356,7 +356,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
0); 0);
if (pent == NULL) { if (pent == NULL) {
/* FIXME: Should clean everything one day */ /* FIXME: Should clean everything one day */
mhl_mem_free (buffer); g_free (buffer);
pclose (extfsd); pclose (extfsd);
close_error_pipe (D_ERROR, _("Inconsistent extfs archive")); close_error_pipe (D_ERROR, _("Inconsistent extfs archive"));
return -1; return -1;
@ -375,7 +375,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
current_link_name, 0, 0); current_link_name, 0, 0);
if (pent == NULL) { if (pent == NULL) {
/* FIXME: Should clean everything one day */ /* FIXME: Should clean everything one day */
mhl_mem_free (buffer); g_free (buffer);
pclose (extfsd); pclose (extfsd);
close_error_pipe (D_ERROR, close_error_pipe (D_ERROR,
_("Inconsistent extfs archive")); _("Inconsistent extfs archive"));
@ -420,11 +420,11 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
} }
} }
read_extfs_continue: read_extfs_continue:
mhl_mem_free (current_file_name); g_free (current_file_name);
mhl_mem_free (current_link_name); g_free (current_link_name);
} }
} }
mhl_mem_free (buffer); g_free (buffer);
/* Check if extfs 'list' returned 0 */ /* Check if extfs 'list' returned 0 */
if (pclose (extfsd) != 0) { if (pclose (extfsd) != 0) {
@ -499,7 +499,7 @@ extfs_get_path (struct vfs_class *me, const char *inname, struct archive **archi
char *res2 = NULL; char *res2 = NULL;
if (res) if (res)
res2 = mhl_str_dup (res); res2 = mhl_str_dup (res);
mhl_mem_free (buf); g_free (buf);
return res2; return res2;
} }
@ -533,7 +533,7 @@ static char *extfs_get_path_from_entry (struct entry *entry)
strcat (localpath, "/"); strcat (localpath, "/");
p = head; p = head;
head = head->next; head = head->next;
mhl_mem_free (p); g_free (p);
} }
return (localpath); return (localpath);
} }
@ -568,7 +568,7 @@ extfs_resolve_symlinks_int (struct entry *entry,
looping->entry = entry; looping->entry = entry;
looping->next = list; looping->next = list;
pent = extfs_find_entry_int (entry->dir, entry->inode->linkname, looping, 0, 0); pent = extfs_find_entry_int (entry->dir, entry->inode->linkname, looping, 0, 0);
mhl_mem_free (looping); g_free (looping);
if (pent == NULL) if (pent == NULL)
my_errno = ENOENT; my_errno = ENOENT;
return pent; return pent;
@ -621,7 +621,7 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive,
file = extfs_get_path_from_entry (entry); file = extfs_get_path_from_entry (entry);
quoted_file = name_quote (file, 0); quoted_file = name_quote (file, 0);
mhl_mem_free (file); g_free (file);
archive_name = name_quote (extfs_get_archive_name (archive), 0); archive_name = name_quote (extfs_get_archive_name (archive), 0);
quoted_localname = name_quote (localname, 0); quoted_localname = name_quote (localname, 0);
@ -629,14 +629,14 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive,
cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
extfs_cmd, archive_name, " ", quoted_file, " ", extfs_cmd, archive_name, " ", quoted_file, " ",
quoted_localname, (char *) NULL); quoted_localname, (char *) NULL);
mhl_mem_free (quoted_file); g_free (quoted_file);
mhl_mem_free (quoted_localname); g_free (quoted_localname);
mhl_mem_free (mc_extfsdir); g_free (mc_extfsdir);
mhl_mem_free (archive_name); g_free (archive_name);
open_error_pipe (); open_error_pipe ();
retval = my_system (EXECUTE_AS_SHELL, shell, cmd); retval = my_system (EXECUTE_AS_SHELL, shell, cmd);
mhl_mem_free (cmd); g_free (cmd);
close_error_pipe (D_ERROR, NULL); close_error_pipe (D_ERROR, NULL);
return retval; return retval;
} }
@ -651,17 +651,17 @@ extfs_run (struct vfs_class *me, const char *file)
if ((p = extfs_get_path (me, file, &archive, 0)) == NULL) if ((p = extfs_get_path (me, file, &archive, 0)) == NULL)
return; return;
q = name_quote (p, 0); q = name_quote (p, 0);
mhl_mem_free (p); g_free (p);
archive_name = name_quote (extfs_get_archive_name (archive), 0); archive_name = name_quote (extfs_get_archive_name (archive), 0);
mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR); mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR);
cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
" run ", archive_name, " ", q, (char *) NULL); " run ", archive_name, " ", q, (char *) NULL);
mhl_mem_free (mc_extfsdir); g_free (mc_extfsdir);
mhl_mem_free (archive_name); g_free (archive_name);
mhl_mem_free (q); g_free (q);
shell_execute (cmd, 0); shell_execute (cmd, 0);
mhl_mem_free (cmd); g_free (cmd);
} }
static void * static void *
@ -683,7 +683,7 @@ extfs_open (struct vfs_class *me, const char *file, int flags, int mode)
created = (entry != NULL); created = (entry != NULL);
} }
mhl_mem_free (q); g_free (q);
if (entry == NULL) if (entry == NULL)
return NULL; return NULL;
if ((entry = extfs_resolve_symlinks (entry)) == NULL) if ((entry = extfs_resolve_symlinks (entry)) == NULL)
@ -766,7 +766,7 @@ extfs_close (void *data)
if (!file->archive->fd_usage) if (!file->archive->fd_usage)
vfs_stamp_create (&vfs_extfs_ops, file->archive); vfs_stamp_create (&vfs_extfs_ops, file->archive);
mhl_mem_free (data); g_free (data);
if (errno_code) if (errno_code)
ERRNOR (EIO, -1); ERRNOR (EIO, -1);
return 0; return 0;
@ -882,7 +882,7 @@ static void * extfs_opendir (struct vfs_class *me, const char *dirname)
if ((q = extfs_get_path (me, dirname, &archive, 0)) == NULL) if ((q = extfs_get_path (me, dirname, &archive, 0)) == NULL)
return NULL; return NULL;
entry = extfs_find_entry (archive->root_entry, q, 0, 0); entry = extfs_find_entry (archive->root_entry, q, 0, 0);
mhl_mem_free (q); g_free (q);
if (entry == NULL) if (entry == NULL)
return NULL; return NULL;
if ((entry = extfs_resolve_symlinks (entry)) == NULL) if ((entry = extfs_resolve_symlinks (entry)) == NULL)
@ -914,7 +914,7 @@ static void * extfs_readdir(void *data)
static int extfs_closedir (void *data) static int extfs_closedir (void *data)
{ {
mhl_mem_free (data); g_free (data);
return 0; return 0;
} }
@ -961,7 +961,7 @@ extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf,
extfs_stat_move (buf, entry->inode); extfs_stat_move (buf, entry->inode);
result = 0; result = 0;
cleanup: cleanup:
mhl_mem_free (path2); g_free (path2);
return result; return result;
} }
@ -1008,7 +1008,7 @@ extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
/* readlink() does not append a NUL character to buf */ /* readlink() does not append a NUL character to buf */
memcpy (buf, entry->inode->linkname, result = len); memcpy (buf, entry->inode->linkname, result = len);
cleanup: cleanup:
mhl_mem_free (mpath); g_free (mpath);
return result; return result;
} }
@ -1053,7 +1053,7 @@ static int extfs_unlink (struct vfs_class *me, const char *file)
extfs_remove_entry (entry); extfs_remove_entry (entry);
result = 0; result = 0;
cleanup: cleanup:
mhl_mem_free (mpath); g_free (mpath);
return result; return result;
} }
@ -1090,7 +1090,7 @@ static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
} }
result = 0; result = 0;
cleanup: cleanup:
mhl_mem_free (mpath); g_free (mpath);
return result; return result;
} }
@ -1120,7 +1120,7 @@ static int extfs_rmdir (struct vfs_class *me, const char *path)
extfs_remove_entry (entry); extfs_remove_entry (entry);
result = 0; result = 0;
cleanup: cleanup:
mhl_mem_free (mpath); g_free (mpath);
return result; return result;
} }
@ -1135,7 +1135,7 @@ extfs_chdir (struct vfs_class *me, const char *path)
if ((q = extfs_get_path (me, path, &archive, 0)) == NULL) if ((q = extfs_get_path (me, path, &archive, 0)) == NULL)
return -1; return -1;
entry = extfs_find_entry (archive->root_entry, q, 0, 0); entry = extfs_find_entry (archive->root_entry, q, 0, 0);
mhl_mem_free (q); g_free (q);
if (!entry) if (!entry)
return -1; return -1;
entry = extfs_resolve_symlinks (entry); entry = extfs_resolve_symlinks (entry);
@ -1160,7 +1160,7 @@ extfs_getid (struct vfs_class *me, const char *path)
if (!(p = extfs_get_path (me, path, &archive, 1))) if (!(p = extfs_get_path (me, path, &archive, 1)))
return NULL; return NULL;
mhl_mem_free (p); g_free (p);
return (vfsid) archive; return (vfsid) archive;
} }
@ -1202,12 +1202,12 @@ static void extfs_remove_entry (struct entry *e)
unlink (e->inode->local_filename); unlink (e->inode->local_filename);
free (e->inode->local_filename); free (e->inode->local_filename);
} }
mhl_mem_free (e->inode->linkname); g_free (e->inode->linkname);
mhl_mem_free (e->inode); g_free (e->inode);
} }
mhl_mem_free (e->name); g_free (e->name);
mhl_mem_free (e); g_free (e);
} }
static void extfs_free_entry (struct entry *e) static void extfs_free_entry (struct entry *e)
@ -1224,13 +1224,13 @@ static void extfs_free_entry (struct entry *e)
unlink (e->inode->local_filename); unlink (e->inode->local_filename);
free (e->inode->local_filename); free (e->inode->local_filename);
} }
mhl_mem_free (e->inode->linkname); g_free (e->inode->linkname);
mhl_mem_free (e->inode); g_free (e->inode);
} }
if (e->next_in_dir != NULL) if (e->next_in_dir != NULL)
extfs_free_entry (e->next_in_dir); extfs_free_entry (e->next_in_dir);
mhl_mem_free (e->name); g_free (e->name);
mhl_mem_free (e); g_free (e);
} }
static void extfs_free (vfsid id) static void extfs_free (vfsid id)
@ -1307,7 +1307,7 @@ static int extfs_init (struct vfs_class *me)
* appear on screen. */ * appear on screen. */
if (!cfg) { if (!cfg) {
fprintf (stderr, _("Warning: file %s not found\n"), mc_extfsini); fprintf (stderr, _("Warning: file %s not found\n"), mc_extfsini);
mhl_mem_free (mc_extfsini); g_free (mc_extfsini);
return 0; return 0;
} }
@ -1323,7 +1323,7 @@ static int extfs_init (struct vfs_class *me)
fprintf(stderr, "Warning: You need to update your %s file.\n", fprintf(stderr, "Warning: You need to update your %s file.\n",
mc_extfsini); mc_extfsini);
fclose(cfg); fclose(cfg);
mhl_mem_free (mc_extfsini); g_free (mc_extfsini);
return 0; return 0;
} }
if (*key == '#' || *key == '\n') if (*key == '#' || *key == '\n')
@ -1343,7 +1343,7 @@ static int extfs_init (struct vfs_class *me)
extfs_prefixes [extfs_no++] = mhl_str_dup (key); extfs_prefixes [extfs_no++] = mhl_str_dup (key);
} }
fclose(cfg); fclose(cfg);
mhl_mem_free (mc_extfsini); g_free (mc_extfsini);
return 1; return 1;
} }
@ -1372,7 +1372,7 @@ static void extfs_done (struct vfs_class *me)
} }
for (i = 0; i < extfs_no; i++ ) for (i = 0; i < extfs_no; i++ )
mhl_mem_free (extfs_prefixes [i]); g_free (extfs_prefixes [i]);
extfs_no = 0; extfs_no = 0;
} }

View File

@ -147,7 +147,7 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super,
enable_interrupt_key (); enable_interrupt_key ();
status = write (SUP.sockw, str, strlen (str)); status = write (SUP.sockw, str, strlen (str));
mhl_mem_free (str); g_free (str);
disable_interrupt_key (); disable_interrupt_key ();
if (status < 0) if (status < 0)
@ -171,10 +171,10 @@ fish_free_archive (struct vfs_class *me, struct vfs_s_super *super)
close (SUP.sockr); close (SUP.sockr);
SUP.sockw = SUP.sockr = -1; SUP.sockw = SUP.sockr = -1;
} }
mhl_mem_free (SUP.host); g_free (SUP.host);
mhl_mem_free (SUP.user); g_free (SUP.user);
mhl_mem_free (SUP.cwdir); g_free (SUP.cwdir);
mhl_mem_free (SUP.password); g_free (SUP.password);
} }
static void static void
@ -263,7 +263,7 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
p = g_strconcat (_(" fish: Password required for "), p = g_strconcat (_(" fish: Password required for "),
SUP.user, " ", (char *) NULL); SUP.user, " ", (char *) NULL);
op = vfs_get_password (p); op = vfs_get_password (p);
mhl_mem_free (p); g_free (p);
if (op == NULL) if (op == NULL)
ERRNOR (EPERM, -1); ERRNOR (EPERM, -1);
SUP.password = op; SUP.password = op;
@ -326,7 +326,7 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super,
p = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags, p = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags,
&password, 0, URL_NOSLASH); &password, 0, URL_NOSLASH);
mhl_mem_free (p); g_free (p);
SUP.host = host; SUP.host = host;
SUP.user = user; SUP.user = user;
@ -353,12 +353,12 @@ fish_archive_same (struct vfs_class *me, struct vfs_s_super *super,
op = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags, 0, 0, op = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags, 0, 0,
URL_NOSLASH); URL_NOSLASH);
mhl_mem_free (op); g_free (op);
flags = ((strcmp (host, SUP.host) == 0) flags = ((strcmp (host, SUP.host) == 0)
&& (strcmp (user, SUP.user) == 0) && (flags == SUP.flags)); && (strcmp (user, SUP.user) == 0) && (flags == SUP.flags));
mhl_mem_free (host); g_free (host);
mhl_mem_free (user); g_free (user);
return flags; return flags;
} }
@ -466,7 +466,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
"echo '### 500'\n" "echo '### 500'\n"
"fi\n", "fi\n",
quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s); quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s, quoted_path.s);
mhl_mem_free (quoted_path.s); g_free (quoted_path.s);
ent = vfs_s_generate_entry(me, NULL, dir, 0); ent = vfs_s_generate_entry(me, NULL, dir, 0);
while (1) { while (1) {
int res = vfs_s_get_line_interruptible (me, buffer, sizeof (buffer), SUP.sockr); int res = vfs_s_get_line_interruptible (me, buffer, sizeof (buffer), SUP.sockr);
@ -597,7 +597,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
vfs_s_free_entry (me, ent); vfs_s_free_entry (me, ent);
reply_code = fish_decode_reply(buffer + 4, 0); reply_code = fish_decode_reply(buffer + 4, 0);
if (reply_code == COMPLETE) { if (reply_code == COMPLETE) {
mhl_mem_free (SUP.cwdir); g_free (SUP.cwdir);
SUP.cwdir = mhl_str_dup (remote_path); SUP.cwdir = mhl_str_dup (remote_path);
print_vfs_message (_("%s: done."), me->name); print_vfs_message (_("%s: done."), me->name);
return 0; return 0;
@ -738,14 +738,14 @@ fish_file_store(struct vfs_class *me, struct vfs_s_fh *fh, char *name, char *loc
(unsigned long) s.st_size); (unsigned long) s.st_size);
} }
close(h); close(h);
mhl_mem_free(quoted_name.s); g_free(quoted_name.s);
if ((fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE) || was_error) if ((fish_get_reply (me, SUP.sockr, NULL, 0) != COMPLETE) || was_error)
ERRNOR (E_REMOTE, -1); ERRNOR (E_REMOTE, -1);
return 0; return 0;
error_return: error_return:
close(h); close(h);
fish_get_reply(me, SUP.sockr, NULL, 0); fish_get_reply(me, SUP.sockr, NULL, 0);
mhl_mem_free(quoted_name.s); g_free(quoted_name.s);
return -1; return -1;
} }
@ -783,7 +783,7 @@ fish_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
"echo '### 500'\n" "echo '### 500'\n"
"fi\n", "fi\n",
quoted_name.s, quoted_name.s, quoted_name.s, quoted_name.s ); quoted_name.s, quoted_name.s, quoted_name.s, quoted_name.s );
mhl_mem_free (quoted_name.s); g_free (quoted_name.s);
if (offset != PRELIM) ERRNOR (E_REMOTE, 0); if (offset != PRELIM) ERRNOR (E_REMOTE, 0);
fh->linear = LS_LINEAR_OPEN; fh->linear = LS_LINEAR_OPEN;
fh->u.fish.got = 0; fh->u.fish.got = 0;
@ -896,14 +896,14 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super *super, const char *c
SHELL_ESCAPED_STR rpath; \ SHELL_ESCAPED_STR rpath; \
struct vfs_s_super *super; \ struct vfs_s_super *super; \
if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \ if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \
mhl_mem_free (mpath); \ g_free (mpath); \
return -1; \ return -1; \
} \ } \
rpath = mhl_shell_escape_dup(crpath); \ rpath = mhl_shell_escape_dup(crpath); \
mhl_mem_free (mpath); g_free (mpath);
#define POSTFIX(flags) \ #define POSTFIX(flags) \
mhl_mem_free (rpath.s); \ g_free (rpath.s); \
return fish_send_command(me, super, buf, flags); return fish_send_command(me, super, buf, flags);
static int static int
@ -926,20 +926,20 @@ static int fish_##name (struct vfs_class *me, const char *path1, const char *pat
char *mpath1, *mpath2; \ char *mpath1, *mpath2; \
struct vfs_s_super *super1, *super2; \ struct vfs_s_super *super1, *super2; \
if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = mhl_str_dup(path1), &super1, 0))) { \ if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = mhl_str_dup(path1), &super1, 0))) { \
mhl_mem_free (mpath1); \ g_free (mpath1); \
return -1; \ return -1; \
} \ } \
if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = mhl_str_dup(path2), &super2, 0))) { \ if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = mhl_str_dup(path2), &super2, 0))) { \
mhl_mem_free (mpath1); \ g_free (mpath1); \
mhl_mem_free (mpath2); \ g_free (mpath2); \
} \ } \
SHELL_ESCAPED_STR rpath1 = mhl_shell_escape_dup (crpath1); \ SHELL_ESCAPED_STR rpath1 = mhl_shell_escape_dup (crpath1); \
mhl_mem_free (mpath1); \ g_free (mpath1); \
SHELL_ESCAPED_STR rpath2 = mhl_shell_escape_dup (crpath2); \ SHELL_ESCAPED_STR rpath2 = mhl_shell_escape_dup (crpath2); \
mhl_mem_free (mpath2); \ g_free (mpath2); \
snprintf(buf, sizeof(buf), string "\n", rpath1.s, rpath2.s, rpath1.s, rpath2.s); \ snprintf(buf, sizeof(buf), string "\n", rpath1.s, rpath2.s, rpath1.s, rpath2.s); \
mhl_mem_free (rpath1.s); \ g_free (rpath1.s); \
mhl_mem_free (rpath2.s); \ g_free (rpath2.s); \
return fish_send_command(me, super2, buf, OPT_FLUSH); \ return fish_send_command(me, super2, buf, OPT_FLUSH); \
} }
@ -960,7 +960,7 @@ static int fish_symlink (struct vfs_class *me, const char *setto, const char *pa
"ln -s %s /%s 2>/dev/null\n" "ln -s %s /%s 2>/dev/null\n"
"echo '### 000'\n", "echo '### 000'\n",
qsetto.s, rpath.s, qsetto.s, rpath.s); qsetto.s, rpath.s, qsetto.s, rpath.s);
mhl_mem_free (qsetto.s); g_free (qsetto.s);
POSTFIX(OPT_FLUSH); POSTFIX(OPT_FLUSH);
} }
@ -1096,7 +1096,7 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
name = g_strconcat ("/#sh:", SUP.user, "@", SUP.host, flags, name = g_strconcat ("/#sh:", SUP.user, "@", SUP.host, flags,
"/", SUP.cwdir, (char *) NULL); "/", SUP.cwdir, (char *) NULL);
(*func)(name); (*func)(name);
mhl_mem_free (name); g_free (name);
super = super->next; super = super->next;
} }
} }

View File

@ -45,7 +45,7 @@ What to do with this?
if (f || !strncmp( remote_path, "/~/", 3 )) { if (f || !strncmp( remote_path, "/~/", 3 )) {
char *s; char *s;
s = mhl_str_dir_plus_file( qhome (*bucket), remote_path +3-f ); s = mhl_str_dir_plus_file( qhome (*bucket), remote_path +3-f );
mhl_mem_free (remote_path); g_free (remote_path);
remote_path = s; remote_path = s;
} }
} }
@ -56,7 +56,6 @@ What to do with this?
/* Namespace pollution: horrible */ /* Namespace pollution: horrible */
#include <config.h> #include <config.h>
#include <sys/types.h> /* POSIX-required by sys/socket.h and netdb.h */ #include <sys/types.h> /* POSIX-required by sys/socket.h and netdb.h */
#include <netdb.h> /* struct hostent */ #include <netdb.h> /* struct hostent */
#include <sys/socket.h> /* AF_INET */ #include <sys/socket.h> /* AF_INET */
@ -248,14 +247,14 @@ ftpfs_split_url(char *path, char **host, char **user, int *port, char **pass)
/* If user is different, remove password */ /* If user is different, remove password */
if (new_user && strcmp (*user, new_user)) { if (new_user && strcmp (*user, new_user)) {
mhl_mem_free (*pass); g_free (*pass);
*pass = NULL; *pass = NULL;
} }
mhl_mem_free (new_user); g_free (new_user);
} }
mhl_mem_free (p); g_free (p);
} }
/* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */ /* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */
@ -312,7 +311,7 @@ ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super)
if (!cwdir) if (!cwdir)
return 1; return 1;
sock = ftpfs_chdir_internal (me, super, cwdir); sock = ftpfs_chdir_internal (me, super, cwdir);
mhl_mem_free (cwdir); g_free (cwdir);
return sock == COMPLETE; return sock == COMPLETE;
} }
SUP.cwdir = cwdir; SUP.cwdir = cwdir;
@ -366,7 +365,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
} }
got_sigpipe = 1; got_sigpipe = 1;
} }
mhl_mem_free (cmdstr); g_free (cmdstr);
disable_interrupt_key (); disable_interrupt_key ();
return TRANSIENT; return TRANSIENT;
} }
@ -390,10 +389,10 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
} }
} }
retry = 0; retry = 0;
mhl_mem_free (cmdstr); g_free (cmdstr);
return status; return status;
} }
mhl_mem_free (cmdstr); g_free (cmdstr);
return COMPLETE; return COMPLETE;
} }
@ -405,10 +404,10 @@ ftpfs_free_archive (struct vfs_class *me, struct vfs_s_super *super)
ftpfs_command(me, super, NONE, "QUIT"); ftpfs_command(me, super, NONE, "QUIT");
close(SUP.sock); close(SUP.sock);
} }
mhl_mem_free (SUP.host); g_free (SUP.host);
mhl_mem_free (SUP.user); g_free (SUP.user);
mhl_mem_free (SUP.cwdir); g_free (SUP.cwdir);
mhl_mem_free (SUP.password); g_free (SUP.password);
} }
/* some defines only used by ftpfs_changetype */ /* some defines only used by ftpfs_changetype */
@ -459,7 +458,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
p = g_strconcat (_(" FTP: Password required for "), SUP.user, " ", p = g_strconcat (_(" FTP: Password required for "), SUP.user, " ",
NULL); NULL);
op = vfs_get_password (p); op = vfs_get_password (p);
mhl_mem_free (p); g_free (p);
if (op == NULL) if (op == NULL)
ERRNOR (EPERM, 0); ERRNOR (EPERM, 0);
SUP.password = mhl_str_dup (op); SUP.password = mhl_str_dup (op);
@ -505,13 +504,13 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
("FTP: Account required for user %s"), ("FTP: Account required for user %s"),
SUP.user); SUP.user);
op = input_dialog (p, _("Account:"), MC_HISTORY_FTPFS_ACCOUNT, ""); op = input_dialog (p, _("Account:"), MC_HISTORY_FTPFS_ACCOUNT, "");
mhl_mem_free (p); g_free (p);
if (op == NULL) if (op == NULL)
ERRNOR (EPERM, 0); ERRNOR (EPERM, 0);
print_vfs_message (_("ftpfs: sending user account")); print_vfs_message (_("ftpfs: sending user account"));
code = code =
ftpfs_command (me, super, WAIT_REPLY, "ACCT %s", op); ftpfs_command (me, super, WAIT_REPLY, "ACCT %s", op);
mhl_mem_free (op); g_free (op);
} }
if (code != COMPLETE) if (code != COMPLETE)
break; break;
@ -520,7 +519,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
case COMPLETE: case COMPLETE:
print_vfs_message (_("ftpfs: logged in")); print_vfs_message (_("ftpfs: logged in"));
wipe_password (pass); wipe_password (pass);
mhl_mem_free (name); g_free (name);
return 1; return 1;
default: default:
@ -536,7 +535,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
SUP.user); SUP.user);
login_fail: login_fail:
wipe_password (pass); wipe_password (pass);
mhl_mem_free (name); g_free (name);
ERRNOR (EPERM, 0); ERRNOR (EPERM, 0);
} }
@ -586,7 +585,7 @@ ftpfs_load_no_proxy_list (void)
fclose (npf); fclose (npf);
} }
mhl_mem_free (mc_file); g_free (mc_file);
} }
/* Return 1 if FTP proxy should be used for this host, 0 otherwise */ /* Return 1 if FTP proxy should be used for this host, 0 otherwise */
@ -638,8 +637,8 @@ ftpfs_get_proxy_host_and_port (const char *proxy, char **host, int *port)
dir = dir =
vfs_split_url (proxy, host, &user, port, 0, FTP_COMMAND_PORT, vfs_split_url (proxy, host, &user, port, 0, FTP_COMMAND_PORT,
URL_ALLOW_ANON); URL_ALLOW_ANON);
mhl_mem_free (user); g_free (user);
mhl_mem_free (dir); g_free (dir);
} }
static int static int
@ -682,7 +681,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
print_vfs_message (_("ftpfs: Invalid host address.")); print_vfs_message (_("ftpfs: Invalid host address."));
ftpfs_errno = EINVAL; ftpfs_errno = EINVAL;
if (free_host) if (free_host)
mhl_mem_free (host); g_free (host);
return -1; return -1;
} }
server_address.sin_family = hp->h_addrtype; server_address.sin_family = hp->h_addrtype;
@ -698,13 +697,13 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
disable_interrupt_key(); disable_interrupt_key();
ftpfs_errno = errno; ftpfs_errno = errno;
if (free_host) if (free_host)
mhl_mem_free (host); g_free (host);
return -1; return -1;
} }
print_vfs_message (_("ftpfs: making connection to %s"), host); print_vfs_message (_("ftpfs: making connection to %s"), host);
if (free_host) if (free_host)
mhl_mem_free (host); g_free (host);
if (connect (my_socket, (struct sockaddr *) &server_address, if (connect (my_socket, (struct sockaddr *) &server_address,
sizeof (server_address)) < 0){ sizeof (server_address)) < 0){
@ -819,8 +818,8 @@ ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super,
port = ((strcmp (host, SUP.host) == 0) port = ((strcmp (host, SUP.host) == 0)
&& (strcmp (user, SUP.user) == 0) && (port == SUP.port)); && (strcmp (user, SUP.user) == 0) && (port == SUP.port));
mhl_mem_free (host); g_free (host);
mhl_mem_free (user); g_free (user);
return port; return port;
} }
@ -971,7 +970,7 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con
j = ftpfs_command (me, super, WAIT_REPLY, "%s /%s", cmd, j = ftpfs_command (me, super, WAIT_REPLY, "%s /%s", cmd,
/* WarFtpD can't STORE //filename */ /* WarFtpD can't STORE //filename */
(*remote_path == '/') ? remote_path + 1 : remote_path); (*remote_path == '/') ? remote_path + 1 : remote_path);
mhl_mem_free (remote_path); g_free (remote_path);
} else } else
j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd); j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd);
if (j != PRELIM) if (j != PRELIM)
@ -1157,7 +1156,7 @@ resolve_symlink_with_ls_options(struct vfs_class *me, struct vfs_s_super *super,
vfs_die("This code should be commented out\n"); vfs_die("This code should be commented out\n");
if (vfs_parse_ls_lga (buffer, &s, &filename, NULL)) { if (vfs_parse_ls_lga (buffer, &s, &filename, NULL)) {
int r = strcmp(fe->name, filename); int r = strcmp(fe->name, filename);
mhl_mem_free(filename); g_free(filename);
if (r == 0) { if (r == 0) {
if (S_ISLNK (s.st_mode)) { if (S_ISLNK (s.st_mode)) {
/* This server doesn't understand LIST -lLa */ /* This server doesn't understand LIST -lLa */
@ -1238,7 +1237,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
sock = sock =
ftpfs_open_data_connection (me, super, "LIST -la", path, TYPE_ASCII, ftpfs_open_data_connection (me, super, "LIST -la", path, TYPE_ASCII,
0); 0);
mhl_mem_free (path); g_free (path);
} }
if (sock == -1) if (sock == -1)
@ -1411,7 +1410,7 @@ ftpfs_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
if (!name) if (!name)
return 0; return 0;
FH_SOCK = ftpfs_open_data_connection(me, FH_SUPER, "RETR", name, TYPE_BINARY, offset); FH_SOCK = ftpfs_open_data_connection(me, FH_SUPER, "RETR", name, TYPE_BINARY, offset);
mhl_mem_free (name); g_free (name);
if (FH_SOCK == -1) if (FH_SOCK == -1)
ERRNOR (EACCES, 0); ERRNOR (EACCES, 0);
fh->linear = LS_LINEAR_OPEN; fh->linear = LS_LINEAR_OPEN;
@ -1487,23 +1486,23 @@ ftpfs_send_command(struct vfs_class *me, const char *filename, const char *cmd,
int flush_directory_cache = (flags & OPT_FLUSH); int flush_directory_cache = (flags & OPT_FLUSH);
if (!(rpath = vfs_s_get_path_mangle(me, mpath, &super, 0))) { if (!(rpath = vfs_s_get_path_mangle(me, mpath, &super, 0))) {
mhl_mem_free(mpath); g_free(mpath);
return -1; return -1;
} }
p = ftpfs_translate_path (me, super, rpath); p = ftpfs_translate_path (me, super, rpath);
r = ftpfs_command (me, super, WAIT_REPLY, cmd, p); r = ftpfs_command (me, super, WAIT_REPLY, cmd, p);
mhl_mem_free (p); g_free (p);
vfs_stamp_create (&vfs_ftpfs_ops, super); vfs_stamp_create (&vfs_ftpfs_ops, super);
if (flags & OPT_IGNORE_ERROR) if (flags & OPT_IGNORE_ERROR)
r = COMPLETE; r = COMPLETE;
if (r != COMPLETE) { if (r != COMPLETE) {
me->verrno = EPERM; me->verrno = EPERM;
mhl_mem_free (mpath); g_free (mpath);
return -1; return -1;
} }
if (flush_directory_cache) if (flush_directory_cache)
vfs_s_invalidate(me, super); vfs_s_invalidate(me, super);
mhl_mem_free(mpath); g_free(mpath);
return 0; return 0;
} }
@ -1579,12 +1578,12 @@ ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, const cha
p = ftpfs_translate_path (me, super, remote_path); p = ftpfs_translate_path (me, super, remote_path);
r = ftpfs_command (me, super, WAIT_REPLY, "CWD /%s", p); r = ftpfs_command (me, super, WAIT_REPLY, "CWD /%s", p);
mhl_mem_free (p); g_free (p);
if (r != COMPLETE) { if (r != COMPLETE) {
ftpfs_errno = EIO; ftpfs_errno = EIO;
} else { } else {
mhl_mem_free(SUP.cwdir); g_free(SUP.cwdir);
SUP.cwdir = mhl_str_dup (remote_path); SUP.cwdir = mhl_str_dup (remote_path);
SUP.cwd_deferred = 0; SUP.cwd_deferred = 0;
} }
@ -1647,7 +1646,7 @@ ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
ftpfs_open_data_connection (me, fh->ino->super, ftpfs_open_data_connection (me, fh->ino->super,
(flags & O_APPEND) ? "APPE" : (flags & O_APPEND) ? "APPE" :
"STOR", name, TYPE_BINARY, 0); "STOR", name, TYPE_BINARY, 0);
mhl_mem_free (name); g_free (name);
if (fh->handle < 0) if (fh->handle < 0)
return -1; return -1;
@ -1659,7 +1658,7 @@ ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
if (fh->ino->localname) { if (fh->ino->localname) {
unlink (fh->ino->localname); unlink (fh->ino->localname);
mhl_mem_free (fh->ino->localname); g_free (fh->ino->localname);
fh->ino->localname = NULL; fh->ino->localname = NULL;
} }
return 0; return 0;
@ -1698,12 +1697,12 @@ ftpfs_done (struct vfs_class *me)
while (no_proxy) { while (no_proxy) {
np = no_proxy->next; np = no_proxy->next;
mhl_mem_free (no_proxy->domain); g_free (no_proxy->domain);
mhl_mem_free (no_proxy); g_free (no_proxy);
no_proxy = np; no_proxy = np;
} }
mhl_mem_free (ftpfs_anonymous_passwd); g_free (ftpfs_anonymous_passwd);
mhl_mem_free (ftpfs_proxy_host); g_free (ftpfs_proxy_host);
} }
static void static void
@ -1715,7 +1714,7 @@ ftpfs_fill_names (struct vfs_class *me, fill_names_f func)
while (super){ while (super){
name = g_strconcat ("/#ftp:", SUP.user, "@", SUP.host, "/", SUP.cwdir, (char *) NULL); name = g_strconcat ("/#ftp:", SUP.user, "@", SUP.host, "/", SUP.cwdir, (char *) NULL);
(*func)(name); (*func)(name);
mhl_mem_free (name); g_free (name);
super = super->next; super = super->next;
} }
} }
@ -1893,7 +1892,7 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass)
netrcname = mhl_str_dir_plus_file (home_dir, ".netrc"); netrcname = mhl_str_dir_plus_file (home_dir, ".netrc");
netrcp = netrc = load_file (netrcname); netrcp = netrc = load_file (netrcname);
if (netrc == NULL) { if (netrc == NULL) {
mhl_mem_free (netrcname); g_free (netrcname);
return 0; return 0;
} }
@ -1968,8 +1967,8 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass)
break; break;
} }
mhl_mem_free (netrc); g_free (netrc);
mhl_mem_free (netrcname); g_free (netrcname);
rupp = g_new (struct rupcache, 1); rupp = g_new (struct rupcache, 1);
rupp->host = mhl_str_dup (host); rupp->host = mhl_str_dup (host);

View File

@ -110,7 +110,7 @@ vfs_rmstamp (struct vfs_class *v, vfsid id)
} else { } else {
st1->next = stamp->next; st1->next = stamp->next;
} }
mhl_mem_free (stamp); g_free (stamp);
return; return;
} }
@ -129,7 +129,7 @@ vfs_getid (struct vfs_class *vclass, const char *dir)
if (vclass->getid) if (vclass->getid)
id = (*vclass->getid) (vclass, dir1); id = (*vclass->getid) (vclass, dir1);
mhl_mem_free (dir1); g_free (dir1);
return id; return id;
} }
@ -298,7 +298,7 @@ vfs_gc_done (void)
if (stamp->v->free) if (stamp->v->free)
(*stamp->v->free) (stamp->id); (*stamp->v->free) (stamp->id);
st = stamp->next; st = stamp->next;
mhl_mem_free (stamp); g_free (stamp);
stamp = st; stamp = st;
} }

View File

@ -70,7 +70,7 @@ local_close (void *data)
return -1; return -1;
fd = *(int *) data; fd = *(int *) data;
mhl_mem_free (data); g_free (data);
return close (fd); return close (fd);
} }
@ -111,7 +111,7 @@ local_closedir (void *data)
int i; int i;
i = closedir (* (DIR **) data); i = closedir (* (DIR **) data);
mhl_mem_free (data); g_free (data);
return i; return i;
} }

View File

@ -114,7 +114,7 @@ mcfs_fill_names (struct vfs_class *me, fill_names_f func)
name = g_strconcat ("/#mc:", mcfs_connections[i].user, name = g_strconcat ("/#mc:", mcfs_connections[i].user,
"@", mcfs_connections[i].host, (char *) NULL); "@", mcfs_connections[i].host, (char *) NULL);
(*func) (name); (*func) (name);
mhl_mem_free (name); g_free (name);
} }
} }
@ -392,11 +392,11 @@ mcfs_get_path (mcfs_connection **mc, const char *path)
if ((remote_path = if ((remote_path =
mcfs_get_host_and_username (path, &host, &user, &port, &pass))) mcfs_get_host_and_username (path, &host, &user, &port, &pass)))
if (!(*mc = mcfs_open_link (host, user, &port, pass))) { if (!(*mc = mcfs_open_link (host, user, &port, pass))) {
mhl_mem_free (remote_path); g_free (remote_path);
remote_path = NULL; remote_path = NULL;
} }
mhl_mem_free (host); g_free (host);
mhl_mem_free (user); g_free (user);
if (pass) if (pass)
wipe_password (pass); wipe_password (pass);
@ -410,7 +410,7 @@ mcfs_get_path (mcfs_connection **mc, const char *path)
char *s; char *s;
s = mhl_str_dir_plus_file (mcfs_gethome (*mc), s = mhl_str_dir_plus_file (mcfs_gethome (*mc),
remote_path + 3 - f); remote_path + 3 - f);
mhl_mem_free (remote_path); g_free (remote_path);
remote_path = s; remote_path = s;
} }
} }
@ -444,14 +444,14 @@ mcfs_rpc_two_paths (int command, const char *s1, const char *s2)
return -1; return -1;
if ((r2 = mcfs_get_path (&mc, s2)) == 0) { if ((r2 = mcfs_get_path (&mc, s2)) == 0) {
mhl_mem_free (r1); g_free (r1);
return -1; return -1;
} }
rpc_send (mc->sock, rpc_send (mc->sock,
RPC_INT, command, RPC_STRING, r1, RPC_STRING, r2, RPC_END); RPC_INT, command, RPC_STRING, r1, RPC_STRING, r2, RPC_END);
mhl_mem_free (r1); g_free (r1);
mhl_mem_free (r2); g_free (r2);
return mcfs_handle_simple_error (mc->sock, 0); 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_send (mc->sock,
RPC_INT, command, RPC_STRING, remote_file, RPC_END); RPC_INT, command, RPC_STRING, remote_file, RPC_END);
mhl_mem_free (remote_file); g_free (remote_file);
return mcfs_handle_simple_error (mc->sock, 0); 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_INT, command,
RPC_STRING, remote_file, RPC_INT, data, RPC_END); RPC_STRING, remote_file, RPC_INT, data, RPC_END);
mhl_mem_free (remote_file); g_free (remote_file);
return mcfs_handle_simple_error (mc->sock, 0); 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_INT, command,
RPC_STRING, remote_file, RPC_INT, n1, RPC_INT, n2, RPC_END); RPC_STRING, remote_file, RPC_INT, n1, RPC_INT, n2, RPC_END);
mhl_mem_free (remote_file); g_free (remote_file);
return mcfs_handle_simple_error (mc->sock, 0); 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, rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT,
flags, RPC_INT, mode, RPC_END); flags, RPC_INT, mode, RPC_END);
mhl_mem_free (remote_file); g_free (remote_file);
if (0 == if (0 ==
rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END)) 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); mcfs_is_error (result, error);
mhl_mem_free (data); g_free (data);
return result; 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_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir,
RPC_END); RPC_END);
mhl_mem_free (remote_dir); g_free (remote_dir);
if (0 == if (0 ==
rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END)) 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) if (!de)
return; return;
mcfs_free_dir (de->next); mcfs_free_dir (de->next);
mhl_mem_free (de->text); g_free (de->text);
mhl_mem_free (de); g_free (de);
} }
static union vfs_dirent mcfs_readdir_data; static union vfs_dirent mcfs_readdir_data;
@ -795,10 +795,10 @@ mcfs_closedir (void *info)
for (p = mcfs_info->entries; p;) { for (p = mcfs_info->entries; p;) {
q = p; q = p;
p = p->next; p = p->next;
mhl_mem_free (q->text); g_free (q->text);
mhl_mem_free (q); g_free (q);
} }
mhl_mem_free (info); g_free (info);
return 0; return 0;
} }
@ -826,7 +826,7 @@ mcfs_get_time (mcfs_connection *mc)
rpc_get (sock, RPC_STRING, &buf, RPC_END); rpc_get (sock, RPC_STRING, &buf, RPC_END);
sscanf (buf, "%lx", &tm); sscanf (buf, "%lx", &tm);
mhl_mem_free (buf); g_free (buf);
return (time_t) tm; return (time_t) tm;
} }
@ -879,7 +879,7 @@ mcfs_stat_cmd (int cmd, const char *path, struct stat *buf)
return -1; return -1;
rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END); rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END);
mhl_mem_free (remote_file); g_free (remote_file);
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
return mcfs_set_error (-1, errno); 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); status = mcfs_handle_simple_error (mc->sock, 0);
} }
mhl_mem_free (file); g_free (file);
return (status); 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_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file,
RPC_END); RPC_END);
mhl_mem_free (remote_file); g_free (remote_file);
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
return mcfs_set_error (-1, EIO); 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; size = len;
/* readlink() does not append a NUL character to buf */ /* readlink() does not append a NUL character to buf */
memcpy (buf, stat_str, size); memcpy (buf, stat_str, size);
mhl_mem_free (stat_str); g_free (stat_str);
return size; 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_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir,
RPC_END); RPC_END);
mhl_mem_free (remote_dir); g_free (remote_dir);
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END)) if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
return mcfs_set_error (-1, EIO); return mcfs_set_error (-1, EIO);
@ -1138,8 +1138,8 @@ mcfs_forget (const char *path)
if ((p = if ((p =
mcfs_get_host_and_username (path, &host, &user, &port, mcfs_get_host_and_username (path, &host, &user, &port,
&pass)) == 0) { &pass)) == 0) {
mhl_mem_free (host); g_free (host);
mhl_mem_free (user); g_free (user);
if (pass) if (pass)
wipe_password (pass); wipe_password (pass);
return; return;
@ -1157,9 +1157,9 @@ mcfs_forget (const char *path)
mcfs_open_tcp_link (host, user, &port, pass, &vers); mcfs_open_tcp_link (host, user, &port, pass, &vers);
} }
} }
mhl_mem_free (p); g_free (p);
mhl_mem_free (host); g_free (host);
mhl_mem_free (user); g_free (user);
if (pass) if (pass)
wipe_password (pass); wipe_password (pass);
} }
@ -1215,9 +1215,9 @@ init_mcfs (void)
static void static void
mcfs_free_bucket (int bucket) mcfs_free_bucket (int bucket)
{ {
mhl_mem_free (mcfs_connections[bucket].host); g_free (mcfs_connections[bucket].host);
mhl_mem_free (mcfs_connections[bucket].user); g_free (mcfs_connections[bucket].user);
mhl_mem_free (mcfs_connections[bucket].home); g_free (mcfs_connections[bucket].home);
/* Set all the fields to zero */ /* Set all the fields to zero */
mcfs_connections[bucket].host = mcfs_connections[bucket].host =

View File

@ -124,6 +124,10 @@
# define INADDR_NONE (0xffffffffU) # define INADDR_NONE (0xffffffffU)
#endif #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 */ /* We don't care about SIGPIPE */
int got_sigpipe = 0; int got_sigpipe = 0;
@ -210,7 +214,7 @@ do_open (void)
handle = open (arg, flags, mode); handle = open (arg, flags, mode);
send_status (handle, errno); send_status (handle, errno);
mhl_mem_free (arg); g_free (arg);
} }
static void static void
@ -237,7 +241,7 @@ do_read (void)
send_status (n, 0); send_status (n, 0);
rpc_send (msock, RPC_BLOCK, n, data, RPC_END); rpc_send (msock, RPC_BLOCK, n, data, RPC_END);
mhl_mem_free (data); g_free (data);
} }
static void static void
@ -377,7 +381,7 @@ do_lstat (void)
send_status (n, errno); send_status (n, errno);
if (n >= 0) if (n >= 0)
send_stat_info (&st); send_stat_info (&st);
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -409,7 +413,7 @@ do_stat (void)
send_status (n, errno); send_status (n, errno);
if (n >= 0) if (n >= 0)
send_stat_info (&st); send_stat_info (&st);
mhl_mem_free (file); g_free (file);
} }
/* }}} */ /* }}} */
@ -429,7 +433,7 @@ close_handle (int handle)
mcfs_DIR.used--; mcfs_DIR.used--;
if (mcfs_DIR.dirs[handle]) if (mcfs_DIR.dirs[handle])
closedir (mcfs_DIR.dirs[handle]); closedir (mcfs_DIR.dirs[handle]);
mhl_mem_free (mcfs_DIR.names[handle]); g_free (mcfs_DIR.names[handle]);
mcfs_DIR.dirs[handle] = 0; mcfs_DIR.dirs[handle] = 0;
mcfs_DIR.names[handle] = 0; mcfs_DIR.names[handle] = 0;
} }
@ -445,7 +449,7 @@ do_opendir (void)
if (mcfs_DIR.used == OPENDIR_HANDLES) { if (mcfs_DIR.used == OPENDIR_HANDLES) {
send_status (-1, ENFILE); /* Error */ send_status (-1, ENFILE); /* Error */
mhl_mem_free (arg); g_free (arg);
return; return;
} }
@ -459,7 +463,7 @@ do_opendir (void)
if (handle == -1) { if (handle == -1) {
send_status (-1, EMFILE); send_status (-1, EMFILE);
mhl_mem_free (arg); g_free (arg);
if (!inetd_started) if (!inetd_started)
fprintf (stderr, fprintf (stderr,
"OOPS! you have found a bug in mc - do_opendir()!\n"); "OOPS! you have found a bug in mc - do_opendir()!\n");
@ -479,7 +483,7 @@ do_opendir (void)
} else { } else {
send_status (-1, errno); send_status (-1, errno);
mhl_mem_free (arg); g_free (arg);
} }
} }
@ -514,7 +518,7 @@ do_readdir (void)
snprintf (fname, fname_len, "%s/%s", mcfs_DIR.names[handle], snprintf (fname, fname_len, "%s/%s", mcfs_DIR.names[handle],
dirent->d_name); dirent->d_name);
n = lstat (fname, &st); n = lstat (fname, &st);
mhl_mem_free (fname); g_free (fname);
send_status (n, errno); send_status (n, errno);
if (n >= 0) if (n >= 0)
send_stat_info (&st); send_stat_info (&st);
@ -545,7 +549,7 @@ do_chdir (void)
status = chdir (file); status = chdir (file);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -558,7 +562,7 @@ do_rmdir (void)
status = rmdir (file); status = rmdir (file);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -571,7 +575,7 @@ do_mkdir (void)
status = mkdir (file, mode); status = mkdir (file, mode);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -585,7 +589,7 @@ do_mknod (void)
status = mknod (file, mode, dev); status = mknod (file, mode, dev);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -602,7 +606,7 @@ do_readlink (void)
buffer[n] = 0; buffer[n] = 0;
rpc_send (msock, RPC_STRING, buffer, RPC_END); rpc_send (msock, RPC_STRING, buffer, RPC_END);
} }
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -614,7 +618,7 @@ do_unlink (void)
rpc_get (msock, RPC_STRING, &file, RPC_END); rpc_get (msock, RPC_STRING, &file, RPC_END);
status = unlink (file); status = unlink (file);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -626,8 +630,8 @@ do_rename (void)
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
status = rename (f1, f2); status = rename (f1, f2);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (f1); g_free (f1);
mhl_mem_free (f2); g_free (f2);
} }
static void static void
@ -639,8 +643,8 @@ do_symlink (void)
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
status = symlink (f1, f2); status = symlink (f1, f2);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (f1); g_free (f1);
mhl_mem_free (f2); g_free (f2);
} }
static void static void
@ -652,8 +656,8 @@ do_link (void)
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END); rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
status = link (f1, f2); status = link (f1, f2);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (f1); g_free (f1);
mhl_mem_free (f2); g_free (f2);
} }
@ -682,7 +686,7 @@ do_chmod (void)
rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_END); rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_END);
status = chmod (file, mode); status = chmod (file, mode);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -695,7 +699,7 @@ do_chown (void)
RPC_END); RPC_END);
status = chown (file, owner, group); status = chown (file, owner, group);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (file); g_free (file);
} }
static void static void
@ -716,13 +720,13 @@ do_utime (void)
if (verbose) if (verbose)
printf ("Got a = %s, m = %s, comp a = %ld, m = %ld\n", as, ms, printf ("Got a = %s, m = %s, comp a = %ld, m = %ld\n", as, ms,
atime, mtime); atime, mtime);
mhl_mem_free (as); g_free (as);
mhl_mem_free (ms); g_free (ms);
times.actime = (time_t) atime; times.actime = (time_t) atime;
times.modtime = (time_t) mtime; times.modtime = (time_t) mtime;
status = utime (file, &times); status = utime (file, &times);
send_status (status, errno); send_status (status, errno);
mhl_mem_free (file); g_free (file);
} }
static void static void

View File

@ -83,7 +83,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
vfs_die ("This cannot happen... Hopefully.\n"); vfs_die ("This cannot happen... Hopefully.\n");
if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) { if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) {
mhl_mem_free (pname); g_free (pname);
return -1; return -1;
} }
@ -91,19 +91,19 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
if (!(sfs_flags[w] & F_NOLOCALCOPY)) { if (!(sfs_flags[w] & F_NOLOCALCOPY)) {
s = mc_getlocalcopy (pname); s = mc_getlocalcopy (pname);
if (!s) { if (!s) {
mhl_mem_free (pname); g_free (pname);
return -1; return -1;
} }
pqname = name_quote (s, 0); pqname = name_quote (s, 0);
mhl_mem_free (s); g_free (s);
} else { } else {
pqname = name_quote (pname, 0); pqname = name_quote (pname, 0);
} }
mhl_mem_free (pname); g_free (pname);
#define COPY_CHAR \ #define COPY_CHAR \
if ((size_t) (t-pad) > sizeof(pad)) { \ if ((size_t) (t-pad) > sizeof(pad)) { \
mhl_mem_free (pqname); \ g_free (pqname); \
return -1; \ return -1; \
} \ } \
else \ else \
@ -111,7 +111,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
#define COPY_STRING(a) \ #define COPY_STRING(a) \
if ((t-pad)+strlen(a)>sizeof(pad)) { \ if ((t-pad)+strlen(a)>sizeof(pad)) { \
mhl_mem_free (pqname); \ g_free (pqname); \
return -1; \ return -1; \
} else { \ } else { \
strcpy (t, a); \ strcpy (t, a); \
@ -147,7 +147,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
} }
} }
mhl_mem_free (pqname); g_free (pqname);
open_error_pipe (); open_error_pipe ();
if (my_system (EXECUTE_AS_SHELL, "/bin/sh", pad)) { if (my_system (EXECUTE_AS_SHELL, "/bin/sh", pad)) {
close_error_pipe (D_ERROR, NULL); close_error_pipe (D_ERROR, NULL);
@ -194,7 +194,7 @@ sfs_redirect (struct vfs_class *me, const char *name)
} }
unlink (cache); unlink (cache);
mhl_mem_free (cache); g_free (cache);
return "/I_MUST_NOT_EXIST"; return "/I_MUST_NOT_EXIST";
} }
@ -288,9 +288,9 @@ static void sfs_free (vfsid id)
else else
head = cur->next; head = cur->next;
mhl_mem_free (cur->cache); g_free (cur->cache);
mhl_mem_free (cur->name); g_free (cur->name);
mhl_mem_free (cur); g_free (cur);
} }
static void sfs_fill_names (struct vfs_class *me, fill_names_f func) static void sfs_fill_names (struct vfs_class *me, fill_names_f func)
@ -344,10 +344,10 @@ static int sfs_init (struct vfs_class *me)
if (!cfg){ if (!cfg){
fprintf (stderr, _("Warning: file %s not found\n"), mc_sfsini); fprintf (stderr, _("Warning: file %s not found\n"), mc_sfsini);
mhl_mem_free (mc_sfsini); g_free (mc_sfsini);
return 0; return 0;
} }
mhl_mem_free (mc_sfsini); g_free (mc_sfsini);
sfs_no = 0; sfs_no = 0;
while (sfs_no < MAXFS && fgets (key, sizeof (key), cfg)) { while (sfs_no < MAXFS && fgets (key, sizeof (key), cfg)) {
@ -409,8 +409,8 @@ sfs_done (struct vfs_class *me)
(void) me; (void) me;
for (i = 0; i < sfs_no; i++){ for (i = 0; i < sfs_no; i++){
mhl_mem_free (sfs_prefix [i]); g_free (sfs_prefix [i]);
mhl_mem_free (sfs_command [i]); g_free (sfs_command [i]);
sfs_prefix [i] = sfs_command [i] = NULL; sfs_prefix [i] = sfs_command [i] = NULL;
} }
sfs_no = 0; sfs_no = 0;

View File

@ -118,7 +118,7 @@ static GSList *auth_list;
static inline char * static inline char *
free_after (char *result, char *string_to_free) free_after (char *result, char *string_to_free)
{ {
mhl_mem_free(string_to_free); g_free(string_to_free);
return result; return result;
} }
@ -126,10 +126,10 @@ free_after (char *result, char *string_to_free)
static void static void
smbfs_auth_free (struct smb_authinfo const *a) smbfs_auth_free (struct smb_authinfo const *a)
{ {
mhl_mem_free (a->host); g_free (a->host);
mhl_mem_free (a->share); g_free (a->share);
mhl_mem_free (a->domain); g_free (a->domain);
mhl_mem_free (a->user); g_free (a->user);
wipe_password (a->password); wipe_password (a->password);
} }
@ -203,8 +203,8 @@ smbfs_auth_remove (const char *host, const char *share)
list = g_slist_find_custom (auth_list, list = g_slist_find_custom (auth_list,
&data, &data,
smbfs_auth_cmp_host_and_share); smbfs_auth_cmp_host_and_share);
mhl_mem_free (data.host); g_free (data.host);
mhl_mem_free (data.share); g_free (data.share);
if (!list) if (!list)
return; return;
auth = list->data; auth = list->data;
@ -225,9 +225,9 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket,
GSList *list; GSList *list;
if (domain && user && pass) { if (domain && user && pass) {
mhl_mem_free (bucket->domain); g_free (bucket->domain);
mhl_mem_free (bucket->user); g_free (bucket->user);
mhl_mem_free (bucket->password); g_free (bucket->password);
bucket->domain = mhl_str_dup (domain); bucket->domain = mhl_str_dup (domain);
bucket->user = mhl_str_dup (user); bucket->user = mhl_str_dup (user);
bucket->password = mhl_str_dup (pass); bucket->password = mhl_str_dup (pass);
@ -262,9 +262,9 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket,
(domain ? domain : lp_workgroup ()), (domain ? domain : lp_workgroup ()),
user); user);
if (auth) { if (auth) {
mhl_mem_free (bucket->domain); g_free (bucket->domain);
mhl_mem_free (bucket->user); g_free (bucket->user);
mhl_mem_free (bucket->password); g_free (bucket->password);
bucket->domain = mhl_str_dup (auth->domain); bucket->domain = mhl_str_dup (auth->domain);
bucket->user = mhl_str_dup (auth->user); bucket->user = mhl_str_dup (auth->user);
bucket->password = mhl_str_dup (auth->password); 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, "/", smbfs_connections[i].service,
NULL); NULL);
(*func)(path); (*func)(path);
mhl_mem_free (path); g_free (path);
} }
} }
} }
@ -612,10 +612,10 @@ smbfs_reconnect(smbfs_connection *conn, int *retries)
if (!(conn->cli = smbfs_do_connect(host, conn->service))) { if (!(conn->cli = smbfs_do_connect(host, conn->service))) {
message (D_ERROR, MSG_ERROR, message (D_ERROR, MSG_ERROR,
_(" reconnect to %s failed\n "), conn->host); _(" reconnect to %s failed\n "), conn->host);
mhl_mem_free(host); g_free(host);
return False; return False;
} }
mhl_mem_free(host); g_free(host);
if (++(*retries) == 2) if (++(*retries) == 2)
return False; return False;
return True; return True;
@ -783,12 +783,12 @@ smbfs_loaddir (opendir_info *smbfs_info)
smbfs_loaddir_helper, NULL) < 0) { smbfs_loaddir_helper, NULL) < 0) {
/* cli_list returns -1 if directory empty or cannot read socket */ /* cli_list returns -1 if directory empty or cannot read socket */
my_errno = cli_error (smbfs_info->conn->cli, NULL, &err, NULL); my_errno = cli_error (smbfs_info->conn->cli, NULL, &err, NULL);
mhl_mem_free (my_dirname); g_free (my_dirname);
return 0; return 0;
} }
if (*(my_dirname) == 0) if (*(my_dirname) == 0)
smbfs_info->dirname = smbfs_info->conn->service; smbfs_info->dirname = smbfs_info->conn->service;
mhl_mem_free (my_dirname); g_free (my_dirname);
/* do_dskattr(); */ /* do_dskattr(); */
done: done:
@ -805,8 +805,8 @@ smbfs_free_dir (dir_entry *de)
if (!de) return; if (!de) return;
smbfs_free_dir (de->next); smbfs_free_dir (de->next);
mhl_mem_free (de->text); g_free (de->text);
mhl_mem_free (de); g_free (de);
} }
#endif #endif
@ -855,10 +855,10 @@ smbfs_closedir (void *info)
/* for (p = smbfs_info->entries; p;){ /* for (p = smbfs_info->entries; p;){
q = p; q = p;
p = p->next; p = p->next;
mhl_mem_free (q->text); g_free (q->text);
mhl_mem_free (q); g_free (q);
} }
mhl_mem_free (info); */ g_free (info); */
return 0; return 0;
} }
@ -1043,12 +1043,12 @@ smbfs_get_master_browser(char **host)
static void static void
smbfs_free_bucket (smbfs_connection *bucket) smbfs_free_bucket (smbfs_connection *bucket)
{ {
mhl_mem_free (bucket->host); g_free (bucket->host);
mhl_mem_free (bucket->service); g_free (bucket->service);
mhl_mem_free (bucket->domain); g_free (bucket->domain);
mhl_mem_free (bucket->user); g_free (bucket->user);
wipe_password (bucket->password); wipe_password (bucket->password);
mhl_mem_free (bucket->home); g_free (bucket->home);
memset (bucket, 0, sizeof (smbfs_connection)); 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 (!(*host)) { /* if blank host name, browse for servers */
if (!smbfs_get_master_browser (&host)) /* set host to ip of master browser */ if (!smbfs_get_master_browser (&host)) /* set host to ip of master browser */
return 0; /* could not find master browser? */ return 0; /* could not find master browser? */
mhl_mem_free (host); g_free (host);
bucket->host = mhl_str_dup (""); /* blank host means master browser */ bucket->host = mhl_str_dup (""); /* blank host means master browser */
} else } else
bucket->host = mhl_str_dup (host); 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))) smbfs_get_host_and_username (&path, &host, &user, &port, &pass)))
if ((*sc = if ((*sc =
smbfs_open_link (host, remote_path, user, &port, pass)) == NULL) { smbfs_open_link (host, remote_path, user, &port, pass)) == NULL) {
mhl_mem_free (remote_path); g_free (remote_path);
remote_path = NULL; remote_path = NULL;
} }
mhl_mem_free (host); g_free (host);
mhl_mem_free (user); g_free (user);
if (pass) if (pass)
wipe_password (pass); wipe_password (pass);
@ -1218,7 +1218,7 @@ smbfs_get_path (smbfs_connection ** sc, const char *path)
if (f || !strncmp (remote_path, "/~/", 3)) { if (f || !strncmp (remote_path, "/~/", 3)) {
char *s; char *s;
s = mhl_str_dir_plus_file ((*sc)->home, remote_path + 3 - f); s = mhl_str_dir_plus_file ((*sc)->home, remote_path + 3 - f);
mhl_mem_free (remote_path); g_free (remote_path);
return s; return s;
} }
} }
@ -1308,7 +1308,7 @@ smbfs_fake_share_stat (const char *server_url, const char *path, struct stat *bu
smbfs_connection *sc; smbfs_connection *sc;
char *p; char *p;
p = smbfs_get_path (&sc, path); p = smbfs_get_path (&sc, path);
mhl_mem_free (p); g_free (p);
if (p) { if (p) {
memset (buf, 0, sizeof (*buf)); memset (buf, 0, sizeof (*buf));
/* show this as dir */ /* show this as dir */
@ -1372,16 +1372,16 @@ smbfs_get_remote_stat (smbfs_connection * sc, const char *path, struct stat *buf
if (cli_list if (cli_list
(sc->cli, mypath, attribute, smbfs_loaddir_helper, single_entry) < 1) { (sc->cli, mypath, attribute, smbfs_loaddir_helper, single_entry) < 1) {
my_errno = ENOENT; my_errno = ENOENT;
mhl_mem_free (mypath); g_free (mypath);
return -1; /* cli_list returns number of files */ return -1; /* cli_list returns number of files */
} }
memcpy (buf, &single_entry->my_stat, sizeof (struct stat)); memcpy (buf, &single_entry->my_stat, sizeof (struct stat));
/* don't free here, use for smbfs_fstat() */ /* don't free here, use for smbfs_fstat() */
/* mhl_mem_free(single_entry->text); /* g_free(single_entry->text);
mhl_mem_free(single_entry); */ g_free(single_entry); */
mhl_mem_free (mypath); g_free (mypath);
return 0; 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)); memset (buf, 0, sizeof (struct stat));
buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask; buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask;
memcpy (&single_entry->my_stat, buf, sizeof (struct stat)); memcpy (&single_entry->my_stat, buf, sizeof (struct stat));
mhl_mem_free (mdp); g_free (mdp);
DEBUG (1, (" PARENT:found in %s\n", current_info->dirname)); DEBUG (1, (" PARENT:found in %s\n", current_info->dirname));
return 0; return 0;
} }
mhl_mem_free (mdp); g_free (mdp);
} }
/* now try to identify as CURRENT dir? */ /* 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)); DEBUG (3, ("smbfs_chdir(path:%s)\n", path));
if (!(remote_dir = smbfs_get_path (&sc, path))) if (!(remote_dir = smbfs_get_path (&sc, path)))
return -1; return -1;
mhl_mem_free (remote_dir); g_free (remote_dir);
return 0; 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)); DEBUG(6, ("smbfs_loaddir_by_name(%s)\n", mypath));
smbfs_chdir(me, mypath); smbfs_chdir(me, mypath);
info = smbfs_opendir (me, mypath); info = smbfs_opendir (me, mypath);
mhl_mem_free(mypath); g_free(mypath);
if (!info) if (!info)
return -1; return -1;
smbfs_readdir(info); 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")); DEBUG (1, ("smbfs_stat: showing server as directory\n"));
memset (buf, 0, sizeof (struct stat)); memset (buf, 0, sizeof (struct stat));
buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask; buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask;
mhl_mem_free (service); g_free (service);
return 0; 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) { if (strncmp (p, pp, strlen (p)) != 0) {
DEBUG (6, ("desired '%s' is not loaded, we have '%s'\n", p, pp)); DEBUG (6, ("desired '%s' is not loaded, we have '%s'\n", p, pp));
if (smbfs_loaddir_by_name (me, path) < 0) { if (smbfs_loaddir_by_name (me, path) < 0) {
mhl_mem_free (service); g_free (service);
return -1; return -1;
} }
DEBUG (6, ("loaded dir: '%s'\n", current_info->dirname)); DEBUG (6, ("loaded dir: '%s'\n", current_info->dirname));
} }
mhl_mem_free (service); g_free (service);
/* stat dirs & files under shares now */ /* stat dirs & files under shares now */
return smbfs_get_stat_info (sc, path, buf); 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)); DEBUG (3, ("smbfs_mkdir(path:%s, mode:%d)\n", path, (int) mode));
if ((remote_file = smbfs_get_path (&sc, path)) == 0) if ((remote_file = smbfs_get_path (&sc, path)) == 0)
return -1; return -1;
mhl_mem_free (remote_file); g_free (remote_file);
cpath = smbfs_convert_path (path, FALSE); cpath = smbfs_convert_path (path, FALSE);
if (!cli_mkdir (sc->cli, cpath)) { if (!cli_mkdir (sc->cli, cpath)) {
my_errno = cli_error (sc->cli, NULL, &err, NULL); my_errno = cli_error (sc->cli, NULL, &err, NULL);
message (D_ERROR, MSG_ERROR, _(" Error %s creating directory %s "), message (D_ERROR, MSG_ERROR, _(" Error %s creating directory %s "),
cli_errstr (sc->cli), CNV_LANG (cpath)); cli_errstr (sc->cli), CNV_LANG (cpath));
mhl_mem_free (cpath); g_free (cpath);
return -1; return -1;
} }
mhl_mem_free (cpath); g_free (cpath);
return 0; return 0;
} }
@ -1712,18 +1712,18 @@ smbfs_rmdir (struct vfs_class *me, const char *path)
DEBUG(3, ("smbfs_rmdir(path:%s)\n", path)); DEBUG(3, ("smbfs_rmdir(path:%s)\n", path));
if ((remote_file = smbfs_get_path (&sc, path)) == 0) if ((remote_file = smbfs_get_path (&sc, path)) == 0)
return -1; return -1;
mhl_mem_free (remote_file); g_free (remote_file);
cpath = smbfs_convert_path (path, FALSE); cpath = smbfs_convert_path (path, FALSE);
if (!cli_rmdir(sc->cli, cpath)) { if (!cli_rmdir(sc->cli, cpath)) {
my_errno = cli_error(sc->cli, NULL, &err, NULL); my_errno = cli_error(sc->cli, NULL, &err, NULL);
message (D_ERROR, MSG_ERROR, _(" Error %s removing directory %s "), message (D_ERROR, MSG_ERROR, _(" Error %s removing directory %s "),
cli_errstr(sc->cli), CNV_LANG(cpath)); cli_errstr(sc->cli), CNV_LANG(cpath));
mhl_mem_free (cpath); g_free (cpath);
return -1; return -1;
} }
mhl_mem_free (cpath); g_free (cpath);
return 0; return 0;
} }
@ -1763,7 +1763,7 @@ smbfs_forget (const char *path)
path += 2; path += 2;
if ((p = smbfs_get_host_and_username (&path, &host, &user, &port, NULL))) { if ((p = smbfs_get_host_and_username (&path, &host, &user, &port, NULL))) {
mhl_mem_free (p); g_free (p);
for (i = 0; i < SMBFS_MAX_CONNECTIONS; i++) { for (i = 0; i < SMBFS_MAX_CONNECTIONS; i++) {
if (smbfs_connections[i].cli if (smbfs_connections[i].cli
&& (strcmp (host, smbfs_connections[i].host) == 0) && (strcmp (host, smbfs_connections[i].host) == 0)
@ -1779,8 +1779,8 @@ smbfs_forget (const char *path)
} }
} }
} }
mhl_mem_free (host); g_free (host);
mhl_mem_free (user); g_free (user);
} }
static int 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); ret = smbfs_open_readwrite (remote_handle, remote_file, flags, mode);
mhl_mem_free (remote_file); g_free (remote_file);
if (!ret) if (!ret)
mhl_mem_free (remote_handle); g_free (remote_handle);
return ret; return ret;
} }
@ -1900,10 +1900,10 @@ smbfs_unlink (struct vfs_class *me, const char *path)
if (!cli_unlink(sc->cli, remote_file)) { if (!cli_unlink(sc->cli, remote_file)) {
message (D_ERROR, MSG_ERROR, _(" %s removing remote file %s "), message (D_ERROR, MSG_ERROR, _(" %s removing remote file %s "),
cli_errstr(sc->cli), CNV_LANG(remote_file)); cli_errstr(sc->cli), CNV_LANG(remote_file));
mhl_mem_free (remote_file); g_free (remote_file);
return -1; return -1;
} }
mhl_mem_free (remote_file); g_free (remote_file);
return 0; return 0;
} }
@ -1920,7 +1920,7 @@ smbfs_rename (struct vfs_class *me, const char *a, const char *b)
return -1; return -1;
if ((rb = smbfs_get_path (&sc, b)) == 0) { if ((rb = smbfs_get_path (&sc, b)) == 0) {
mhl_mem_free (ra); g_free (ra);
return -1; 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); retval = cli_rename(sc->cli, ra, rb);
mhl_mem_free (ra); g_free (ra);
mhl_mem_free (rb); g_free (rb);
if (!retval) { if (!retval) {
message (D_ERROR, MSG_ERROR, _(" %s renaming files\n"), message (D_ERROR, MSG_ERROR, _(" %s renaming files\n"),

View File

@ -35,8 +35,6 @@
#include <sys/mknod.h> #include <sys/mknod.h>
#endif #endif
#include <mhl/memory.h>
#include "../src/global.h" #include "../src/global.h"
#include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/tty.h" /* enable/disable interrupt key */
#include "../src/wtools.h" /* message() */ #include "../src/wtools.h" /* message() */
@ -248,7 +246,7 @@ tar_open_archive_int (struct vfs_class *me, const char *name,
result = mc_open (s, O_RDONLY); result = mc_open (s, O_RDONLY);
if (result == -1) if (result == -1)
message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), s); message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), s);
mhl_mem_free (s); g_free (s);
if (result == -1) if (result == -1)
ERRNOR (ENOENT, -1); ERRNOR (ENOENT, -1);
} }
@ -496,13 +494,13 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
longp = ((header->header.linkflag == LF_LONGNAME) longp = ((header->header.linkflag == LF_LONGNAME)
? &next_long_name : &next_long_link); ? &next_long_name : &next_long_link);
mhl_mem_free (*longp); g_free (*longp);
bp = *longp = g_malloc (*h_size + 1); bp = *longp = g_malloc (*h_size + 1);
for (size = *h_size; size > 0; size -= written) { for (size = *h_size; size > 0; size -= written) {
data = tar_get_next_record (archive, tard)->charptr; data = tar_get_next_record (archive, tard)->charptr;
if (data == NULL) { if (data == NULL) {
mhl_mem_free (*longp); g_free (*longp);
*longp = NULL; *longp = NULL;
message (D_ERROR, MSG_ERROR, message (D_ERROR, MSG_ERROR,
_("Unexpected EOF on archive file")); _("Unexpected EOF on archive file"));
@ -517,7 +515,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
} }
if (bp - *longp == MC_MAXPATHLEN && bp[-1] != '\0') { if (bp - *longp == MC_MAXPATHLEN && bp[-1] != '\0') {
mhl_mem_free (*longp); g_free (*longp);
*longp = NULL; *longp = NULL;
message (D_ERROR, MSG_ERROR, _("Inconsistent tar archive")); message (D_ERROR, MSG_ERROR, _("Inconsistent tar archive"));
return STATUS_BADCHECKSUM; return STATUS_BADCHECKSUM;
@ -562,8 +560,8 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
PREFIX_SIZE); PREFIX_SIZE);
current_file_name = g_strconcat (temp_prefix, PATH_SEP_STR, current_file_name = g_strconcat (temp_prefix, PATH_SEP_STR,
temp_name, (char *) NULL); temp_name, (char *) NULL);
mhl_mem_free (temp_name); g_free (temp_name);
mhl_mem_free (temp_prefix); g_free (temp_prefix);
} }
break; break;
case TAR_GNU: case TAR_GNU:
@ -607,7 +605,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
} else { } else {
entry = vfs_s_new_entry (me, p, inode); entry = vfs_s_new_entry (me, p, inode);
vfs_s_insert_entry (me, parent, entry); vfs_s_insert_entry (me, parent, entry);
mhl_mem_free (current_link_name); g_free (current_link_name);
goto done; goto done;
} }
} }
@ -619,12 +617,12 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
if (*current_link_name) { if (*current_link_name) {
inode->linkname = current_link_name; inode->linkname = current_link_name;
} else if (current_link_name != next_long_link) { } else if (current_link_name != next_long_link) {
mhl_mem_free (current_link_name); g_free (current_link_name);
} }
entry = vfs_s_new_entry (me, p, inode); entry = vfs_s_new_entry (me, p, inode);
vfs_s_insert_entry (me, parent, entry); vfs_s_insert_entry (me, parent, entry);
mhl_mem_free (current_file_name); g_free (current_file_name);
done: done:
next_long_link = next_long_name = NULL; next_long_link = next_long_name = NULL;

View File

@ -35,8 +35,8 @@
*/ */
#include <config.h> #include <config.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -101,11 +101,11 @@ undelfs_shutdown (void)
if (fs) if (fs)
ext2fs_close (fs); ext2fs_close (fs);
fs = NULL; fs = NULL;
mhl_mem_free (ext2_fname); g_free (ext2_fname);
ext2_fname = NULL; ext2_fname = NULL;
mhl_mem_free (delarray); g_free (delarray);
delarray = NULL; delarray = NULL;
mhl_mem_free (block_buf); g_free (block_buf);
block_buf = NULL; block_buf = NULL;
} }
@ -146,7 +146,7 @@ undelfs_get_path (const char *dirname, char **fsname, char **file)
*file = mhl_str_dup (p+1); *file = mhl_str_dup (p+1);
tmp = g_strndup (dirname, p - dirname); tmp = g_strndup (dirname, p - dirname);
*fsname = g_strconcat ("/dev/", tmp, (char *) NULL); *fsname = g_strconcat ("/dev/", tmp, (char *) NULL);
mhl_mem_free (tmp); g_free (tmp);
return; return;
} }
p--; p--;
@ -276,10 +276,10 @@ undelfs_loaddel (void)
error_out: error_out:
ext2fs_close_inode_scan (scan); ext2fs_close_inode_scan (scan);
free_block_buf: free_block_buf:
mhl_mem_free (block_buf); g_free (block_buf);
block_buf = NULL; block_buf = NULL;
free_delarray: free_delarray:
mhl_mem_free (delarray); g_free (delarray);
delarray = NULL; delarray = NULL;
return 0; return 0;
} }
@ -301,7 +301,7 @@ com_err (const char *whoami, long err_code, const char *fmt, ...)
message (D_ERROR, _(" Ext2lib error "), " %s (%s: %ld) ", str, whoami, message (D_ERROR, _(" Ext2lib error "), " %s (%s: %ld) ", str, whoami,
err_code); err_code);
mhl_mem_free (str); g_free (str);
} }
static void * static void *
@ -314,7 +314,7 @@ undelfs_opendir (struct vfs_class *me, const char *dirname)
return 0; return 0;
/* We don't use the file name */ /* We don't use the file name */
mhl_mem_free (f); g_free (f);
if (!ext2_fname || strcmp (ext2_fname, file)){ if (!ext2_fname || strcmp (ext2_fname, file)){
undelfs_shutdown (); undelfs_shutdown ();
@ -322,7 +322,7 @@ undelfs_opendir (struct vfs_class *me, const char *dirname)
} else { } else {
/* To avoid expensive re-scannings */ /* To avoid expensive re-scannings */
readdir_ptr = READDIR_PTR_INIT; readdir_ptr = READDIR_PTR_INIT;
mhl_mem_free (file); g_free (file);
return fs; return fs;
} }
@ -418,8 +418,8 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
if (!ext2_fname || strcmp (ext2_fname, file)) { if (!ext2_fname || strcmp (ext2_fname, file)) {
message (D_ERROR, undelfserr, message (D_ERROR, undelfserr,
_(" You have to chdir to extract files first ")); _(" You have to chdir to extract files first "));
mhl_mem_free (file); g_free (file);
mhl_mem_free (f); g_free (f);
return 0; return 0;
} }
inode = atol (f); inode = atol (f);
@ -432,15 +432,15 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
/* Found: setup all the structures needed by read */ /* Found: setup all the structures needed by read */
p = (undelfs_file *) g_try_malloc (((gsize) sizeof (undelfs_file))); p = (undelfs_file *) g_try_malloc (((gsize) sizeof (undelfs_file)));
if (!p) { if (!p) {
mhl_mem_free (file); g_free (file);
mhl_mem_free (f); g_free (f);
return 0; return 0;
} }
p->buf = g_try_malloc (fs->blocksize); p->buf = g_try_malloc (fs->blocksize);
if (!p->buf) { if (!p->buf) {
mhl_mem_free (p); g_free (p);
mhl_mem_free (file); g_free (file);
mhl_mem_free (f); g_free (f);
return 0; return 0;
} }
p->inode = inode; p->inode = inode;
@ -450,8 +450,8 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
p->pos = 0; p->pos = 0;
p->size = delarray[i].size; p->size = delarray[i].size;
} }
mhl_mem_free (file); g_free (file);
mhl_mem_free (f); g_free (f);
undelfs_usage++; undelfs_usage++;
return p; return p;
} }
@ -460,8 +460,8 @@ static int
undelfs_close (void *vfs_info) undelfs_close (void *vfs_info)
{ {
undelfs_file *p = vfs_info; undelfs_file *p = vfs_info;
mhl_mem_free (p->buf); g_free (p->buf);
mhl_mem_free (p); g_free (p);
undelfs_usage--; undelfs_usage--;
return 0; return 0;
} }
@ -595,20 +595,20 @@ undelfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
f = "sda1" f ="401:1" f = "sda1" f ="401:1"
If the first char in f is no digit -> return error */ If the first char in f is no digit -> return error */
if (!isdigit (*f)) { if (!isdigit (*f)) {
mhl_mem_free (file); g_free (file);
mhl_mem_free (f); g_free (f);
return -1; return -1;
} }
if (!ext2_fname || strcmp (ext2_fname, file)){ if (!ext2_fname || strcmp (ext2_fname, file)){
message (D_ERROR, undelfserr, _(" You have to chdir to extract files first ")); message (D_ERROR, undelfserr, _(" You have to chdir to extract files first "));
mhl_mem_free (file); g_free (file);
mhl_mem_free (f); g_free (f);
return 0; return 0;
} }
inode_index = undelfs_getindex (f); inode_index = undelfs_getindex (f);
mhl_mem_free (file); g_free (file);
mhl_mem_free (f); g_free (f);
if (inode_index == -1) if (inode_index == -1)
return -1; return -1;
@ -641,13 +641,13 @@ undelfs_chdir(struct vfs_class *me, const char *path)
/* our vfs, but that is left as an excercise for the reader */ /* our vfs, but that is left as an excercise for the reader */
if ((fd = open (file, O_RDONLY)) == -1){ if ((fd = open (file, O_RDONLY)) == -1){
message (D_ERROR, undelfserr, _(" Cannot open file %s "), file); message (D_ERROR, undelfserr, _(" Cannot open file %s "), file);
mhl_mem_free (f); g_free (f);
mhl_mem_free (file); g_free (file);
return -1; return -1;
} }
close (fd); close (fd);
mhl_mem_free (f); g_free (f);
mhl_mem_free (file); g_free (file);
return 0; return 0;
} }
@ -667,8 +667,8 @@ undelfs_getid (struct vfs_class *me, const char *path)
if (!fsname) if (!fsname)
return NULL; return NULL;
mhl_mem_free (fname); g_free (fname);
mhl_mem_free (fsname); g_free (fsname);
return (vfsid) fs; return (vfsid) fs;
} }

View File

@ -138,7 +138,7 @@ vfs_split_url (const char *path, char **host, char **user, int *port,
if (host) if (host)
*host = mhl_str_dup (rest); *host = mhl_str_dup (rest);
mhl_mem_free (pcopy); g_free (pcopy);
return retval; return retval;
} }
#endif /* USE_NETCODE */ #endif /* USE_NETCODE */
@ -243,7 +243,7 @@ vfs_mkstemps (char **pname, const char *prefix, const char *basename)
*q = 0; *q = 0;
fd = mc_mkstemps (pname, prefix, suffix); fd = mc_mkstemps (pname, prefix, suffix);
mhl_mem_free (suffix); g_free (suffix);
return fd; return fd;
} }
@ -874,7 +874,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename,
t[p] = 0; t[p] = 0;
} }
mhl_mem_free (p_copy); g_free (p_copy);
return 1; return 1;
error: error:
@ -889,7 +889,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename,
_("More parsing errors will be ignored.")); _("More parsing errors will be ignored."));
} }
mhl_mem_free (p_copy); g_free (p_copy);
return 0; return 0;
} }

View File

@ -38,7 +38,6 @@
#include <signal.h> #include <signal.h>
#include <ctype.h> /* is_digit() */ #include <ctype.h> /* is_digit() */
#include <mhl/memory.h>
#include <mhl/string.h> #include <mhl/string.h>
#include "../src/global.h" #include "../src/global.h"
@ -223,7 +222,7 @@ path_magic (const char *path)
/* /*
* Splits path '/p1#op/inpath' into inpath,op; returns which vfs it is. * Splits path '/p1#op/inpath' into inpath,op; returns which vfs it is.
* What is left in path is p1. You still want to mhl_mem_free(path), you DON'T * What is left in path is p1. You still want to g_free(path), you DON'T
* want to free neither *inpath nor *op * want to free neither *inpath nor *op
*/ */
struct vfs_class * struct vfs_class *
@ -304,7 +303,7 @@ vfs_get_class (const char *pathname)
char *path = mhl_str_dup (pathname); char *path = mhl_str_dup (pathname);
vfs = _vfs_get_class (path); vfs = _vfs_get_class (path);
mhl_mem_free (path); g_free (path);
if (!vfs) if (!vfs)
vfs = localfs_class; vfs = localfs_class;
@ -338,13 +337,13 @@ mc_open (const char *filename, int flags, ...)
mode = 0; mode = 0;
if (!vfs->open) { if (!vfs->open) {
mhl_mem_free (file); g_free (file);
errno = -EOPNOTSUPP; errno = -EOPNOTSUPP;
return -1; return -1;
} }
info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */ info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */
mhl_mem_free (file); g_free (file);
if (!info){ if (!info){
errno = ferrno (vfs); errno = ferrno (vfs);
return -1; return -1;
@ -362,7 +361,7 @@ int mc_##name inarg \
char *mpath = vfs_canon (path); \ char *mpath = vfs_canon (path); \
vfs = vfs_get_class (mpath); \ vfs = vfs_get_class (mpath); \
result = vfs->name ? (*vfs->name)callarg : -1; \ result = vfs->name ? (*vfs->name)callarg : -1; \
mhl_mem_free (mpath); \ g_free (mpath); \
if (result == -1) \ if (result == -1) \
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
return result; \ return result; \
@ -407,13 +406,13 @@ int mc_##name (const char *fname1, const char *fname2) \
name2 = vfs_canon (fname2); \ name2 = vfs_canon (fname2); \
if (vfs != vfs_get_class (name2)){ \ if (vfs != vfs_get_class (name2)){ \
errno = EXDEV; \ errno = EXDEV; \
mhl_mem_free (name1); \ g_free (name1); \
mhl_mem_free (name2); \ g_free (name2); \
return -1; \ return -1; \
} \ } \
result = vfs->name ? (*vfs->name)(vfs, name1, name2) : -1; \ result = vfs->name ? (*vfs->name)(vfs, name1, name2) : -1; \
mhl_mem_free (name1); \ g_free (name1); \
mhl_mem_free (name2); \ g_free (name2); \
if (result == -1) \ if (result == -1) \
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \ errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
return result; \ return result; \
@ -444,7 +443,7 @@ mc_setctl (const char *path, int ctlop, void *arg)
mpath = vfs_canon (path); mpath = vfs_canon (path);
vfs = vfs_get_class (mpath); vfs = vfs_get_class (mpath);
result = vfs->setctl ? (*vfs->setctl)(vfs, mpath, ctlop, arg) : 0; result = vfs->setctl ? (*vfs->setctl)(vfs, mpath, ctlop, arg) : 0;
mhl_mem_free (mpath); g_free (mpath);
return result; return result;
} }
@ -483,7 +482,7 @@ mc_opendir (const char *dirname)
vfs = vfs_get_class (dname); vfs = vfs_get_class (dname);
info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL; info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL;
mhl_mem_free (dname); g_free (dname);
if (!info){ if (!info){
errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP; errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP;
return NULL; return NULL;
@ -524,7 +523,7 @@ mc_closedir (DIR *dirp)
result = vfs->closedir ? (*vfs->closedir)(vfs_info (handle)) : -1; result = vfs->closedir ? (*vfs->closedir)(vfs_info (handle)) : -1;
vfs_free_handle (handle); vfs_free_handle (handle);
mhl_mem_free (dirp); g_free (dirp);
return result; return result;
} }
@ -534,7 +533,7 @@ int mc_stat (const char *filename, struct stat *buf) {
char *path; char *path;
path = vfs_canon (filename); vfs = vfs_get_class (path); path = vfs_canon (filename); vfs = vfs_get_class (path);
result = vfs->stat ? (*vfs->stat) (vfs, path, buf) : -1; result = vfs->stat ? (*vfs->stat) (vfs, path, buf) : -1;
mhl_mem_free (path); g_free (path);
if (result == -1) if (result == -1)
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; errno = vfs->name ? ferrno (vfs) : E_NOTSUPP;
return result; return result;
@ -546,7 +545,7 @@ int mc_lstat (const char *filename, struct stat *buf) {
char *path; char *path;
path = vfs_canon (filename); vfs = vfs_get_class (path); path = vfs_canon (filename); vfs = vfs_get_class (path);
result = vfs->lstat ? (*vfs->lstat) (vfs, path, buf) : -1; result = vfs->lstat ? (*vfs->lstat) (vfs, path, buf) : -1;
mhl_mem_free (path); g_free (path);
if (result == -1) if (result == -1)
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; errno = vfs->name ? ferrno (vfs) : E_NOTSUPP;
return result; return result;
@ -585,11 +584,11 @@ _vfs_get_cwd (void)
|| mc_stat (current_dir, &my_stat2) || mc_stat (current_dir, &my_stat2)
|| my_stat.st_ino != my_stat2.st_ino || my_stat.st_ino != my_stat2.st_ino
|| my_stat.st_dev != my_stat2.st_dev) { || my_stat.st_dev != my_stat2.st_dev) {
mhl_mem_free (current_dir); g_free (current_dir);
current_dir = p; current_dir = p;
return p; return p;
} /* Otherwise we return current_dir below */ } /* Otherwise we return current_dir below */
mhl_mem_free (p); g_free (p);
} }
return current_dir; return current_dir;
} }
@ -662,7 +661,7 @@ vfs_canon (const char *path)
local = mhl_str_dir_plus_file (current_dir, path); local = mhl_str_dir_plus_file (current_dir, path);
result = vfs_canon (local); result = vfs_canon (local);
mhl_mem_free (local); g_free (local);
return result; return result;
} }
@ -692,7 +691,7 @@ mc_chdir (const char *path)
new_dir = vfs_canon (path); new_dir = vfs_canon (path);
new_vfs = vfs_get_class (new_dir); new_vfs = vfs_get_class (new_dir);
if (!new_vfs->chdir) { if (!new_vfs->chdir) {
mhl_mem_free (new_dir); g_free (new_dir);
return -1; return -1;
} }
@ -700,7 +699,7 @@ mc_chdir (const char *path)
if (result == -1) { if (result == -1) {
errno = ferrno (new_vfs); errno = ferrno (new_vfs);
mhl_mem_free (new_dir); g_free (new_dir);
return -1; return -1;
} }
@ -708,7 +707,7 @@ mc_chdir (const char *path)
old_vfs = current_vfs; old_vfs = current_vfs;
/* Actually change directory */ /* Actually change directory */
mhl_mem_free (current_dir); g_free (current_dir);
current_dir = new_dir; current_dir = new_dir;
current_vfs = new_vfs; current_vfs = new_vfs;
@ -742,7 +741,7 @@ vfs_file_class_flags (const char *filename)
fname = vfs_canon (filename); fname = vfs_canon (filename);
vfs = vfs_get_class (fname); vfs = vfs_get_class (fname);
mhl_mem_free (fname); g_free (fname);
return vfs->flags; return vfs->flags;
} }
@ -787,7 +786,7 @@ mc_def_getlocalcopy (const char *filename)
close (fdout); close (fdout);
if (fdin != -1) if (fdin != -1)
mc_close (fdin); mc_close (fdin);
mhl_mem_free (tmp); g_free (tmp);
return NULL; return NULL;
} }
@ -800,7 +799,7 @@ mc_getlocalcopy (const char *pathname)
result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs, path) : result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs, path) :
mc_def_getlocalcopy (path); mc_def_getlocalcopy (path);
mhl_mem_free (path); g_free (path);
if (!result) if (!result)
errno = ferrno (vfs); errno = ferrno (vfs);
return result; return result;
@ -863,7 +862,7 @@ mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed)
return_value = vfs->ungetlocalcopy ? return_value = vfs->ungetlocalcopy ?
(*vfs->ungetlocalcopy)(vfs, path, local, has_changed) : (*vfs->ungetlocalcopy)(vfs, path, local, has_changed) :
mc_def_ungetlocalcopy (vfs, path, local, has_changed); mc_def_ungetlocalcopy (vfs, path, local, has_changed);
mhl_mem_free (path); g_free (path);
return return_value; return return_value;
} }
@ -907,7 +906,7 @@ vfs_shut (void)
vfs_gc_done (); vfs_gc_done ();
mhl_mem_free (current_dir); g_free (current_dir);
for (vfs = vfs_list; vfs; vfs = vfs->next) for (vfs = vfs_list; vfs; vfs = vfs->next)
if (vfs->done) if (vfs->done)