mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
replaced g_free() by mhl_mem_free()
This commit is contained in:
parent
8bc0e27a54
commit
15d7d47c15
@ -1,5 +1,10 @@
|
||||
|
||||
2009-01-30 Enrico Weigelt, metux ITS <weigelt@metux.de>
|
||||
|
||||
* replaced calls to g_free() by mhl_mem_free()
|
||||
|
||||
2009-01-29 Mikhail S. Pobolovets <styx.mp@gmail.com>
|
||||
|
||||
* lib/mc.ext.in: update for OpenOffice and StarOffice viewer.
|
||||
odt2txt is now used
|
||||
|
||||
|
@ -28,11 +28,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -158,13 +159,13 @@ int book_mark_clear (WEdit * edit, int line, int c)
|
||||
p->prev->next = p->next;
|
||||
if (p->next)
|
||||
p->next->prev = p->prev;
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* if there is only our dummy book mark left, clear it for speed */
|
||||
if (edit->book_mark->line == -1 && !edit->book_mark->next) {
|
||||
g_free (edit->book_mark);
|
||||
mhl_mem_free (edit->book_mark);
|
||||
edit->book_mark = 0;
|
||||
}
|
||||
return r;
|
||||
@ -185,11 +186,11 @@ void book_mark_flush (WEdit * edit, int c)
|
||||
q->prev->next = q->next;
|
||||
if (p)
|
||||
p->prev = q->prev;
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
}
|
||||
}
|
||||
if (!edit->book_mark->next) {
|
||||
g_free (edit->book_mark);
|
||||
mhl_mem_free (edit->book_mark);
|
||||
edit->book_mark = 0;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,9 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "edit.h"
|
||||
#include "../src/global.h"
|
||||
#include "../src/wtools.h"
|
||||
@ -70,9 +73,9 @@ edit_syntax_dialog (void) {
|
||||
|
||||
if ((syntax = exec_edit_syntax_dialog ((const char**) names)) < 0) {
|
||||
for (i = 0; names[i]; i++) {
|
||||
g_free (names[i]);
|
||||
mhl_mem_free (names[i]);
|
||||
}
|
||||
g_free (names);
|
||||
mhl_mem_free (names);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -88,7 +91,7 @@ edit_syntax_dialog (void) {
|
||||
break;
|
||||
default:
|
||||
option_auto_syntax = 0;
|
||||
g_free (option_syntax_type);
|
||||
mhl_mem_free (option_syntax_type);
|
||||
option_syntax_type = g_strdup (names[syntax - N_DFLT_ENTRIES]);
|
||||
}
|
||||
|
||||
@ -100,8 +103,8 @@ edit_syntax_dialog (void) {
|
||||
edit_load_syntax (wedit, NULL, option_syntax_type);
|
||||
|
||||
for (i = 0; names[i]; i++) {
|
||||
g_free (names[i]);
|
||||
mhl_mem_free (names[i]);
|
||||
}
|
||||
g_free (names);
|
||||
g_free (old_syntax_type);
|
||||
mhl_mem_free (names);
|
||||
mhl_mem_free (old_syntax_type);
|
||||
}
|
||||
|
50
edit/edit.c
50
edit/edit.c
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
@ -30,9 +31,10 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -216,7 +218,7 @@ edit_get_filter (const char *filename)
|
||||
l = strlen (quoted_name);
|
||||
p = g_malloc (strlen (all_filters[i].read) + l + 2);
|
||||
sprintf (p, all_filters[i].read, quoted_name);
|
||||
g_free (quoted_name);
|
||||
mhl_mem_free (quoted_name);
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -232,7 +234,7 @@ edit_get_write_filter (const char *write_name, const char *filename)
|
||||
l = strlen (writename);
|
||||
p = g_malloc (strlen (all_filters[i].write) + l + 2);
|
||||
sprintf (p, all_filters[i].write, writename);
|
||||
g_free (writename);
|
||||
mhl_mem_free (writename);
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -276,7 +278,7 @@ edit_insert_file (WEdit *edit, const char *filename)
|
||||
g_string_sprintf (errmsg, _(" Error reading from pipe: %s "), p);
|
||||
edit_error_dialog (_("Error"), errmsg->str);
|
||||
g_string_free (errmsg, TRUE);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@ -284,10 +286,10 @@ edit_insert_file (WEdit *edit, const char *filename)
|
||||
g_string_sprintf (errmsg, _(" Cannot open pipe for reading: %s "), p);
|
||||
edit_error_dialog (_("Error"), errmsg->str);
|
||||
g_string_free (errmsg, TRUE);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
return 0;
|
||||
}
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
} else {
|
||||
int i, file, blocklen;
|
||||
long current = edit->curs1;
|
||||
@ -300,7 +302,7 @@ edit_insert_file (WEdit *edit, const char *filename)
|
||||
edit_insert (edit, buf[i]);
|
||||
}
|
||||
edit_cursor_move (edit, current - edit->curs1);
|
||||
g_free (buf);
|
||||
mhl_mem_free (buf);
|
||||
mc_close (file);
|
||||
if (blocklen)
|
||||
return 0;
|
||||
@ -447,7 +449,7 @@ edit_load_position (WEdit *edit)
|
||||
|
||||
filename = vfs_canon (edit->filename);
|
||||
load_file_position (filename, &line, &column);
|
||||
g_free (filename);
|
||||
mhl_mem_free (filename);
|
||||
|
||||
edit_move_to_line (edit, line - 1);
|
||||
edit->prev_col = column;
|
||||
@ -466,7 +468,7 @@ edit_save_position (WEdit *edit)
|
||||
|
||||
filename = vfs_canon (edit->filename);
|
||||
save_file_position (filename, edit->curs_line + 1, edit->curs_col);
|
||||
g_free (filename);
|
||||
mhl_mem_free (filename);
|
||||
}
|
||||
|
||||
/* Clean the WEdit stricture except the widget part */
|
||||
@ -540,7 +542,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
|
||||
if (edit_load_file (edit)) {
|
||||
/* edit_load_file already gives an error message */
|
||||
if (to_free)
|
||||
g_free (edit);
|
||||
mhl_mem_free (edit);
|
||||
return 0;
|
||||
}
|
||||
edit->loading_done = 1;
|
||||
@ -591,13 +593,13 @@ edit_clean (WEdit *edit)
|
||||
edit_free_syntax_rules (edit);
|
||||
book_mark_flush (edit, -1);
|
||||
for (; j <= MAXBUFF; j++) {
|
||||
g_free (edit->buffers1[j]);
|
||||
g_free (edit->buffers2[j]);
|
||||
mhl_mem_free (edit->buffers1[j]);
|
||||
mhl_mem_free (edit->buffers2[j]);
|
||||
}
|
||||
|
||||
g_free (edit->undo_stack);
|
||||
g_free (edit->filename);
|
||||
g_free (edit->dir);
|
||||
mhl_mem_free (edit->undo_stack);
|
||||
mhl_mem_free (edit->filename);
|
||||
mhl_mem_free (edit->dir);
|
||||
|
||||
edit_purge_widget (edit);
|
||||
|
||||
@ -637,12 +639,12 @@ edit_reload (WEdit *edit, const char *filename)
|
||||
e = g_malloc0 (sizeof (WEdit));
|
||||
e->widget = edit->widget;
|
||||
if (!edit_init (e, lines, columns, filename, 0)) {
|
||||
g_free (e);
|
||||
mhl_mem_free (e);
|
||||
return 0;
|
||||
}
|
||||
edit_clean (edit);
|
||||
memcpy (edit, e, sizeof (WEdit));
|
||||
g_free (e);
|
||||
mhl_mem_free (e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -928,7 +930,7 @@ int edit_delete (WEdit * edit)
|
||||
p = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1];
|
||||
|
||||
if (!(edit->curs2 & M_EDIT_BUF_SIZE)) {
|
||||
g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
|
||||
mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
|
||||
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = NULL;
|
||||
}
|
||||
edit->last_byte--;
|
||||
@ -965,7 +967,7 @@ edit_backspace (WEdit * edit)
|
||||
|
||||
p = *(edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE] + ((edit->curs1 - 1) & M_EDIT_BUF_SIZE));
|
||||
if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) {
|
||||
g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
|
||||
mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
|
||||
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL;
|
||||
}
|
||||
edit->last_byte--;
|
||||
@ -1050,7 +1052,7 @@ edit_move_backward_lots (WEdit *edit, long increment)
|
||||
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] =
|
||||
g_malloc (EDIT_BUF_SIZE);
|
||||
} else {
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
s = edit->curs1 & M_EDIT_BUF_SIZE;
|
||||
@ -1088,7 +1090,7 @@ edit_move_backward_lots (WEdit *edit, long increment)
|
||||
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] =
|
||||
g_malloc (EDIT_BUF_SIZE);
|
||||
} else {
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
}
|
||||
return edit_get_byte (edit, edit->curs1);
|
||||
@ -1124,7 +1126,7 @@ void edit_cursor_move (WEdit * edit, long increment)
|
||||
edit->curs2++;
|
||||
c = edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 - 1) & M_EDIT_BUF_SIZE];
|
||||
if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) {
|
||||
g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
|
||||
mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
|
||||
edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL;
|
||||
}
|
||||
edit->curs1--;
|
||||
@ -1148,7 +1150,7 @@ void edit_cursor_move (WEdit * edit, long increment)
|
||||
edit->curs1++;
|
||||
c = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1];
|
||||
if (!(edit->curs2 & M_EDIT_BUF_SIZE)) {
|
||||
g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
|
||||
mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
|
||||
edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = 0;
|
||||
}
|
||||
edit->curs2--;
|
||||
@ -2698,5 +2700,5 @@ user_menu (WEdit * edit)
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
|
||||
cleanup:
|
||||
g_free (block_file);
|
||||
mhl_mem_free (block_file);
|
||||
}
|
||||
|
126
edit/editcmd.c
126
edit/editcmd.c
@ -28,7 +28,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
@ -36,9 +35,10 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/history.h"
|
||||
|
||||
@ -166,7 +166,7 @@ catstrs (const char *first,...)
|
||||
len++;
|
||||
|
||||
i = (i + 1) % 16;
|
||||
g_free (stacked[i]);
|
||||
mhl_mem_free (stacked[i]);
|
||||
|
||||
stacked[i] = g_malloc (len);
|
||||
va_end (ap);
|
||||
@ -185,7 +185,7 @@ void freestrs(void)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sizeof(stacked) / sizeof(stacked[0]); i++) {
|
||||
g_free (stacked[i]);
|
||||
mhl_mem_free (stacked[i]);
|
||||
stacked[i] = NULL;
|
||||
}
|
||||
}
|
||||
@ -237,7 +237,7 @@ edit_save_file (WEdit *edit, const char *filename)
|
||||
if (*filename != PATH_SEP && edit->dir) {
|
||||
savename = concat_dir_and_file (edit->dir, filename);
|
||||
filename = catstrs (savename, (char *) NULL);
|
||||
g_free (savename);
|
||||
mhl_mem_free (savename);
|
||||
}
|
||||
|
||||
this_save_mode = option_save_mode;
|
||||
@ -302,9 +302,9 @@ edit_save_file (WEdit *edit, const char *filename)
|
||||
} else
|
||||
savedir = g_strdup (".");
|
||||
saveprefix = concat_dir_and_file (savedir, "cooledit");
|
||||
g_free (savedir);
|
||||
mhl_mem_free (savedir);
|
||||
fd = mc_mkstemps (&savename, saveprefix, NULL);
|
||||
g_free (saveprefix);
|
||||
mhl_mem_free (saveprefix);
|
||||
if (!savename)
|
||||
return 0;
|
||||
/* FIXME:
|
||||
@ -340,7 +340,7 @@ edit_save_file (WEdit *edit, const char *filename)
|
||||
edit_error_dialog (_("Error"),
|
||||
catstrs (_(" Error writing to pipe: "),
|
||||
p, " ", (char *) NULL));
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
goto error_save;
|
||||
}
|
||||
#endif
|
||||
@ -350,10 +350,10 @@ edit_save_file (WEdit *edit, const char *filename)
|
||||
(_
|
||||
(" Cannot open pipe for writing: "),
|
||||
p, " ", (char *) NULL)));
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
goto error_save;
|
||||
}
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
} else {
|
||||
long buf;
|
||||
buf = 0;
|
||||
@ -414,14 +414,14 @@ edit_save_file (WEdit *edit, const char *filename)
|
||||
if (this_save_mode != EDIT_QUICK_SAVE)
|
||||
if (mc_rename (savename, filename) == -1)
|
||||
goto error_save;
|
||||
g_free (savename);
|
||||
mhl_mem_free (savename);
|
||||
return 1;
|
||||
error_save:
|
||||
/* FIXME: Is this safe ?
|
||||
* if (this_save_mode != EDIT_QUICK_SAVE)
|
||||
* mc_unlink (savename);
|
||||
*/
|
||||
g_free (savename);
|
||||
mhl_mem_free (savename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -492,7 +492,7 @@ void menu_save_mode_cmd (void)
|
||||
return;
|
||||
option_save_mode = save_mode_new;
|
||||
|
||||
g_free (option_backup_ext);
|
||||
mhl_mem_free (option_backup_ext);
|
||||
option_backup_ext = str_result;
|
||||
str_result = NULL;
|
||||
}
|
||||
@ -500,7 +500,7 @@ void menu_save_mode_cmd (void)
|
||||
void
|
||||
edit_set_filename (WEdit *edit, const char *f)
|
||||
{
|
||||
g_free (edit->filename);
|
||||
mhl_mem_free (edit->filename);
|
||||
if (!f)
|
||||
f = "";
|
||||
edit->filename = g_strdup (f);
|
||||
@ -529,7 +529,7 @@ edit_save_as_cmd (WEdit *edit)
|
||||
|
||||
if (exp) {
|
||||
if (!*exp) {
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 0;
|
||||
} else {
|
||||
@ -546,7 +546,7 @@ edit_save_as_cmd (WEdit *edit)
|
||||
_(" A file already exists with this name. "),
|
||||
_("&Overwrite"), _("&Cancel"))) {
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -572,7 +572,7 @@ edit_save_as_cmd (WEdit *edit)
|
||||
}
|
||||
|
||||
edit_set_filename (edit, exp);
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
edit->modified = 0;
|
||||
edit->delete_file = 0;
|
||||
if (different_filename)
|
||||
@ -588,7 +588,7 @@ edit_save_as_cmd (WEdit *edit)
|
||||
/* Failed, so maintain modify (not save) lock */
|
||||
if (save_lock)
|
||||
edit_unlock_file (exp);
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 0;
|
||||
}
|
||||
@ -880,13 +880,13 @@ edit_load_file_from_filename (WEdit * edit, char *exp)
|
||||
char *prev_filename = g_strdup (edit->filename);
|
||||
|
||||
if (!edit_reload (edit, exp)) {
|
||||
g_free (prev_filename);
|
||||
mhl_mem_free (prev_filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (prev_locked)
|
||||
edit_unlock_file (prev_filename);
|
||||
g_free (prev_filename);
|
||||
mhl_mem_free (prev_filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -912,7 +912,7 @@ edit_load_cmd (WEdit *edit)
|
||||
if (exp) {
|
||||
if (*exp)
|
||||
edit_load_file_from_filename (edit, exp);
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
}
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 0;
|
||||
@ -1013,7 +1013,7 @@ edit_block_copy_cmd (WEdit *edit)
|
||||
edit_insert_ahead (edit, copy_buf[size]);
|
||||
}
|
||||
|
||||
g_free (copy_buf);
|
||||
mhl_mem_free (copy_buf);
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
|
||||
if (column_highlighting) {
|
||||
@ -1114,7 +1114,7 @@ edit_block_move_cmd (WEdit *edit)
|
||||
edit->curs1 + end_mark - start_mark, 0, 0);
|
||||
}
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
g_free (copy_buf);
|
||||
mhl_mem_free (copy_buf);
|
||||
edit->force |= REDRAW_PAGE;
|
||||
}
|
||||
|
||||
@ -1450,7 +1450,7 @@ string_regexp_search (char *pattern, char *string, int match_type,
|
||||
|| old_type != match_type || old_icase != icase) {
|
||||
if (old_pattern) {
|
||||
regfree (&r);
|
||||
g_free (old_pattern);
|
||||
mhl_mem_free (old_pattern);
|
||||
old_pattern = 0;
|
||||
}
|
||||
if (regcomp (&r, pattern, REG_EXTENDED | (icase ? REG_ICASE : 0) |
|
||||
@ -1826,9 +1826,9 @@ edit_replace_cmd (WEdit *edit, int again)
|
||||
int argord[NUM_REPL_ARGS];
|
||||
|
||||
if (!edit) {
|
||||
g_free (saved1), saved1 = NULL;
|
||||
g_free (saved2), saved2 = NULL;
|
||||
g_free (saved3), saved3 = NULL;
|
||||
mhl_mem_free (saved1), saved1 = NULL;
|
||||
mhl_mem_free (saved2), saved2 = NULL;
|
||||
mhl_mem_free (saved3), saved3 = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1856,9 +1856,9 @@ edit_replace_cmd (WEdit *edit, int again)
|
||||
edit_replace_dialog (edit, disp1, disp2, disp3, &input1, &input2,
|
||||
&input3);
|
||||
|
||||
g_free (disp1);
|
||||
g_free (disp2);
|
||||
g_free (disp3);
|
||||
mhl_mem_free (disp1);
|
||||
mhl_mem_free (disp2);
|
||||
mhl_mem_free (disp3);
|
||||
|
||||
convert_from_input (input1);
|
||||
convert_from_input (input2);
|
||||
@ -1870,9 +1870,9 @@ edit_replace_cmd (WEdit *edit, int again)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
g_free (saved1), saved1 = g_strdup (input1);
|
||||
g_free (saved2), saved2 = g_strdup (input2);
|
||||
g_free (saved3), saved3 = g_strdup (input3);
|
||||
mhl_mem_free (saved1), saved1 = g_strdup (input1);
|
||||
mhl_mem_free (saved2), saved2 = g_strdup (input2);
|
||||
mhl_mem_free (saved3), saved3 = g_strdup (input3);
|
||||
|
||||
}
|
||||
|
||||
@ -2064,9 +2064,9 @@ edit_replace_cmd (WEdit *edit, int again)
|
||||
edit->force = REDRAW_COMPLETELY;
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
cleanup:
|
||||
g_free (input1);
|
||||
g_free (input2);
|
||||
g_free (input3);
|
||||
mhl_mem_free (input1);
|
||||
mhl_mem_free (input2);
|
||||
mhl_mem_free (input3);
|
||||
}
|
||||
|
||||
|
||||
@ -2078,7 +2078,7 @@ void edit_search_cmd (WEdit * edit, int again)
|
||||
char *exp = "";
|
||||
|
||||
if (!edit) {
|
||||
g_free (old);
|
||||
mhl_mem_free (old);
|
||||
old = NULL;
|
||||
return;
|
||||
}
|
||||
@ -2108,7 +2108,7 @@ void edit_search_cmd (WEdit * edit, int again)
|
||||
if (exp) {
|
||||
if (*exp) {
|
||||
int len = 0;
|
||||
g_free (old);
|
||||
mhl_mem_free (old);
|
||||
old = g_strdup (exp);
|
||||
|
||||
if (search_create_bookmark) {
|
||||
@ -2165,7 +2165,7 @@ void edit_search_cmd (WEdit * edit, int again)
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
}
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
edit_scroll_screen_over_cursor (edit);
|
||||
@ -2204,7 +2204,7 @@ edit_ok_to_exit (WEdit *edit)
|
||||
|
||||
#define TEMP_BUF_LEN 1024
|
||||
|
||||
/* Return a null terminated length of text. Result must be g_free'd */
|
||||
/* Return a null terminated length of text. Result must be mhl_mem_free'd */
|
||||
static unsigned char *
|
||||
edit_get_block (WEdit *edit, long start, long finish, int *l)
|
||||
{
|
||||
@ -2257,7 +2257,7 @@ edit_save_block (WEdit * edit, const char *filename, long start,
|
||||
p += r;
|
||||
len -= r;
|
||||
}
|
||||
g_free (block);
|
||||
mhl_mem_free (block);
|
||||
} else {
|
||||
unsigned char *buf;
|
||||
int i = start, end;
|
||||
@ -2270,7 +2270,7 @@ edit_save_block (WEdit * edit, const char *filename, long start,
|
||||
len -= mc_write (file, (char *) buf, end - start);
|
||||
start = end;
|
||||
}
|
||||
g_free (buf);
|
||||
mhl_mem_free (buf);
|
||||
}
|
||||
mc_close (file);
|
||||
if (len)
|
||||
@ -2344,13 +2344,13 @@ edit_goto_cmd (WEdit *edit)
|
||||
return;
|
||||
|
||||
if (!*f) {
|
||||
g_free (f);
|
||||
mhl_mem_free (f);
|
||||
return;
|
||||
}
|
||||
|
||||
l = strtol (f, &error, 0);
|
||||
if (*error) {
|
||||
g_free (f);
|
||||
mhl_mem_free (f);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2360,7 +2360,7 @@ edit_goto_cmd (WEdit *edit)
|
||||
edit_move_display (edit, l - edit->num_widget_lines / 2 - 1);
|
||||
edit_move_to_line (edit, l - 1);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
g_free (f);
|
||||
mhl_mem_free (f);
|
||||
}
|
||||
|
||||
|
||||
@ -2379,15 +2379,15 @@ edit_save_block_cmd (WEdit *edit)
|
||||
edit_push_action (edit, KEY_PRESS + edit->start_display);
|
||||
if (exp) {
|
||||
if (!*exp) {
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
return 0;
|
||||
} else {
|
||||
if (edit_save_block (edit, exp, start_mark, end_mark)) {
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 1;
|
||||
} else {
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
edit_error_dialog (_(" Save Block "),
|
||||
get_sys_error (_
|
||||
(" Cannot save file. ")));
|
||||
@ -2409,15 +2409,15 @@ edit_insert_file_cmd (WEdit *edit)
|
||||
edit_push_action (edit, KEY_PRESS + edit->start_display);
|
||||
if (exp) {
|
||||
if (!*exp) {
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
return 0;
|
||||
} else {
|
||||
if (edit_insert_file (edit, exp)) {
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
edit->force |= REDRAW_COMPLETELY;
|
||||
return 1;
|
||||
} else {
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
edit_error_dialog (_(" Insert File "),
|
||||
get_sys_error (_
|
||||
(" Cannot insert file. ")));
|
||||
@ -2448,7 +2448,7 @@ int edit_sort_cmd (WEdit * edit)
|
||||
|
||||
if (!exp)
|
||||
return 1;
|
||||
g_free (old);
|
||||
mhl_mem_free (old);
|
||||
old = exp;
|
||||
|
||||
e = system (catstrs (" sort ", exp, " ", home_dir, PATH_SEP_STR BLOCK_FILE, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL));
|
||||
@ -2492,7 +2492,7 @@ edit_ext_cmd (WEdit *edit)
|
||||
return 1;
|
||||
|
||||
e = system (catstrs (exp, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL));
|
||||
g_free (exp);
|
||||
mhl_mem_free (exp);
|
||||
|
||||
if (e) {
|
||||
edit_error_dialog (_("External command"),
|
||||
@ -2588,7 +2588,7 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block)
|
||||
system (catstrs (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ",
|
||||
quoted_name, (char *) NULL));
|
||||
}
|
||||
g_free (quoted_name);
|
||||
mhl_mem_free (quoted_name);
|
||||
close_error_pipe (D_NORMAL, NULL);
|
||||
|
||||
edit_refresh_cmd (edit);
|
||||
@ -2629,13 +2629,13 @@ static void pipe_mail (WEdit *edit, char *to, char *subject, char *cc)
|
||||
subject = name_quote (subject, 0);
|
||||
cc = name_quote (cc, 0);
|
||||
s = g_strconcat ("mail -s ", subject, *cc ? " -c " : "" , cc, " ", to, (char *) NULL);
|
||||
g_free (to);
|
||||
g_free (subject);
|
||||
g_free (cc);
|
||||
mhl_mem_free (to);
|
||||
mhl_mem_free (subject);
|
||||
mhl_mem_free (cc);
|
||||
|
||||
if (s) {
|
||||
p = popen (s, "w");
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
}
|
||||
|
||||
if (p) {
|
||||
@ -2694,9 +2694,9 @@ void edit_mail_dialog (WEdit * edit)
|
||||
Quick_input.widgets = quick_widgets;
|
||||
|
||||
if (quick_dialog (&Quick_input) != B_CANCEL) {
|
||||
g_free (mail_cc_last);
|
||||
g_free (mail_subject_last);
|
||||
g_free (mail_to_last);
|
||||
mhl_mem_free (mail_cc_last);
|
||||
mhl_mem_free (mail_subject_last);
|
||||
mhl_mem_free (mail_to_last);
|
||||
mail_cc_last = tmail_cc;
|
||||
mail_subject_last = tmail_subject;
|
||||
mail_to_last = tmail_to;
|
||||
@ -2938,10 +2938,10 @@ edit_complete_word_cmd (WEdit *edit)
|
||||
}
|
||||
}
|
||||
|
||||
g_free (match_expr);
|
||||
mhl_mem_free (match_expr);
|
||||
/* release memory before return */
|
||||
for (i = 0; i < num_compl; i++)
|
||||
g_free (compl[i].text);
|
||||
mhl_mem_free (compl[i].text);
|
||||
|
||||
/* restore search parameters */
|
||||
edit_set_search_parameters (old_rs, old_rb, old_rr, old_rw, old_rc);
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -145,7 +147,7 @@ edit_status (WEdit *edit)
|
||||
printwstr (status, w - (fname_len + gap));
|
||||
attrset (EDITOR_NORMAL_COLOR);
|
||||
|
||||
g_free (status);
|
||||
mhl_mem_free (status);
|
||||
}
|
||||
|
||||
/* this scrolls the text so that cursor is on the screen */
|
||||
|
@ -22,8 +22,8 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <signal.h> /* kill() */
|
||||
|
||||
#include <signal.h> /* kill() */
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
@ -34,9 +34,10 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -99,7 +100,7 @@ lock_build_symlink_name (const char *fname)
|
||||
fname_copy = g_strdup (fname);
|
||||
absolute_fname[fname - absolute_fname] = '\0';
|
||||
symlink_name = g_strconcat (absolute_fname, ".#", fname_copy, (char *) NULL);
|
||||
g_free (fname_copy);
|
||||
mhl_mem_free (fname_copy);
|
||||
|
||||
return symlink_name;
|
||||
}
|
||||
@ -174,7 +175,7 @@ edit_lock_file (const char *fname)
|
||||
if (lstat (lockfname, &statbuf) == 0) {
|
||||
lock = lock_get_info (lockfname);
|
||||
if (!lock) {
|
||||
g_free (lockfname);
|
||||
mhl_mem_free (lockfname);
|
||||
return 0;
|
||||
}
|
||||
lockinfo = lock_extract_info (lock);
|
||||
@ -195,11 +196,11 @@ edit_lock_file (const char *fname)
|
||||
break;
|
||||
case 1:
|
||||
case -1:
|
||||
g_free (lockfname);
|
||||
g_free (msg);
|
||||
mhl_mem_free (lockfname);
|
||||
mhl_mem_free (msg);
|
||||
return 0;
|
||||
}
|
||||
g_free (msg);
|
||||
mhl_mem_free (msg);
|
||||
}
|
||||
unlink (lockfname);
|
||||
}
|
||||
@ -207,13 +208,13 @@ edit_lock_file (const char *fname)
|
||||
/* Create lock symlink */
|
||||
newlock = lock_build_name ();
|
||||
if (symlink (newlock, lockfname) == -1) {
|
||||
g_free (lockfname);
|
||||
g_free (newlock);
|
||||
mhl_mem_free (lockfname);
|
||||
mhl_mem_free (newlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_free (lockfname);
|
||||
g_free (newlock);
|
||||
mhl_mem_free (lockfname);
|
||||
mhl_mem_free (newlock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -235,7 +236,7 @@ edit_unlock_file (const char *fname)
|
||||
|
||||
/* Check if lock exists */
|
||||
if (lstat (lockfname, &statbuf) == -1) {
|
||||
g_free (lockfname);
|
||||
mhl_mem_free (lockfname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -243,13 +244,13 @@ edit_unlock_file (const char *fname)
|
||||
if (lock) {
|
||||
/* Don't touch if lock is not ours */
|
||||
if (lock_extract_info (lock)->pid != getpid ()) {
|
||||
g_free (lockfname);
|
||||
mhl_mem_free (lockfname);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove lock */
|
||||
unlink (lockfname);
|
||||
g_free (lockfname);
|
||||
mhl_mem_free (lockfname);
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,9 +33,10 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -475,7 +476,7 @@ edit_done_menu (struct WMenu *wmenu)
|
||||
for (i = 0; i < N_menus; i++)
|
||||
destroy_menu (wmenu->menu[i]);
|
||||
|
||||
g_free(wmenu->menu);
|
||||
mhl_mem_free(wmenu->menu);
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,9 +33,10 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -186,13 +187,13 @@ edit_options_dialog (void)
|
||||
|
||||
if (p) {
|
||||
option_word_wrap_line_length = atoi (p);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
if (q) {
|
||||
option_tab_spacing = atoi (q);
|
||||
if (option_tab_spacing <= 0)
|
||||
option_tab_spacing = 8;
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
}
|
||||
|
||||
option_syntax_highlighting = tedit_syntax_highlighting;
|
||||
|
@ -33,9 +33,10 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -176,7 +177,7 @@ edit_file (const char *_file, int line)
|
||||
if (!made_directory) {
|
||||
char *dir = concat_dir_and_file (home_dir, EDIT_DIR);
|
||||
made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST);
|
||||
g_free (dir);
|
||||
mhl_mem_free (dir);
|
||||
}
|
||||
|
||||
if (!(wedit = edit_init (NULL, LINES - 2, COLS, _file, line))) {
|
||||
|
@ -30,9 +30,10 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -102,7 +103,7 @@ int option_syntax_highlighting = 1;
|
||||
int option_auto_syntax = 1;
|
||||
char *option_syntax_type = NULL;
|
||||
|
||||
#define syntax_g_free(x) do {g_free(x); (x)=0;} while (0)
|
||||
#define _FREEPTR(x) do {mhl_mem_free(x); (x)=0;} while (0)
|
||||
|
||||
static gint
|
||||
mc_defines_destroy (gpointer key, gpointer value, gpointer data)
|
||||
@ -111,10 +112,10 @@ mc_defines_destroy (gpointer key, gpointer value, gpointer data)
|
||||
|
||||
(void) data;
|
||||
|
||||
g_free (key);
|
||||
mhl_mem_free (key);
|
||||
while (*values)
|
||||
g_free (*values++);
|
||||
g_free (value);
|
||||
mhl_mem_free (*values++);
|
||||
mhl_mem_free (value);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -471,7 +472,7 @@ static struct syntax_rule edit_get_rule (WEdit * edit, long byte_index)
|
||||
break;
|
||||
}
|
||||
s = edit->syntax_marker->next;
|
||||
syntax_g_free (edit->syntax_marker);
|
||||
_FREEPTR (edit->syntax_marker);
|
||||
edit->syntax_marker = s;
|
||||
}
|
||||
}
|
||||
@ -666,19 +667,19 @@ static FILE *open_include_file (const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
syntax_g_free (error_file_name);
|
||||
_FREEPTR (error_file_name);
|
||||
error_file_name = g_strdup (filename);
|
||||
if (*filename == PATH_SEP)
|
||||
return fopen (filename, "r");
|
||||
|
||||
g_free (error_file_name);
|
||||
mhl_mem_free (error_file_name);
|
||||
error_file_name = g_strconcat (home_dir, PATH_SEP_STR EDIT_DIR PATH_SEP_STR,
|
||||
filename, (char *) NULL);
|
||||
f = fopen (error_file_name, "r");
|
||||
if (f)
|
||||
return f;
|
||||
|
||||
g_free (error_file_name);
|
||||
mhl_mem_free (error_file_name);
|
||||
error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR,
|
||||
filename, (char *) NULL);
|
||||
return fopen (error_file_name, "r");
|
||||
@ -725,8 +726,8 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size)
|
||||
f = g;
|
||||
g = 0;
|
||||
line = save_line + 1;
|
||||
syntax_g_free (error_file_name);
|
||||
syntax_g_free (l);
|
||||
_FREEPTR (error_file_name);
|
||||
_FREEPTR (l);
|
||||
if (!read_one_line (&l, f))
|
||||
break;
|
||||
} else {
|
||||
@ -745,7 +746,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size)
|
||||
g = f;
|
||||
f = open_include_file (args[1]);
|
||||
if (!f) {
|
||||
syntax_g_free (error_file_name);
|
||||
_FREEPTR (error_file_name);
|
||||
result = line;
|
||||
break;
|
||||
}
|
||||
@ -922,10 +923,10 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size)
|
||||
break_a;
|
||||
}
|
||||
free_args (args);
|
||||
syntax_g_free (l);
|
||||
_FREEPTR (l);
|
||||
}
|
||||
free_args (args);
|
||||
syntax_g_free (l);
|
||||
_FREEPTR (l);
|
||||
|
||||
/* Terminate context array. */
|
||||
if (num_contexts > 0) {
|
||||
@ -934,7 +935,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size)
|
||||
}
|
||||
|
||||
if (!edit->rules[0])
|
||||
syntax_g_free (edit->rules);
|
||||
_FREEPTR (edit->rules);
|
||||
|
||||
if (result)
|
||||
return result;
|
||||
@ -958,7 +959,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size)
|
||||
c->keyword_first_chars = g_strdup (first_chars);
|
||||
}
|
||||
|
||||
g_free (first_chars);
|
||||
mhl_mem_free (first_chars);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -976,34 +977,34 @@ void edit_free_syntax_rules (WEdit * edit)
|
||||
return;
|
||||
|
||||
edit_get_rule (edit, -1);
|
||||
syntax_g_free (edit->syntax_type);
|
||||
_FREEPTR (edit->syntax_type);
|
||||
edit->syntax_type = 0;
|
||||
|
||||
for (i = 0; edit->rules[i]; i++) {
|
||||
if (edit->rules[i]->keyword) {
|
||||
for (j = 0; edit->rules[i]->keyword[j]; j++) {
|
||||
syntax_g_free (edit->rules[i]->keyword[j]->keyword);
|
||||
syntax_g_free (edit->rules[i]->keyword[j]->whole_word_chars_left);
|
||||
syntax_g_free (edit->rules[i]->keyword[j]->whole_word_chars_right);
|
||||
syntax_g_free (edit->rules[i]->keyword[j]);
|
||||
_FREEPTR (edit->rules[i]->keyword[j]->keyword);
|
||||
_FREEPTR (edit->rules[i]->keyword[j]->whole_word_chars_left);
|
||||
_FREEPTR (edit->rules[i]->keyword[j]->whole_word_chars_right);
|
||||
_FREEPTR (edit->rules[i]->keyword[j]);
|
||||
}
|
||||
}
|
||||
syntax_g_free (edit->rules[i]->left);
|
||||
syntax_g_free (edit->rules[i]->right);
|
||||
syntax_g_free (edit->rules[i]->whole_word_chars_left);
|
||||
syntax_g_free (edit->rules[i]->whole_word_chars_right);
|
||||
syntax_g_free (edit->rules[i]->keyword);
|
||||
syntax_g_free (edit->rules[i]->keyword_first_chars);
|
||||
syntax_g_free (edit->rules[i]);
|
||||
_FREEPTR (edit->rules[i]->left);
|
||||
_FREEPTR (edit->rules[i]->right);
|
||||
_FREEPTR (edit->rules[i]->whole_word_chars_left);
|
||||
_FREEPTR (edit->rules[i]->whole_word_chars_right);
|
||||
_FREEPTR (edit->rules[i]->keyword);
|
||||
_FREEPTR (edit->rules[i]->keyword_first_chars);
|
||||
_FREEPTR (edit->rules[i]);
|
||||
}
|
||||
|
||||
while (edit->syntax_marker) {
|
||||
struct _syntax_marker *s = edit->syntax_marker->next;
|
||||
syntax_g_free (edit->syntax_marker);
|
||||
_FREEPTR (edit->syntax_marker);
|
||||
edit->syntax_marker = s;
|
||||
}
|
||||
|
||||
syntax_g_free (edit->rules);
|
||||
_FREEPTR (edit->rules);
|
||||
}
|
||||
|
||||
/* returns -1 on file error, line number on error in file syntax */
|
||||
@ -1028,7 +1029,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
|
||||
if (!f){
|
||||
lib_file = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
|
||||
f = fopen (lib_file, "r");
|
||||
g_free (lib_file);
|
||||
mhl_mem_free (lib_file);
|
||||
if (!f)
|
||||
return -1;
|
||||
}
|
||||
@ -1036,7 +1037,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
|
||||
args[0] = 0;
|
||||
for (;;) {
|
||||
line++;
|
||||
syntax_g_free (l);
|
||||
_FREEPTR (l);
|
||||
if (!read_one_line (&l, f))
|
||||
break;
|
||||
(void)get_args (l, args, 1023); /* Final NULL */
|
||||
@ -1117,7 +1118,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
|
||||
else
|
||||
result = line_error;
|
||||
} else {
|
||||
syntax_g_free (edit->syntax_type);
|
||||
_FREEPTR (edit->syntax_type);
|
||||
edit->syntax_type = g_strdup (syntax_type);
|
||||
|
||||
/* if there are no rules then turn off syntax highlighting for speed */
|
||||
@ -1136,7 +1137,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
|
||||
}
|
||||
}
|
||||
}
|
||||
syntax_g_free (l);
|
||||
_FREEPTR (l);
|
||||
fclose (f);
|
||||
return result;
|
||||
}
|
||||
@ -1201,9 +1202,9 @@ edit_load_syntax (WEdit *edit, char ***pnames, const char *type)
|
||||
message (D_ERROR, _(" Load syntax file "),
|
||||
_(" Error in file %s on line %d "),
|
||||
error_file_name ? error_file_name : f, r);
|
||||
syntax_g_free (error_file_name);
|
||||
_FREEPTR (error_file_name);
|
||||
} else {
|
||||
/* succeeded */
|
||||
}
|
||||
g_free (f);
|
||||
mhl_mem_free (f);
|
||||
}
|
||||
|
@ -26,11 +26,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -241,7 +242,7 @@ cfg_free_maps(config_t *cfg)
|
||||
cfg->ext_keymap = NULL;
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
g_free(cfg->labels[i]);
|
||||
mhl_mem_free(cfg->labels[i]);
|
||||
}
|
||||
|
||||
/* Returns an array containing the words in str. WARNING: As long as
|
||||
@ -553,7 +554,7 @@ parse_file(config_t *cfg, const char *file, const command_t *cmd)
|
||||
char *ss = g_strdup(error_msg);
|
||||
snprintf(error_msg, sizeof(error_msg),
|
||||
_("%s:%d: %s"), file, line, ss);
|
||||
g_free(ss);
|
||||
mhl_mem_free(ss);
|
||||
g_ptr_array_free(args, TRUE);
|
||||
fclose(fp);
|
||||
return FALSE;
|
||||
@ -601,8 +602,8 @@ edit_load_user_map(WEdit *edit)
|
||||
if (stat(file, &s) < 0) {
|
||||
char *msg = g_strdup_printf(_("%s not found!"), file);
|
||||
edit_error_dialog(_("Error"), msg);
|
||||
g_free(msg);
|
||||
g_free(file);
|
||||
mhl_mem_free(msg);
|
||||
mhl_mem_free(file);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -613,7 +614,7 @@ edit_load_user_map(WEdit *edit)
|
||||
if (!load_user_keymap(&new_cfg, file)) {
|
||||
edit_error_dialog(_("Error"), error_msg);
|
||||
cfg_free_maps(&new_cfg);
|
||||
g_free(file);
|
||||
mhl_mem_free(file);
|
||||
return FALSE;
|
||||
} else {
|
||||
cfg_free_maps(&cfg);
|
||||
@ -625,7 +626,7 @@ edit_load_user_map(WEdit *edit)
|
||||
edit->ext_map = (edit_key_map_type *) cfg.ext_keymap->data;
|
||||
memcpy(edit->labels, cfg.labels, sizeof(edit->labels));
|
||||
|
||||
g_free(file);
|
||||
mhl_mem_free(file);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -30,9 +30,10 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "edit.h"
|
||||
@ -349,13 +350,13 @@ format_paragraph (WEdit *edit, int force)
|
||||
if (!force) {
|
||||
int i;
|
||||
if (strchr (NO_FORMAT_CHARS_START, *t)) {
|
||||
g_free (t);
|
||||
mhl_mem_free (t);
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < size - 1; i++) {
|
||||
if (t[i] == '\n') {
|
||||
if (strchr (NO_FORMAT_CHARS_START "\t ", t[i + 1])) {
|
||||
g_free (t);
|
||||
mhl_mem_free (t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -363,7 +364,7 @@ format_paragraph (WEdit *edit, int force)
|
||||
}
|
||||
format_this (t, q - p, indent);
|
||||
put_paragraph (edit, t, p, indent, size);
|
||||
g_free (t);
|
||||
mhl_mem_free (t);
|
||||
|
||||
/* Scroll left as much as possible to show the formatted paragraph */
|
||||
edit_scroll_left (edit, -edit->start_col);
|
||||
|
@ -22,11 +22,12 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "win.h"
|
||||
@ -596,7 +597,7 @@ init_chown_advanced (void)
|
||||
static void
|
||||
chown_advanced_done (void)
|
||||
{
|
||||
g_free (sf_stat);
|
||||
mhl_mem_free (sf_stat);
|
||||
if (need_update)
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
repaint_screen ();
|
||||
|
@ -31,11 +31,12 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "background.h"
|
||||
#include "tty.h" /* doupdate() */
|
||||
@ -89,8 +90,8 @@ unregister_task_running (pid_t pid, int fd)
|
||||
prev->next = p->next;
|
||||
else
|
||||
task_list = p->next;
|
||||
g_free (p->info);
|
||||
g_free (p);
|
||||
mhl_mem_free (p->info);
|
||||
mhl_mem_free (p);
|
||||
break;
|
||||
}
|
||||
prev = p;
|
||||
@ -321,7 +322,7 @@ background_attention (int fd, void *closure)
|
||||
write (fd, &len, sizeof (len));
|
||||
if (len){
|
||||
write (fd, resstr, len);
|
||||
g_free (resstr);
|
||||
mhl_mem_free (resstr);
|
||||
}
|
||||
} else {
|
||||
len = 0;
|
||||
@ -329,7 +330,7 @@ background_attention (int fd, void *closure)
|
||||
}
|
||||
}
|
||||
for (i = 0; i < argc; i++)
|
||||
g_free (data [i]);
|
||||
mhl_mem_free (data [i]);
|
||||
|
||||
do_refresh ();
|
||||
mc_refresh ();
|
||||
|
25
src/boxes.c
25
src/boxes.c
@ -27,10 +27,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "win.h" /* Our window tools */
|
||||
@ -233,11 +234,11 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n
|
||||
panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
|
||||
section = g_strconcat ("Temporal:", p, (char *) NULL);
|
||||
if (!profile_has_section (section, profile_name)) {
|
||||
g_free (section);
|
||||
mhl_mem_free (section);
|
||||
section = g_strdup (p);
|
||||
}
|
||||
panel_load_setup (panel, section);
|
||||
g_free (section);
|
||||
mhl_mem_free (section);
|
||||
}
|
||||
|
||||
current_mode = panel->list_type;
|
||||
@ -249,10 +250,10 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n
|
||||
result = -1;
|
||||
|
||||
if (section) {
|
||||
g_free (panel->user_format);
|
||||
mhl_mem_free (panel->user_format);
|
||||
for (i = 0; i < LIST_TYPES; i++)
|
||||
g_free (panel->user_status_format [i]);
|
||||
g_free (panel);
|
||||
mhl_mem_free (panel->user_status_format [i]);
|
||||
mhl_mem_free (panel);
|
||||
}
|
||||
|
||||
if (dd->ret_value != B_CANCEL){
|
||||
@ -782,19 +783,19 @@ configure_vfs (void)
|
||||
|
||||
if (quick_dialog (&confvfs_dlg) != B_CANCEL) {
|
||||
vfs_timeout = atoi (ret_timeout);
|
||||
g_free (ret_timeout);
|
||||
mhl_mem_free (ret_timeout);
|
||||
if (vfs_timeout < 0 || vfs_timeout > 10000)
|
||||
vfs_timeout = 10;
|
||||
#if defined(USE_NETCODE)
|
||||
g_free (ftpfs_anonymous_passwd);
|
||||
mhl_mem_free (ftpfs_anonymous_passwd);
|
||||
ftpfs_anonymous_passwd = ret_passwd;
|
||||
g_free (ftpfs_proxy_host);
|
||||
mhl_mem_free (ftpfs_proxy_host);
|
||||
ftpfs_proxy_host = ret_ftp_proxy;
|
||||
ftpfs_directory_timeout = atoi(ret_directory_timeout);
|
||||
use_netrc = ret_use_netrc;
|
||||
ftpfs_use_passive_connections = ret_ftpfs_use_passive_connections;
|
||||
ftpfs_use_passive_connections_over_proxy = ret_ftpfs_use_passive_connections_over_proxy;
|
||||
g_free (ret_directory_timeout);
|
||||
mhl_mem_free (ret_directory_timeout);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -905,7 +906,7 @@ jobs_fill_listbox (void)
|
||||
|
||||
s = g_strconcat (state_str [tl->state], " ", tl->info, (char *) NULL);
|
||||
listbox_add_item (bg_list, LISTBOX_APPEND_AT_END, 0, s, (void *) tl);
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
tl = tl->next;
|
||||
}
|
||||
}
|
||||
@ -1083,7 +1084,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
|
||||
auth_dlg = create_dlg (0, 0, dialog_y, dialog_x, dialog_colors, NULL,
|
||||
"[Smb Authinfo]", title, DLG_CENTER | DLG_REVERSE);
|
||||
|
||||
g_free (title);
|
||||
mhl_mem_free (title);
|
||||
|
||||
in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name");
|
||||
add_widget (auth_dlg, in_user);
|
||||
|
@ -51,10 +51,10 @@ load_codepages_list (void)
|
||||
fname = concat_dir_and_file (mc_home, CHARSETS_INDEX);
|
||||
if (!(f = fopen (fname, "r"))) {
|
||||
fprintf (stderr, _("Warning: file %s not found\n"), fname);
|
||||
g_free (fname);
|
||||
mhl_mem_free (fname);
|
||||
return -1;
|
||||
}
|
||||
g_free (fname);
|
||||
mhl_mem_free (fname);
|
||||
|
||||
for (n_codepages = 0; fgets (buf, sizeof (buf), f);)
|
||||
if (buf[0] != '\n' && buf[0] != '\0' && buf[0] != '#')
|
||||
@ -97,7 +97,7 @@ load_codepages_list (void)
|
||||
|
||||
if (default_codepage) {
|
||||
display_codepage = get_codepage_index (default_codepage);
|
||||
g_free (default_codepage);
|
||||
mhl_mem_free (default_codepage);
|
||||
}
|
||||
|
||||
result = n_codepages;
|
||||
@ -112,11 +112,11 @@ free_codepages_list (void)
|
||||
if (n_codepages > 0) {
|
||||
int i;
|
||||
for (i = 0; i < n_codepages; i++) {
|
||||
g_free (codepages[i].id);
|
||||
g_free (codepages[i].name);
|
||||
mhl_mem_free (codepages[i].id);
|
||||
mhl_mem_free (codepages[i].name);
|
||||
}
|
||||
n_codepages = 0;
|
||||
g_free (codepages);
|
||||
mhl_mem_free (codepages);
|
||||
codepages = 0;
|
||||
}
|
||||
}
|
||||
|
77
src/cmd.c
77
src/cmd.c
@ -23,7 +23,6 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef HAVE_MMAP
|
||||
@ -34,6 +33,8 @@
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "cmd.h" /* Our definitions */
|
||||
#include "fileopctx.h" /* file_op_context_new() */
|
||||
@ -239,7 +240,7 @@ view_file_cmd (void)
|
||||
return;
|
||||
|
||||
view_file (filename, 0, use_internal_view);
|
||||
g_free (filename);
|
||||
mhl_mem_free (filename);
|
||||
}
|
||||
|
||||
/* Run plain internal viewer on the currently selected file */
|
||||
@ -264,7 +265,7 @@ filtered_view_cmd (void)
|
||||
|
||||
mc_internal_viewer (command, "", NULL, 0);
|
||||
|
||||
g_free (command);
|
||||
mhl_mem_free (command);
|
||||
}
|
||||
|
||||
void do_edit_at_line (const char *what, int start_line)
|
||||
@ -382,8 +383,8 @@ mkdir_cmd (void)
|
||||
message (D_ERROR, MSG_ERROR, " %s ", unix_error_string (errno));
|
||||
}
|
||||
|
||||
g_free (absdir);
|
||||
g_free (dir);
|
||||
mhl_mem_free (absdir);
|
||||
mhl_mem_free (dir);
|
||||
}
|
||||
|
||||
void delete_cmd (void)
|
||||
@ -415,13 +416,13 @@ void find_cmd (void)
|
||||
static void
|
||||
set_panel_filter_to (WPanel *p, char *allocated_filter_string)
|
||||
{
|
||||
g_free (p->filter);
|
||||
mhl_mem_free (p->filter);
|
||||
p->filter = 0;
|
||||
|
||||
if (!(allocated_filter_string [0] == '*' && allocated_filter_string [1] == 0))
|
||||
p->filter = allocated_filter_string;
|
||||
else
|
||||
g_free (allocated_filter_string);
|
||||
mhl_mem_free (allocated_filter_string);
|
||||
reread_cmd ();
|
||||
}
|
||||
|
||||
@ -493,7 +494,7 @@ select_unselect_cmd (const char *title, const char *history_name, int cmd)
|
||||
if (!reg_exp)
|
||||
return;
|
||||
if (!*reg_exp) {
|
||||
g_free (reg_exp);
|
||||
mhl_mem_free (reg_exp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -523,14 +524,14 @@ select_unselect_cmd (const char *title, const char *history_name, int cmd)
|
||||
match_file);
|
||||
if (c == -1) {
|
||||
message (D_ERROR, MSG_ERROR, _(" Malformed regular expression "));
|
||||
g_free (reg_exp);
|
||||
mhl_mem_free (reg_exp);
|
||||
return;
|
||||
}
|
||||
if (c) {
|
||||
do_file_mark (current_panel, i, cmd);
|
||||
}
|
||||
}
|
||||
g_free (reg_exp);
|
||||
mhl_mem_free (reg_exp);
|
||||
}
|
||||
|
||||
void select_cmd (void)
|
||||
@ -583,11 +584,11 @@ void ext_cmd (void)
|
||||
buffer = concat_dir_and_file (home_dir, MC_USER_EXT);
|
||||
check_for_default (extdir, buffer);
|
||||
do_edit (buffer);
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
} else if (dir == 1)
|
||||
do_edit (extdir);
|
||||
|
||||
g_free (extdir);
|
||||
mhl_mem_free (extdir);
|
||||
flush_extension_file ();
|
||||
}
|
||||
|
||||
@ -625,14 +626,14 @@ menu_edit_cmd (int where)
|
||||
break;
|
||||
|
||||
default:
|
||||
g_free (menufile);
|
||||
mhl_mem_free (menufile);
|
||||
return;
|
||||
}
|
||||
do_edit (buffer);
|
||||
if (dir == 0)
|
||||
chmod(buffer, 0600);
|
||||
g_free (buffer);
|
||||
g_free (menufile);
|
||||
mhl_mem_free (buffer);
|
||||
mhl_mem_free (menufile);
|
||||
}
|
||||
|
||||
void quick_chdir_cmd (void)
|
||||
@ -648,7 +649,7 @@ void quick_chdir_cmd (void)
|
||||
else
|
||||
if (!do_cd (target, cd_exact))
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot change directory") );
|
||||
g_free (target);
|
||||
mhl_mem_free (target);
|
||||
}
|
||||
|
||||
/* edit file menu for mc */
|
||||
@ -686,11 +687,11 @@ edit_syntax_cmd (void)
|
||||
buffer = concat_dir_and_file (home_dir, SYNTAX_FILE);
|
||||
check_for_default (extdir, buffer);
|
||||
do_edit (buffer);
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
} else if (dir == 1)
|
||||
do_edit (extdir);
|
||||
|
||||
g_free (extdir);
|
||||
mhl_mem_free (extdir);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -705,7 +706,7 @@ void reselect_vfs (void)
|
||||
|
||||
if (!do_cd (target, cd_exact))
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot change directory") );
|
||||
g_free (target);
|
||||
mhl_mem_free (target);
|
||||
}
|
||||
#endif /* USE_VFS */
|
||||
|
||||
@ -818,8 +819,8 @@ compare_dir (WPanel *panel, WPanel *other, enum CompareMode mode)
|
||||
dst_name = concat_dir_and_file (other->cwd, target->fname);
|
||||
if (compare_files (src_name, dst_name, source->st.st_size))
|
||||
do_file_mark (panel, i, 1);
|
||||
g_free (src_name);
|
||||
g_free (dst_name);
|
||||
mhl_mem_free (src_name);
|
||||
mhl_mem_free (dst_name);
|
||||
}
|
||||
} /* for (i ...) */
|
||||
}
|
||||
@ -878,7 +879,7 @@ history_cmd (void)
|
||||
else
|
||||
current = listbox->list->current->data;
|
||||
destroy_dlg (listbox->dlg);
|
||||
g_free (listbox);
|
||||
mhl_mem_free (listbox);
|
||||
|
||||
if (!current)
|
||||
return;
|
||||
@ -938,8 +939,8 @@ do_link (int symbolic_link, const char *fname)
|
||||
}
|
||||
|
||||
symlink_dialog (s, d, &dest, &src);
|
||||
g_free (d);
|
||||
g_free (s);
|
||||
mhl_mem_free (d);
|
||||
mhl_mem_free (s);
|
||||
|
||||
if (!dest || !*dest || !src || !*src)
|
||||
goto cleanup;
|
||||
@ -952,8 +953,8 @@ do_link (int symbolic_link, const char *fname)
|
||||
repaint_screen ();
|
||||
|
||||
cleanup:
|
||||
g_free (src);
|
||||
g_free (dest);
|
||||
mhl_mem_free (src);
|
||||
mhl_mem_free (dest);
|
||||
}
|
||||
|
||||
void link_cmd (void)
|
||||
@ -1001,10 +1002,10 @@ void edit_symlink_cmd (void)
|
||||
update_panels (UP_OPTIMIZE, UP_KEEPSEL);
|
||||
repaint_screen ();
|
||||
}
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
}
|
||||
}
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
} else {
|
||||
message (D_ERROR, MSG_ERROR, _("`%s' is not a symbolic link"),
|
||||
selection (current_panel)->fname);
|
||||
@ -1023,7 +1024,7 @@ user_file_menu_cmd (void)
|
||||
}
|
||||
|
||||
/* partly taken from dcigettext.c, returns "" for default locale */
|
||||
/* value should be freed by calling function g_free() */
|
||||
/* value should be freed by calling function mhl_mem_free() */
|
||||
char *guess_message_value (void)
|
||||
{
|
||||
static const char * const var[] = {
|
||||
@ -1093,7 +1094,7 @@ get_random_hint (int force)
|
||||
if (eol)
|
||||
*eol = 0;
|
||||
result = g_strdup (&data[start]);
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1124,8 +1125,8 @@ nice_cd (const char *text, const char *xtext, const char *help,
|
||||
directory_history_add (MENU_PANEL, (MENU_PANEL)->cwd);
|
||||
else
|
||||
message (D_ERROR, MSG_ERROR, _(" Cannot chdir to %s "), cd_path);
|
||||
g_free (cd_path);
|
||||
g_free (machine);
|
||||
mhl_mem_free (cd_path);
|
||||
mhl_mem_free (machine);
|
||||
}
|
||||
#endif /* USE_NETCODE || USE_EXT2FSLIB */
|
||||
|
||||
@ -1185,9 +1186,9 @@ void quick_cd_cmd (void)
|
||||
char *q = g_strconcat ("cd ", p, (char *) NULL);
|
||||
|
||||
do_cd_command (q);
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
}
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1253,17 +1254,17 @@ configure_panel_listing (WPanel *p, int view_type, int use_msformat, char *user,
|
||||
p->list_type = view_type;
|
||||
|
||||
if (view_type == list_user || use_msformat){
|
||||
g_free (p->user_format);
|
||||
mhl_mem_free (p->user_format);
|
||||
p->user_format = user;
|
||||
|
||||
g_free (p->user_status_format [view_type]);
|
||||
mhl_mem_free (p->user_status_format [view_type]);
|
||||
p->user_status_format [view_type] = status;
|
||||
|
||||
set_panel_formats (p);
|
||||
}
|
||||
else {
|
||||
g_free (user);
|
||||
g_free (status);
|
||||
mhl_mem_free (user);
|
||||
mhl_mem_free (status);
|
||||
}
|
||||
|
||||
set_panel_formats (p);
|
||||
|
10
src/color.c
10
src/color.c
@ -22,6 +22,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "setup.h" /* For the externs */
|
||||
@ -252,7 +254,7 @@ static void configure_colors_string (const char *the_color_string)
|
||||
color_string++;
|
||||
}
|
||||
}
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
static void configure_colors (void)
|
||||
@ -464,9 +466,9 @@ done_colors (void)
|
||||
|
||||
for (p = c.next; p; p = next) {
|
||||
next = p->next;
|
||||
g_free (p->fg);
|
||||
g_free (p->bg);
|
||||
g_free (p);
|
||||
mhl_mem_free (p->fg);
|
||||
mhl_mem_free (p->bg);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
c.next = NULL;
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h" /* home_dir */
|
||||
#include "tty.h"
|
||||
#include "widget.h" /* WInput */
|
||||
@ -126,15 +128,15 @@ examine_cd (char *path)
|
||||
if (*p) {
|
||||
r = concat_dir_and_file (p, q);
|
||||
result = do_cd (r, cd_parse_command);
|
||||
g_free (r);
|
||||
mhl_mem_free (r);
|
||||
}
|
||||
*s = c;
|
||||
p = s + 1;
|
||||
}
|
||||
g_free (cdpath);
|
||||
mhl_mem_free (cdpath);
|
||||
}
|
||||
g_free (q);
|
||||
g_free (path_tilde);
|
||||
mhl_mem_free (q);
|
||||
mhl_mem_free (path_tilde);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -178,14 +180,14 @@ void do_cd_command (char *cmd)
|
||||
char *new;
|
||||
new = concat_dir_and_file (old, cmd+3);
|
||||
sync_tree (new);
|
||||
g_free (new);
|
||||
mhl_mem_free (new);
|
||||
}
|
||||
} else
|
||||
if (!examine_cd (&cmd [3])) {
|
||||
char *d = strip_password (g_strdup (&cmd [3]), 1);
|
||||
message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "),
|
||||
d, unix_error_string (errno));
|
||||
g_free (d);
|
||||
mhl_mem_free (d);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -239,7 +241,7 @@ enter (WInput *cmdline)
|
||||
s = expand_format (NULL, cmd[i], 1);
|
||||
command = g_realloc (command, j + strlen (s) + cmd_len - i + 1);
|
||||
strcpy (command + j, s);
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
j = strlen (command);
|
||||
} else {
|
||||
command[j] = cmd[i];
|
||||
@ -249,7 +251,7 @@ enter (WInput *cmdline)
|
||||
}
|
||||
new_input (cmdline);
|
||||
shell_execute (command, 0);
|
||||
g_free (command);
|
||||
mhl_mem_free (command);
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
if (quit & SUBSHELL_EXIT) {
|
||||
@ -310,6 +312,6 @@ command_insert (WInput * in, const char *text, int insert_extra_space)
|
||||
|
||||
quoted_text = name_quote (text, 1);
|
||||
stuff (in, quoted_text, insert_extra_space);
|
||||
g_free (quoted_text);
|
||||
mhl_mem_free (quoted_text);
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "win.h"
|
||||
@ -67,9 +68,9 @@ filename_completion_function (char *text, int state)
|
||||
if (!state){
|
||||
const char *temp;
|
||||
|
||||
g_free (dirname);
|
||||
g_free (filename);
|
||||
g_free (users_dirname);
|
||||
mhl_mem_free (dirname);
|
||||
mhl_mem_free (filename);
|
||||
mhl_mem_free (users_dirname);
|
||||
|
||||
if ((*text) && (temp = strrchr (text, PATH_SEP))){
|
||||
filename = g_strdup (++temp);
|
||||
@ -133,7 +134,7 @@ filename_completion_function (char *text, int state)
|
||||
isexec = 1;
|
||||
}
|
||||
}
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
}
|
||||
switch (look_for_executables)
|
||||
{
|
||||
@ -154,11 +155,11 @@ filename_completion_function (char *text, int state)
|
||||
mc_closedir (directory);
|
||||
directory = NULL;
|
||||
}
|
||||
g_free (dirname);
|
||||
mhl_mem_free (dirname);
|
||||
dirname = NULL;
|
||||
g_free (filename);
|
||||
mhl_mem_free (filename);
|
||||
filename = NULL;
|
||||
g_free (users_dirname);
|
||||
mhl_mem_free (users_dirname);
|
||||
users_dirname = NULL;
|
||||
return NULL;
|
||||
} else {
|
||||
@ -333,7 +334,7 @@ static void fetch_hosts (const char *filename)
|
||||
*(hosts_p++) = name;
|
||||
*hosts_p = NULL;
|
||||
} else
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -351,8 +352,8 @@ hostname_completion_function (char *text, int state)
|
||||
|
||||
if (hosts != NULL){
|
||||
for (host_p = hosts; *host_p; host_p++)
|
||||
g_free (*host_p);
|
||||
g_free (hosts);
|
||||
mhl_mem_free (*host_p);
|
||||
mhl_mem_free (hosts);
|
||||
}
|
||||
hosts = g_new (char *, (hosts_alloclen = 30) + 1);
|
||||
*hosts = NULL;
|
||||
@ -373,8 +374,8 @@ hostname_completion_function (char *text, int state)
|
||||
|
||||
if (!*host_p){
|
||||
for (host_p = hosts; *host_p; host_p++)
|
||||
g_free (*host_p);
|
||||
g_free (hosts);
|
||||
mhl_mem_free (*host_p);
|
||||
mhl_mem_free (hosts);
|
||||
hosts = NULL;
|
||||
return NULL;
|
||||
} else {
|
||||
@ -475,7 +476,7 @@ command_completion_function (char *text, int state)
|
||||
break;
|
||||
expanded = tilde_expand (*cur_path ? cur_path : ".");
|
||||
cur_word = concat_dir_and_file (expanded, text);
|
||||
g_free (expanded);
|
||||
mhl_mem_free (expanded);
|
||||
canonicalize_pathname (cur_word);
|
||||
cur_path = strchr (cur_path, 0) + 1;
|
||||
init_state = state;
|
||||
@ -484,7 +485,7 @@ command_completion_function (char *text, int state)
|
||||
filename_completion_function (cur_word,
|
||||
state - init_state);
|
||||
if (!found) {
|
||||
g_free (cur_word);
|
||||
mhl_mem_free (cur_word);
|
||||
cur_word = NULL;
|
||||
}
|
||||
}
|
||||
@ -492,14 +493,14 @@ command_completion_function (char *text, int state)
|
||||
|
||||
if (!found) {
|
||||
look_for_executables = 0;
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
path = NULL;
|
||||
return NULL;
|
||||
}
|
||||
if ((p = strrchr (found, PATH_SEP)) != NULL) {
|
||||
p++;
|
||||
p = g_strdup (p);
|
||||
g_free (found);
|
||||
mhl_mem_free (found);
|
||||
return p;
|
||||
}
|
||||
return found;
|
||||
@ -572,7 +573,7 @@ completion_matches (char *text, CompletionFunction entry_function)
|
||||
if (c1 != c2) break;
|
||||
|
||||
if (!c1 && !match_list [j][si]){ /* Two equal strings */
|
||||
g_free (match_list [j]);
|
||||
mhl_mem_free (match_list [j]);
|
||||
j++;
|
||||
if (j > matches)
|
||||
break;
|
||||
@ -588,7 +589,7 @@ completion_matches (char *text, CompletionFunction entry_function)
|
||||
match_list[0] = g_strndup(match_list[1], low);
|
||||
}
|
||||
} else { /* There were no matches. */
|
||||
g_free (match_list);
|
||||
mhl_mem_free (match_list);
|
||||
match_list = NULL;
|
||||
}
|
||||
return match_list;
|
||||
@ -744,17 +745,17 @@ try_complete (char *text, int *start, int *end, int flags)
|
||||
ignore_filenames = 1;
|
||||
matches = completion_matches (r, filename_completion_function);
|
||||
ignore_filenames = 0;
|
||||
g_free (r);
|
||||
mhl_mem_free (r);
|
||||
}
|
||||
*s = c;
|
||||
cdpath = s + 1;
|
||||
}
|
||||
g_free (cdpath_ref);
|
||||
mhl_mem_free (cdpath_ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_free (word);
|
||||
mhl_mem_free (word);
|
||||
|
||||
return matches;
|
||||
}
|
||||
@ -766,8 +767,8 @@ void free_completions (WInput *in)
|
||||
if (!in->completions)
|
||||
return;
|
||||
for (p=in->completions; *p; p++)
|
||||
g_free (*p);
|
||||
g_free (in->completions);
|
||||
mhl_mem_free (*p);
|
||||
mhl_mem_free (in->completions);
|
||||
in->completions = NULL;
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ console_shutdown (void)
|
||||
if (!console_flag)
|
||||
return;
|
||||
|
||||
g_free (screen_shot.buf);
|
||||
mhl_mem_free (screen_shot.buf);
|
||||
|
||||
console_flag = 0;
|
||||
}
|
||||
|
10
src/dialog.c
10
src/dialog.c
@ -24,6 +24,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "mouse.h"
|
||||
@ -218,7 +220,7 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set,
|
||||
char *t;
|
||||
t = g_strstrip (g_strdup (title));
|
||||
new_d->title = g_strconcat (" ", t, " ", (char *) NULL);
|
||||
g_free (t);
|
||||
mhl_mem_free (t);
|
||||
}
|
||||
|
||||
return (new_d);
|
||||
@ -813,11 +815,11 @@ destroy_dlg (Dlg_head *h)
|
||||
c = h->current;
|
||||
for (i = 0; i < h->count; i++) {
|
||||
c = c->next;
|
||||
g_free (h->current);
|
||||
mhl_mem_free (h->current);
|
||||
h->current = c;
|
||||
}
|
||||
g_free (h->title);
|
||||
g_free (h);
|
||||
mhl_mem_free (h->title);
|
||||
mhl_mem_free (h);
|
||||
|
||||
do_refresh ();
|
||||
}
|
||||
|
@ -22,9 +22,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "dir.h"
|
||||
@ -254,7 +255,7 @@ clean_dir (dir_list *list, int count)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++){
|
||||
g_free (list->list [i].fname);
|
||||
mhl_mem_free (list->list [i].fname);
|
||||
list->list [i].fname = 0;
|
||||
}
|
||||
}
|
||||
@ -471,9 +472,9 @@ alloc_dir_copy (int size)
|
||||
if (dir_copy.list){
|
||||
|
||||
for (i = 0; i < dir_copy.size; i++) {
|
||||
g_free (dir_copy.list [i].fname);
|
||||
mhl_mem_free (dir_copy.list [i].fname);
|
||||
}
|
||||
g_free (dir_copy.list);
|
||||
mhl_mem_free (dir_copy.list);
|
||||
dir_copy.list = 0;
|
||||
}
|
||||
|
||||
|
@ -75,12 +75,12 @@ test_locale_en_US_UTF_8(void)
|
||||
valid = ecs_mbstr_to_str(&ecs, teststr_mb);
|
||||
assert(valid);
|
||||
assert(ecs_strlen(ecs) == 10);
|
||||
g_free(ecs);
|
||||
mhl_mem_free(ecs);
|
||||
|
||||
valid = ecs_str_to_mbstr(&mbs, teststr_ecs);
|
||||
assert(valid);
|
||||
assert(strlen(mbs) == 11);
|
||||
g_free(mbs);
|
||||
mhl_mem_free(mbs);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -45,7 +45,7 @@ extern gboolean ecs_mbstr_to_str(ecs_char **ret_str, const char *s)
|
||||
str = g_new(ecs_char, maxlen + 1);
|
||||
len = mbstowcs(str, s, maxlen + 1);
|
||||
if (len == (size_t) -1) {
|
||||
g_free(str);
|
||||
mhl_mem_free(str);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ extern gboolean ecs_str_to_mbstr(char **ret_str, const ecs_char *s)
|
||||
str = g_new(char, maxlen + 1);
|
||||
len = wcstombs(str, s, maxlen + 1);
|
||||
if (len == (size_t) -1) {
|
||||
g_free(str);
|
||||
mhl_mem_free(str);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ typedef char ecs_char;
|
||||
/*
|
||||
* String conversion functions between the wide character encoding and
|
||||
* the multibyte encoding. The returned strings should be freed using
|
||||
* g_free after use. The return value is TRUE if the string is valid
|
||||
* mhl_mem_free after use. The return value is TRUE if the string is valid
|
||||
* and has been converted, FALSE otherwise.
|
||||
*/
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "win.h"
|
||||
@ -161,7 +163,7 @@ do_execute (const char *shell, const char *command, int flags)
|
||||
#ifdef USE_VFS
|
||||
if (old_vfs_dir) {
|
||||
mc_chdir (old_vfs_dir);
|
||||
g_free (old_vfs_dir);
|
||||
mhl_mem_free (old_vfs_dir);
|
||||
}
|
||||
#endif /* USE_VFS */
|
||||
|
||||
@ -195,7 +197,7 @@ shell_execute (const char *command, int flags)
|
||||
#endif /* HAVE_SUBSHELL_SUPPORT */
|
||||
do_execute (shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
|
||||
|
||||
g_free (cmd);
|
||||
mhl_mem_free (cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -368,6 +370,6 @@ execute_with_vfs_arg (const char *command, const char *filename)
|
||||
do_execute (command, localcopy, EXECUTE_INTERNAL);
|
||||
mc_stat (localcopy, &st);
|
||||
mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime);
|
||||
g_free (localcopy);
|
||||
g_free (fn);
|
||||
mhl_mem_free (localcopy);
|
||||
mhl_mem_free (fn);
|
||||
}
|
||||
|
43
src/ext.c
43
src/ext.c
@ -25,9 +25,10 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "user.h"
|
||||
@ -52,7 +53,7 @@ static char *data = NULL;
|
||||
void
|
||||
flush_extension_file (void)
|
||||
{
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
@ -121,14 +122,14 @@ exec_extension (const char *filename, const char *data, int *move_dir,
|
||||
unlink (file_name);
|
||||
if (localcopy) {
|
||||
mc_ungetlocalcopy (filename, localcopy, 0);
|
||||
g_free (localcopy);
|
||||
mhl_mem_free (localcopy);
|
||||
}
|
||||
g_free (file_name);
|
||||
mhl_mem_free (file_name);
|
||||
return;
|
||||
}
|
||||
fputs (parameter, cmd_file);
|
||||
written_nonspace = 1;
|
||||
g_free (parameter);
|
||||
mhl_mem_free (parameter);
|
||||
} else {
|
||||
size_t len = strlen (prompt);
|
||||
|
||||
@ -156,7 +157,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
|
||||
data += i - 1;
|
||||
} else if ((i = check_format_var (data, &v)) > 0 && v) {
|
||||
fputs (v, cmd_file);
|
||||
g_free (v);
|
||||
mhl_mem_free (v);
|
||||
data += i;
|
||||
} else {
|
||||
char *text;
|
||||
@ -167,7 +168,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
|
||||
if (localcopy == NULL) {
|
||||
fclose (cmd_file);
|
||||
unlink (file_name);
|
||||
g_free (file_name);
|
||||
mhl_mem_free (file_name);
|
||||
return;
|
||||
}
|
||||
mc_stat (localcopy, &mystat);
|
||||
@ -184,7 +185,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
|
||||
strcpy (p, text);
|
||||
p = strchr (p, 0);
|
||||
}
|
||||
g_free (text);
|
||||
mhl_mem_free (text);
|
||||
written_nonspace = 1;
|
||||
}
|
||||
}
|
||||
@ -215,7 +216,7 @@ exec_extension (const char *filename, const char *data, int *move_dir,
|
||||
|
||||
if ((run_view && !written_nonspace) || is_cd) {
|
||||
unlink (file_name);
|
||||
g_free (file_name);
|
||||
mhl_mem_free (file_name);
|
||||
file_name = NULL;
|
||||
} else {
|
||||
/* Set executable flag on the command file ... */
|
||||
@ -274,14 +275,14 @@ exec_extension (const char *filename, const char *data, int *move_dir,
|
||||
}
|
||||
}
|
||||
|
||||
g_free (file_name);
|
||||
g_free (cmd);
|
||||
mhl_mem_free (file_name);
|
||||
mhl_mem_free (cmd);
|
||||
|
||||
if (localcopy) {
|
||||
mc_stat (localcopy, &mystat);
|
||||
mc_ungetlocalcopy (filename, localcopy,
|
||||
localmtime != mystat.st_mtime);
|
||||
g_free (localcopy);
|
||||
mhl_mem_free (localcopy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,8 +305,8 @@ get_file_type_local (const char *filename, char *buf, int buflen)
|
||||
char *command = g_strconcat (FILE_CMD, tmp, " 2>/dev/null", (char *) 0);
|
||||
FILE *f = popen (command, "r");
|
||||
|
||||
g_free (tmp);
|
||||
g_free (command);
|
||||
mhl_mem_free (tmp);
|
||||
mhl_mem_free (command);
|
||||
if (f != NULL) {
|
||||
#ifdef __QNXNTO__
|
||||
if (setvbuf (f, NULL, _IOFBF, 0) != 0) {
|
||||
@ -386,7 +387,7 @@ regex_check_type (const char *filename, const char *ptr, int *have_type)
|
||||
/* No data */
|
||||
content_string[0] = 0;
|
||||
}
|
||||
g_free (realname);
|
||||
mhl_mem_free (realname);
|
||||
}
|
||||
|
||||
if (got_data == -1) {
|
||||
@ -442,20 +443,20 @@ regex_command (const char *filename, const char *action, int *move_dir)
|
||||
|
||||
extension_file = concat_dir_and_file (home_dir, MC_USER_EXT);
|
||||
if (!exist_file (extension_file)) {
|
||||
g_free (extension_file);
|
||||
mhl_mem_free (extension_file);
|
||||
check_stock_mc_ext:
|
||||
extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT);
|
||||
mc_user_ext = 0;
|
||||
}
|
||||
data = load_file (extension_file);
|
||||
g_free (extension_file);
|
||||
mhl_mem_free (extension_file);
|
||||
if (data == NULL)
|
||||
return 0;
|
||||
|
||||
if (!strstr (data, "default/")) {
|
||||
if (!strstr (data, "regex/") && !strstr (data, "shell/")
|
||||
&& !strstr (data, "type/")) {
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
data = NULL;
|
||||
if (mc_user_ext) {
|
||||
home_error = 1;
|
||||
@ -469,7 +470,7 @@ regex_command (const char *filename, const char *action, int *move_dir)
|
||||
"the installation failed. Please fetch a fresh "
|
||||
"copy from the Midnight Commander package."),
|
||||
mc_home);
|
||||
g_free (title);
|
||||
mhl_mem_free (title);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -481,7 +482,7 @@ regex_command (const char *filename, const char *action, int *move_dir)
|
||||
"changed with version 3.0. You may either want to copy "
|
||||
"it from %smc.ext or use that file as an example of how "
|
||||
"to write it."), MC_USER_EXT, mc_home);
|
||||
g_free (title);
|
||||
mhl_mem_free (title);
|
||||
}
|
||||
}
|
||||
mc_stat (filename, &mystat);
|
||||
@ -594,7 +595,7 @@ regex_command (const char *filename, const char *action, int *move_dir)
|
||||
|
||||
exec_extension (filename_copy, r + 1, move_dir,
|
||||
view_at_line_number);
|
||||
g_free (filename_copy);
|
||||
mhl_mem_free (filename_copy);
|
||||
|
||||
ret = 1;
|
||||
}
|
||||
|
68
src/file.c
68
src/file.c
@ -247,7 +247,7 @@ transform_source (FileOpContext *ctx, const char *source)
|
||||
*q = ' ';
|
||||
}
|
||||
p = do_transform_source (ctx, s);
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ free_linklist (struct link **linklist)
|
||||
|
||||
for (lp = *linklist; lp != NULL; lp = lp2) {
|
||||
lp2 = lp->next;
|
||||
g_free (lp);
|
||||
mhl_mem_free (lp);
|
||||
}
|
||||
*linklist = NULL;
|
||||
}
|
||||
@ -390,17 +390,17 @@ make_symlink (FileOpContext *ctx, const char *src_path, const char *dst_path)
|
||||
if (s) {
|
||||
s[1] = 0;
|
||||
s = g_strconcat (p, link_target, (char *) NULL);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
g_strlcpy (link_target, s, sizeof (link_target));
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
s = diff_two_paths (q, link_target);
|
||||
if (s) {
|
||||
g_strlcpy (link_target, s, sizeof (link_target));
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
}
|
||||
} else
|
||||
g_free (p);
|
||||
g_free (q);
|
||||
mhl_mem_free (p);
|
||||
mhl_mem_free (q);
|
||||
}
|
||||
}
|
||||
retry_dst_symlink:
|
||||
@ -751,7 +751,7 @@ copy_file_file (FileOpContext *ctx, const char *src_path, const char *dst_path,
|
||||
dst_status = DEST_FULL; /* copy successful, don't remove target file */
|
||||
|
||||
ret:
|
||||
g_free (buf);
|
||||
mhl_mem_free (buf);
|
||||
|
||||
while (src_desc != -1 && mc_close (src_desc) < 0) {
|
||||
temp_status = file_error (
|
||||
@ -889,7 +889,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
||||
|
||||
if (move_over) {
|
||||
if (mc_rename (s, d) == 0) {
|
||||
g_free (parent_dirs);
|
||||
mhl_mem_free (parent_dirs);
|
||||
return FILE_CONT;
|
||||
}
|
||||
}
|
||||
@ -908,7 +908,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
||||
_(" Destination \"%s\" must be a directory \n %s "), d);
|
||||
if (return_status == FILE_RETRY)
|
||||
goto retry_dst_stat;
|
||||
g_free (parent_dirs);
|
||||
mhl_mem_free (parent_dirs);
|
||||
return return_status;
|
||||
}
|
||||
/* Dive into subdir if exists */
|
||||
@ -972,12 +972,12 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
||||
*/
|
||||
return_status = copy_dir_dir (ctx, path, mdpath, 0, 0, delete,
|
||||
parent_dirs, progress_count, progress_bytes);
|
||||
g_free (mdpath);
|
||||
mhl_mem_free (mdpath);
|
||||
} else {
|
||||
dest_file = concat_dir_and_file (dest_dir, x_basename (path));
|
||||
return_status = copy_file_file (ctx, path, dest_file, 1,
|
||||
progress_count, progress_bytes, 0);
|
||||
g_free (dest_file);
|
||||
mhl_mem_free (dest_file);
|
||||
}
|
||||
if (delete && return_status == FILE_CONT) {
|
||||
if (ctx->erase_at_end) {
|
||||
@ -998,7 +998,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
||||
return_status = erase_file (ctx, path, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
}
|
||||
mc_closedir (reading);
|
||||
|
||||
@ -1010,8 +1010,8 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel,
|
||||
}
|
||||
|
||||
ret:
|
||||
g_free (dest_dir);
|
||||
g_free (parent_dirs);
|
||||
mhl_mem_free (dest_dir);
|
||||
mhl_mem_free (parent_dirs);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
@ -1206,7 +1206,7 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
|
||||
if (return_status == FILE_RETRY)
|
||||
goto retry_dst_stat;
|
||||
}
|
||||
g_free (destdir);
|
||||
mhl_mem_free (destdir);
|
||||
return return_status;
|
||||
}
|
||||
|
||||
@ -1249,17 +1249,17 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d,
|
||||
erase_file (ctx, erase_list->name, 0, 0, 0);
|
||||
lp = erase_list;
|
||||
erase_list = erase_list->next;
|
||||
g_free (lp);
|
||||
mhl_mem_free (lp);
|
||||
}
|
||||
}
|
||||
erase_dir_iff_empty (ctx, s);
|
||||
|
||||
ret:
|
||||
g_free (destdir);
|
||||
mhl_mem_free (destdir);
|
||||
while (erase_list) {
|
||||
lp = erase_list;
|
||||
erase_list = erase_list->next;
|
||||
g_free (lp);
|
||||
mhl_mem_free (lp);
|
||||
}
|
||||
return return_status;
|
||||
}
|
||||
@ -1323,7 +1323,7 @@ recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count,
|
||||
continue;
|
||||
path = concat_dir_and_file (s, next->d_name);
|
||||
if (mc_lstat (path, &buf)) {
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
mc_closedir (reading);
|
||||
return 1;
|
||||
}
|
||||
@ -1335,7 +1335,7 @@ recursive_erase (FileOpContext *ctx, const char *s, off_t *progress_count,
|
||||
else
|
||||
return_status =
|
||||
erase_file (ctx, path, progress_count, progress_bytes, 0);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
}
|
||||
mc_closedir (reading);
|
||||
if (return_status != FILE_CONT)
|
||||
@ -1517,7 +1517,7 @@ compute_dir_size (const char *dirname, off_t *ret_marked, double *ret_total)
|
||||
res = mc_lstat (fullname, &s);
|
||||
|
||||
if (res != 0) {
|
||||
g_free (fullname);
|
||||
mhl_mem_free (fullname);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1533,7 +1533,7 @@ compute_dir_size (const char *dirname, off_t *ret_marked, double *ret_total)
|
||||
(*ret_marked)++;
|
||||
*ret_total += s.st_size;
|
||||
}
|
||||
g_free (fullname);
|
||||
mhl_mem_free (fullname);
|
||||
}
|
||||
|
||||
mc_closedir (dir);
|
||||
@ -1574,7 +1574,7 @@ panel_compute_totals (WPanel *panel, off_t *ret_marked, double *ret_total)
|
||||
|
||||
*ret_marked += subdir_count;
|
||||
*ret_total += subdir_bytes;
|
||||
g_free (dir_name);
|
||||
mhl_mem_free (dir_name);
|
||||
} else {
|
||||
(*ret_marked)++;
|
||||
*ret_total += s->st_size;
|
||||
@ -1820,7 +1820,7 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
}
|
||||
if (!*dest) {
|
||||
file_op_context_destroy (ctx);
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1893,7 +1893,7 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
value = transform_error;
|
||||
} else {
|
||||
char *temp2 = concat_dir_and_file (dest, temp);
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
dest = temp2;
|
||||
temp = NULL;
|
||||
|
||||
@ -1969,7 +1969,7 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
src_stat = panel->dir.list[i].st;
|
||||
|
||||
#ifdef WITH_FULL_PATHS
|
||||
g_free (source_with_path);
|
||||
mhl_mem_free (source_with_path);
|
||||
source_with_path = concat_dir_and_file (panel->cwd, source);
|
||||
#endif /* WITH_FULL_PATHS */
|
||||
|
||||
@ -2021,7 +2021,7 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
/* Unknown file operation */
|
||||
abort ();
|
||||
}
|
||||
g_free (temp2);
|
||||
mhl_mem_free (temp2);
|
||||
}
|
||||
} /* Copy or move operation */
|
||||
|
||||
@ -2053,20 +2053,20 @@ panel_operate (void *source_panel, FileOperation operation,
|
||||
|
||||
if (save_cwd) {
|
||||
mc_setctl (save_cwd, VFS_SETCTL_STALE_DATA, NULL);
|
||||
g_free (save_cwd);
|
||||
mhl_mem_free (save_cwd);
|
||||
}
|
||||
if (save_dest) {
|
||||
mc_setctl (save_dest, VFS_SETCTL_STALE_DATA, NULL);
|
||||
g_free (save_dest);
|
||||
mhl_mem_free (save_dest);
|
||||
}
|
||||
|
||||
free_linklist (&linklist);
|
||||
free_linklist (&dest_dirs);
|
||||
#ifdef WITH_FULL_PATHS
|
||||
g_free (source_with_path);
|
||||
mhl_mem_free (source_with_path);
|
||||
#endif /* WITH_FULL_PATHS */
|
||||
g_free (dest);
|
||||
g_free (ctx->dest_mask);
|
||||
mhl_mem_free (dest);
|
||||
mhl_mem_free (ctx->dest_mask);
|
||||
ctx->dest_mask = NULL;
|
||||
#ifdef WITH_BACKGROUND
|
||||
/* Let our parent know we are saying bye bye */
|
||||
@ -2160,7 +2160,7 @@ real_query_recursive (FileOpContext *ctx, enum OperationMode mode, const char *s
|
||||
|
||||
if (ctx->recursive_result != RECURSIVE_ABORT)
|
||||
do_refresh ();
|
||||
g_free (text);
|
||||
mhl_mem_free (text);
|
||||
}
|
||||
|
||||
switch (ctx->recursive_result) {
|
||||
|
@ -48,11 +48,12 @@
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "setup.h" /* verbose */
|
||||
#include "dialog.h" /* do_refresh() */
|
||||
@ -256,7 +257,7 @@ file_op_context_destroy_ui (FileOpContext *ctx)
|
||||
|
||||
dlg_run_done (ui->op_dlg);
|
||||
destroy_dlg (ui->op_dlg);
|
||||
g_free (ui);
|
||||
mhl_mem_free (ui);
|
||||
}
|
||||
|
||||
the_hint->widget.y = last_hint_line;
|
||||
@ -904,10 +905,10 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
|
||||
ask_file_mask:
|
||||
|
||||
if ((val = quick_dialog_skip (&Quick_input, SKIP)) == B_CANCEL) {
|
||||
g_free (def_text_secure);
|
||||
mhl_mem_free (def_text_secure);
|
||||
return 0;
|
||||
}
|
||||
g_free (def_text_secure);
|
||||
mhl_mem_free (def_text_secure);
|
||||
|
||||
if (ctx->follow_links)
|
||||
ctx->stat_func = mc_stat;
|
||||
@ -928,7 +929,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
|
||||
|
||||
orig_mask = source_mask;
|
||||
if (!dest_dir || !*dest_dir) {
|
||||
g_free (source_mask);
|
||||
mhl_mem_free (source_mask);
|
||||
return dest_dir;
|
||||
}
|
||||
if (source_easy_patterns) {
|
||||
@ -939,7 +940,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
|
||||
error =
|
||||
re_compile_pattern (source_mask, strlen (source_mask),
|
||||
&ctx->rx);
|
||||
g_free (source_mask);
|
||||
mhl_mem_free (source_mask);
|
||||
} else
|
||||
error =
|
||||
re_compile_pattern (source_mask, strlen (source_mask),
|
||||
@ -948,14 +949,14 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
|
||||
if (error) {
|
||||
message (D_ERROR, MSG_ERROR, _("Invalid source pattern `%s' \n %s "),
|
||||
orig_mask, error);
|
||||
g_free (orig_mask);
|
||||
mhl_mem_free (orig_mask);
|
||||
goto ask_file_mask;
|
||||
}
|
||||
g_free (orig_mask);
|
||||
mhl_mem_free (orig_mask);
|
||||
|
||||
tmpdest = dest_dir;
|
||||
dest_dir = tilde_expand(tmpdest);
|
||||
g_free(tmpdest);
|
||||
mhl_mem_free(tmpdest);
|
||||
|
||||
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
|
||||
if (ctx->dest_mask == NULL)
|
||||
@ -977,7 +978,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
|
||||
*orig_mask = 0;
|
||||
}
|
||||
if (!*dest_dir) {
|
||||
g_free (dest_dir);
|
||||
mhl_mem_free (dest_dir);
|
||||
dest_dir = g_strdup ("./");
|
||||
}
|
||||
if (val == B_USER)
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
|
||||
static char *
|
||||
@ -62,12 +64,12 @@ my_mkdir_rec (char *s, mode_t mode)
|
||||
|
||||
p = concat_dir_and_file (s, "..");
|
||||
q = vfs_canon (p);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
if (!(result = my_mkdir_rec (q, mode)))
|
||||
result = mc_mkdir (s, mode);
|
||||
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -82,7 +84,7 @@ my_mkdir (const char *s, mode_t mode)
|
||||
char *p = vfs_canon (s);
|
||||
|
||||
result = my_mkdir_rec (p, mode);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
if (result == 0) {
|
||||
my_s = get_absolute_name (s);
|
||||
@ -91,7 +93,7 @@ my_mkdir (const char *s, mode_t mode)
|
||||
tree_add_entry (tree, my_s);
|
||||
#endif
|
||||
|
||||
g_free (my_s);
|
||||
mhl_mem_free (my_s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -114,7 +116,7 @@ my_rmdir (const char *s)
|
||||
tree_remove_entry (tree, my_s);
|
||||
#endif
|
||||
|
||||
g_free (my_s);
|
||||
mhl_mem_free (my_s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "fileopctx.h"
|
||||
|
||||
@ -77,5 +79,5 @@ file_op_context_destroy (FileOpContext *ctx)
|
||||
|
||||
/* FIXME: do we need to free ctx->dest_mask? */
|
||||
|
||||
g_free (ctx);
|
||||
mhl_mem_free (ctx);
|
||||
}
|
||||
|
69
src/find.c
69
src/find.c
@ -25,9 +25,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "win.h"
|
||||
@ -306,14 +307,14 @@ find_parameters (char **start_dir, char **pattern, char **content)
|
||||
find_regex_flag = find_regex_cbox->state & C_BOOL;
|
||||
find_recursively = recursively_cbox->state & C_BOOL;
|
||||
destroy_dlg (find_dlg);
|
||||
g_free (in_start_dir);
|
||||
mhl_mem_free (in_start_dir);
|
||||
if (strcmp (temp_dir, ".") == 0) {
|
||||
g_free (temp_dir);
|
||||
mhl_mem_free (temp_dir);
|
||||
temp_dir = g_strdup (current_panel->cwd);
|
||||
}
|
||||
in_start_dir = tree_box (temp_dir);
|
||||
if (in_start_dir)
|
||||
g_free (temp_dir);
|
||||
mhl_mem_free (temp_dir);
|
||||
else
|
||||
in_start_dir = temp_dir;
|
||||
/* Warning: Dreadful goto */
|
||||
@ -321,7 +322,7 @@ find_parameters (char **start_dir, char **pattern, char **content)
|
||||
break;
|
||||
|
||||
default:
|
||||
g_free (in_contents);
|
||||
mhl_mem_free (in_contents);
|
||||
if (in_with->buffer[0]) {
|
||||
*content = g_strdup (in_with->buffer);
|
||||
in_contents = g_strdup (*content);
|
||||
@ -337,9 +338,9 @@ find_parameters (char **start_dir, char **pattern, char **content)
|
||||
*start_dir = g_strdup (in_start->buffer);
|
||||
*pattern = g_strdup (in_name->buffer);
|
||||
|
||||
g_free (in_start_dir);
|
||||
mhl_mem_free (in_start_dir);
|
||||
in_start_dir = g_strdup (*start_dir);
|
||||
g_free (in_start_name);
|
||||
mhl_mem_free (in_start_name);
|
||||
in_start_name = g_strdup (*pattern);
|
||||
}
|
||||
|
||||
@ -368,7 +369,7 @@ pop_directory (void)
|
||||
if (dir_stack_base){
|
||||
name = dir_stack_base->name;
|
||||
next = dir_stack_base->prev;
|
||||
g_free (dir_stack_base);
|
||||
mhl_mem_free (dir_stack_base);
|
||||
dir_stack_base = next;
|
||||
return name;
|
||||
} else
|
||||
@ -386,7 +387,7 @@ insert_file (const char *dir, const char *file)
|
||||
|
||||
if (old_dir){
|
||||
if (strcmp (old_dir, dir)){
|
||||
g_free (old_dir);
|
||||
mhl_mem_free (old_dir);
|
||||
old_dir = g_strdup (dir);
|
||||
dirname = add_to_list (dir, NULL);
|
||||
}
|
||||
@ -397,7 +398,7 @@ insert_file (const char *dir, const char *file)
|
||||
|
||||
tmp_name = g_strconcat (" ", file, (char *) NULL);
|
||||
add_to_list (tmp_name, dirname);
|
||||
g_free (tmp_name);
|
||||
mhl_mem_free (tmp_name);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -519,12 +520,12 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
|
||||
fname = concat_dir_and_file (directory, filename);
|
||||
|
||||
if (mc_stat (fname, &s) != 0 || !S_ISREG (s.st_mode)){
|
||||
g_free (fname);
|
||||
mhl_mem_free (fname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
file_fd = mc_open (fname, O_RDONLY);
|
||||
g_free (fname);
|
||||
mhl_mem_free (fname);
|
||||
|
||||
if (file_fd == -1)
|
||||
return 0;
|
||||
@ -560,7 +561,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
|
||||
if (found == 0){ /* Search in binary line once */
|
||||
if (find_regex_flag) {
|
||||
if (regexec (r, p, 1, 0, 0) == 0){
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
p = g_strdup_printf ("%d:%s", line, filename);
|
||||
find_add_match (h, directory, p);
|
||||
found = 1;
|
||||
@ -577,7 +578,7 @@ search_content (Dlg_head *h, const char *directory, const char *filename)
|
||||
line++;
|
||||
found = 0;
|
||||
}
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
if ((line & 0xff) == 0) {
|
||||
FindProgressStatus res;
|
||||
@ -620,7 +621,7 @@ do_search (struct Dlg_head *h)
|
||||
mc_closedir (dirp);
|
||||
dirp = 0;
|
||||
}
|
||||
g_free (directory);
|
||||
mhl_mem_free (directory);
|
||||
directory = NULL;
|
||||
dp = 0;
|
||||
return 1;
|
||||
@ -650,16 +651,16 @@ do_search (struct Dlg_head *h)
|
||||
char *temp_dir = g_strconcat (":", tmp, ":", (char *) NULL);
|
||||
|
||||
found = strstr (find_ignore_dirs, temp_dir) != 0;
|
||||
g_free (temp_dir);
|
||||
mhl_mem_free (temp_dir);
|
||||
if (found)
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
else
|
||||
break;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (directory);
|
||||
mhl_mem_free (directory);
|
||||
directory = tmp;
|
||||
|
||||
if (verbose){
|
||||
@ -698,7 +699,7 @@ do_search (struct Dlg_head *h)
|
||||
push_directory (tmp_name);
|
||||
subdirs_left--;
|
||||
}
|
||||
g_free (tmp_name);
|
||||
mhl_mem_free (tmp_name);
|
||||
}
|
||||
|
||||
if (regexp_match (find_pattern, dp->d_name, match_file)){
|
||||
@ -735,14 +736,14 @@ init_find_vars (void)
|
||||
{
|
||||
char *dir;
|
||||
|
||||
g_free (old_dir);
|
||||
mhl_mem_free (old_dir);
|
||||
old_dir = 0;
|
||||
count = 0;
|
||||
matches = 0;
|
||||
|
||||
/* Remove all the items in the stack */
|
||||
while ((dir = pop_directory ()) != NULL)
|
||||
g_free (dir);
|
||||
mhl_mem_free (dir);
|
||||
}
|
||||
|
||||
static char *
|
||||
@ -776,7 +777,7 @@ find_do_view_edit (int unparsed_view, int edit, char *dir, char *file)
|
||||
do_edit_at_line (fullname, line);
|
||||
else
|
||||
view_file_at_line (fullname, unparsed_view, use_internal_view, line);
|
||||
g_free (fullname);
|
||||
mhl_mem_free (fullname);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -976,7 +977,7 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname,
|
||||
|
||||
/* Remove all the items in the stack */
|
||||
while ((dir = pop_directory ()) != NULL)
|
||||
g_free (dir);
|
||||
mhl_mem_free (dir);
|
||||
|
||||
get_list_info (&file_tmp, &dir_tmp);
|
||||
|
||||
@ -1011,18 +1012,18 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname,
|
||||
handle_path (list, name, &st, next_free, &link_to_dir,
|
||||
&stale_link);
|
||||
if (status == 0) {
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
continue;
|
||||
}
|
||||
if (status == -1) {
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
break;
|
||||
}
|
||||
|
||||
/* don't add files more than once to the panel */
|
||||
if (content_pattern && next_free > 0) {
|
||||
if (strcmp (list->list[next_free - 1].fname, name) == 0) {
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1059,7 +1060,7 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname,
|
||||
|
||||
kill_gui ();
|
||||
do_search (0); /* force do_search to release resources */
|
||||
g_free (old_dir);
|
||||
mhl_mem_free (old_dir);
|
||||
old_dir = 0;
|
||||
|
||||
return return_value;
|
||||
@ -1078,8 +1079,8 @@ do_find (void)
|
||||
dirname = filename = NULL;
|
||||
is_start = 0;
|
||||
v = find_file (start_dir, pattern, content, &dirname, &filename);
|
||||
g_free (start_dir);
|
||||
g_free (pattern);
|
||||
mhl_mem_free (start_dir);
|
||||
mhl_mem_free (pattern);
|
||||
if (find_regex_flag && r)
|
||||
regfree (r);
|
||||
|
||||
@ -1094,14 +1095,14 @@ do_find (void)
|
||||
do_cd (filename, cd_exact);
|
||||
select_item (current_panel);
|
||||
}
|
||||
g_free (dirname);
|
||||
g_free (filename);
|
||||
mhl_mem_free (dirname);
|
||||
mhl_mem_free (filename);
|
||||
break;
|
||||
}
|
||||
g_free (content);
|
||||
mhl_mem_free (content);
|
||||
dir_and_file_set = dirname && filename;
|
||||
g_free (dirname);
|
||||
g_free (filename);
|
||||
mhl_mem_free (dirname);
|
||||
mhl_mem_free (filename);
|
||||
if (v == B_CANCEL)
|
||||
break;
|
||||
|
||||
|
11
src/help.c
11
src/help.c
@ -45,10 +45,11 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "color.h"
|
||||
@ -127,7 +128,7 @@ search_string (const char *start, const char *text)
|
||||
}
|
||||
}
|
||||
cleanup:
|
||||
g_free (local_text);
|
||||
mhl_mem_free (local_text);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -327,7 +328,7 @@ static void clear_link_areas (void)
|
||||
while (link_area){
|
||||
current = link_area;
|
||||
link_area = current -> next;
|
||||
g_free (current);
|
||||
mhl_mem_free (current);
|
||||
}
|
||||
inside_link_area = 0;
|
||||
}
|
||||
@ -753,7 +754,7 @@ static void
|
||||
interactive_display_finish (void)
|
||||
{
|
||||
clear_link_areas ();
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
}
|
||||
|
||||
void
|
||||
@ -774,7 +775,7 @@ interactive_display (const char *filename, const char *node)
|
||||
}
|
||||
|
||||
if (!filename)
|
||||
g_free (hlpfile);
|
||||
mhl_mem_free (hlpfile);
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
|
@ -32,11 +32,12 @@
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h" /* COLS */
|
||||
#include "color.h" /* dialog_colors */
|
||||
@ -199,7 +200,7 @@ update_path_name (void)
|
||||
else
|
||||
label_set_text (movelist_group,
|
||||
name_trunc (p, dlg->cols - (UX * 2 + 4)));
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
dlg_redraw (dlg);
|
||||
}
|
||||
@ -209,7 +210,7 @@ do { \
|
||||
int i; \
|
||||
\
|
||||
if ((i = strlen (current->label) + 3) > buflen) { \
|
||||
g_free (buf); \
|
||||
mhl_mem_free (buf); \
|
||||
buf = g_malloc (buflen = 1024 * (i/1024 + 1)); \
|
||||
} \
|
||||
buf[0] = '\0'; \
|
||||
@ -463,7 +464,7 @@ hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm)
|
||||
char *tmp =
|
||||
g_strconcat ("cd ", hlp->directory, (char *) NULL);
|
||||
stuff (cmdline, tmp, 0);
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
dlg_stop (h);
|
||||
h->ret_value = B_CANCEL;
|
||||
return MSG_HANDLED;
|
||||
@ -686,7 +687,7 @@ init_movelist (int list_type, struct hotlist *item)
|
||||
movelist_dlg =
|
||||
create_dlg (0, 0, LINES - 6, movelist_cols, dialog_colors,
|
||||
hotlist_callback, "[Hotlist]", hdr, DLG_CENTER | DLG_REVERSE);
|
||||
g_free (hdr);
|
||||
mhl_mem_free (hdr);
|
||||
|
||||
for (i = 0; i < BUTTONS; i++) {
|
||||
if (hotlist_but[i].type & list_type)
|
||||
@ -811,7 +812,7 @@ add2hotlist (char *label, char *directory, enum HotListType type, int pos)
|
||||
char *lbl = g_strconcat ("->", new->label, (char *) NULL);
|
||||
|
||||
listbox_add_item (l_hotlist, pos, 0, lbl, new);
|
||||
g_free (lbl);
|
||||
mhl_mem_free (lbl);
|
||||
} else
|
||||
listbox_add_item (l_hotlist, pos, 0, new->label, new);
|
||||
listbox_select_entry (l_hotlist, l_hotlist->current);
|
||||
@ -937,13 +938,13 @@ static void add_new_entry_cmd (void)
|
||||
|
||||
ret = add_new_entry_input (_("New hotlist entry"), _("Directory label"),
|
||||
_("Directory path"), "[Hotlist]", &title, &url);
|
||||
g_free (to_free);
|
||||
mhl_mem_free (to_free);
|
||||
|
||||
if (!ret)
|
||||
return;
|
||||
if (!title || !*title || !url || !*url) {
|
||||
g_free (title);
|
||||
g_free (url);
|
||||
mhl_mem_free (title);
|
||||
mhl_mem_free (url);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1044,11 +1045,11 @@ void add2hotlist_cmd (void)
|
||||
|
||||
prompt = g_strdup_printf (cp, path_trunc (current_panel->cwd, COLS-2*UX-(l+8)));
|
||||
label = input_dialog (_(" Add to hotlist "), prompt, MC_HISTORY_HOTLIST_ADD, label_string);
|
||||
g_free (prompt);
|
||||
mhl_mem_free (prompt);
|
||||
|
||||
if (!label || !*label) {
|
||||
g_free (label_string);
|
||||
g_free (label);
|
||||
mhl_mem_free (label_string);
|
||||
mhl_mem_free (label);
|
||||
return;
|
||||
}
|
||||
add2hotlist (label, label_string, HL_TYPE_ENTRY, 0);
|
||||
@ -1065,9 +1066,9 @@ static void remove_group (struct hotlist *grp)
|
||||
if (current->type == HL_TYPE_GROUP)
|
||||
remove_group (current);
|
||||
|
||||
g_free (current->label);
|
||||
g_free (current->directory);
|
||||
g_free (current);
|
||||
mhl_mem_free (current->label);
|
||||
mhl_mem_free (current->directory);
|
||||
mhl_mem_free (current);
|
||||
|
||||
current = next;
|
||||
}
|
||||
@ -1094,7 +1095,7 @@ static void remove_from_hotlist (struct hotlist *entry)
|
||||
_("\n Are you sure you want to remove this entry?"),
|
||||
D_ERROR, 2, _("&Yes"), _("&No"));
|
||||
|
||||
g_free (title);
|
||||
mhl_mem_free (title);
|
||||
|
||||
if (result != 0)
|
||||
return;
|
||||
@ -1112,7 +1113,7 @@ static void remove_from_hotlist (struct hotlist *entry)
|
||||
result = query_dialog (header, _("\n Group not empty.\n Remove it?"),
|
||||
D_ERROR, 2,
|
||||
_("&Yes"), _("&No"));
|
||||
g_free (header);
|
||||
mhl_mem_free (header);
|
||||
|
||||
if (result != 0)
|
||||
return;
|
||||
@ -1123,9 +1124,9 @@ static void remove_from_hotlist (struct hotlist *entry)
|
||||
|
||||
unlink_entry (entry);
|
||||
|
||||
g_free (entry->label);
|
||||
g_free (entry->directory);
|
||||
g_free (entry);
|
||||
mhl_mem_free (entry->label);
|
||||
mhl_mem_free (entry->directory);
|
||||
mhl_mem_free (entry);
|
||||
/* now remove list entry from screen */
|
||||
listbox_remove_current (l_hotlist, 1);
|
||||
hotlist_state.modified = 1;
|
||||
@ -1183,7 +1184,7 @@ load_group (struct hotlist *grp)
|
||||
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
||||
add2hotlist (g_strdup (value), g_strdup (key), HL_TYPE_GROUP, 0);
|
||||
}
|
||||
g_free (group_section);
|
||||
mhl_mem_free (group_section);
|
||||
|
||||
profile_keys = profile_init_iterator (grp->directory, profile_name);
|
||||
|
||||
@ -1427,7 +1428,7 @@ clean_up_hotlist_groups (const char *section)
|
||||
}
|
||||
profile_clean_section (grp_section, profile_name);
|
||||
}
|
||||
g_free (grp_section);
|
||||
mhl_mem_free (grp_section);
|
||||
}
|
||||
|
||||
|
||||
@ -1572,7 +1573,7 @@ int save_hotlist (void)
|
||||
hotlist_state.modified = 0;
|
||||
} else
|
||||
rename (fbak, hotlist_file_name);
|
||||
g_free (fbak);
|
||||
mhl_mem_free (fbak);
|
||||
}
|
||||
|
||||
return saved;
|
||||
@ -1586,20 +1587,20 @@ void done_hotlist (void)
|
||||
{
|
||||
if (hotlist){
|
||||
remove_group (hotlist);
|
||||
g_free (hotlist->label);
|
||||
g_free (hotlist->directory);
|
||||
g_free (hotlist);
|
||||
mhl_mem_free (hotlist->label);
|
||||
mhl_mem_free (hotlist->directory);
|
||||
mhl_mem_free (hotlist);
|
||||
hotlist = 0;
|
||||
}
|
||||
|
||||
hotlist_state.loaded = 0;
|
||||
|
||||
g_free (hotlist_file_name);
|
||||
mhl_mem_free (hotlist_file_name);
|
||||
hotlist_file_name = 0;
|
||||
l_hotlist = 0;
|
||||
current_group = 0;
|
||||
if (tkn_buf){
|
||||
g_free (tkn_buf);
|
||||
mhl_mem_free (tkn_buf);
|
||||
tkn_buf_length = 0;
|
||||
tkn_length = 0;
|
||||
tkn_buf = NULL;
|
||||
|
@ -29,10 +29,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "mouse.h"
|
||||
@ -152,7 +153,7 @@ void delete_select_channel (int fd)
|
||||
else
|
||||
select_list = p_next;
|
||||
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
p = p_next;
|
||||
continue;
|
||||
}
|
||||
@ -1395,7 +1396,7 @@ static void k_dispose (key_def *k)
|
||||
return;
|
||||
k_dispose (k->child);
|
||||
k_dispose (k->next);
|
||||
g_free (k);
|
||||
mhl_mem_free (k);
|
||||
}
|
||||
|
||||
static void s_dispose (SelectList *sel)
|
||||
@ -1404,7 +1405,7 @@ static void s_dispose (SelectList *sel)
|
||||
return;
|
||||
|
||||
s_dispose (sel->next);
|
||||
g_free (sel);
|
||||
mhl_mem_free (sel);
|
||||
}
|
||||
|
||||
void done_key ()
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
/*
|
||||
@ -41,6 +40,8 @@
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h" /* COLS */
|
||||
#include "win.h"
|
||||
@ -1050,13 +1051,13 @@ void swap_panels ()
|
||||
|
||||
if (panels [0].type == view_listing) {
|
||||
if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) {
|
||||
g_free (panel1->panel_name);
|
||||
mhl_mem_free (panel1->panel_name);
|
||||
panel1->panel_name = g_strdup (get_nth_panel_name (1));
|
||||
}
|
||||
}
|
||||
if (panels [1].type == view_listing) {
|
||||
if (!strcmp (panel2->panel_name, get_nth_panel_name (1))) {
|
||||
g_free (panel2->panel_name);
|
||||
mhl_mem_free (panel2->panel_name);
|
||||
panel2->panel_name = g_strdup (get_nth_panel_name (0));
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "win.h"
|
||||
@ -88,7 +89,7 @@ _("Please press the %s\n"
|
||||
_(key_name_conv_tab [action - B_USER].longname));
|
||||
mc_refresh ();
|
||||
if (learnkeys [action - B_USER].sequence != NULL) {
|
||||
g_free (learnkeys [action - B_USER].sequence);
|
||||
mhl_mem_free (learnkeys [action - B_USER].sequence);
|
||||
learnkeys [action - B_USER].sequence = NULL;
|
||||
}
|
||||
seq = learn_key ();
|
||||
@ -117,7 +118,7 @@ _("Please press the %s\n"
|
||||
_(" You have entered \"%s\""), seq);
|
||||
}
|
||||
|
||||
g_free (seq);
|
||||
mhl_mem_free (seq);
|
||||
}
|
||||
|
||||
dlg_run_done (d);
|
||||
@ -327,7 +328,7 @@ learn_save (void)
|
||||
if (profile_changed)
|
||||
sync_profiles ();
|
||||
|
||||
g_free (section);
|
||||
mhl_mem_free (section);
|
||||
}
|
||||
|
||||
void learn_keys (void)
|
||||
|
@ -289,7 +289,7 @@ listmode_edit (char *oldlistformat)
|
||||
|
||||
s = g_strdup (oldlistformat);
|
||||
listmode_dlg = init_listmode (s);
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
|
||||
if (run_dlg (listmode_dlg) == B_ENTER) {
|
||||
newformat = collect_new_format ();
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "logging.h"
|
||||
#include "setup.h"
|
||||
@ -43,7 +45,7 @@ is_logging_enabled(void)
|
||||
mc_ini = g_strdup_printf("%s/%s", home_dir, PROFILE_NAME);
|
||||
logging_enabled =
|
||||
get_int(mc_ini, "development.enable_logging", FALSE);
|
||||
g_free(mc_ini);
|
||||
mhl_mem_free(mc_ini);
|
||||
logging_initialized = TRUE;
|
||||
}
|
||||
return logging_enabled;
|
||||
@ -65,6 +67,6 @@ mc_log(const char *fmt, ...)
|
||||
(void)vfprintf(f, fmt, args);
|
||||
(void)fclose(f);
|
||||
}
|
||||
g_free(logfilename);
|
||||
mhl_mem_free(logfilename);
|
||||
}
|
||||
}
|
||||
|
41
src/main.c
41
src/main.c
@ -29,11 +29,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "dir.h"
|
||||
@ -301,7 +302,7 @@ reload_panelized (WPanel *panel)
|
||||
do_file_mark (panel, i, 0);
|
||||
}
|
||||
if (mc_lstat (list->list[i].fname, &list->list[i].st)) {
|
||||
g_free (list->list[i].fname);
|
||||
mhl_mem_free (list->list[i].fname);
|
||||
continue;
|
||||
}
|
||||
if (list->list[i].f.marked)
|
||||
@ -349,7 +350,7 @@ update_one_panel_widget (WPanel *panel, int force_update,
|
||||
panel->dirty = 1;
|
||||
|
||||
if (free_pointer)
|
||||
g_free (my_current_file);
|
||||
mhl_mem_free (my_current_file);
|
||||
}
|
||||
|
||||
void
|
||||
@ -589,11 +590,11 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type)
|
||||
|
||||
if (mc_chdir (directory) == -1) {
|
||||
strcpy (panel->cwd, olddir);
|
||||
g_free (olddir);
|
||||
g_free (translated_url);
|
||||
mhl_mem_free (olddir);
|
||||
mhl_mem_free (translated_url);
|
||||
return 0;
|
||||
}
|
||||
g_free (translated_url);
|
||||
mhl_mem_free (translated_url);
|
||||
|
||||
/* Success: save previous directory, shutdown status of previous dir */
|
||||
strcpy (panel->lwd, olddir);
|
||||
@ -616,7 +617,7 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type)
|
||||
panel->dirty = 1;
|
||||
update_xterm_title_path ();
|
||||
|
||||
g_free (olddir);
|
||||
mhl_mem_free (olddir);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -687,7 +688,7 @@ directory_history_list (WPanel *panel)
|
||||
directory_history_add (panel, panel->cwd);
|
||||
else
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot change directory"));
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SUBSHELL_SUPPORT
|
||||
@ -776,7 +777,7 @@ treebox_cmd (void)
|
||||
sel_dir = tree_box (selection (current_panel)->fname);
|
||||
if (sel_dir) {
|
||||
do_cd (sel_dir, cd_exact);
|
||||
g_free (sel_dir);
|
||||
mhl_mem_free (sel_dir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -793,7 +794,7 @@ listmode_cmd (void)
|
||||
if (!newmode)
|
||||
return;
|
||||
|
||||
g_free (current_panel->user_format);
|
||||
mhl_mem_free (current_panel->user_format);
|
||||
current_panel->list_type = list_user;
|
||||
current_panel->user_format = newmode;
|
||||
set_panel_formats (current_panel);
|
||||
@ -1035,7 +1036,7 @@ translated_mc_chdir (char *dir)
|
||||
|
||||
newdir = vfs_translate_url (dir);
|
||||
mc_chdir (newdir);
|
||||
g_free (newdir);
|
||||
mhl_mem_free (newdir);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1141,7 +1142,7 @@ copy_readlink (WPanel *panel)
|
||||
int i;
|
||||
|
||||
i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
if (i > 0) {
|
||||
buffer[i] = 0;
|
||||
command_insert (cmdline, buffer, 1);
|
||||
@ -1621,7 +1622,7 @@ update_xterm_title_path (void)
|
||||
numeric_keypad_mode ();
|
||||
fprintf (stdout, "\33]0;mc - %s\7", p);
|
||||
fflush (stdout);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1645,7 +1646,7 @@ load_hint (int force)
|
||||
if ((hint = get_random_hint (force))) {
|
||||
if (*hint)
|
||||
set_hintbar (hint);
|
||||
g_free (hint);
|
||||
mhl_mem_free (hint);
|
||||
} else {
|
||||
char text[BUF_SMALL];
|
||||
|
||||
@ -1713,7 +1714,7 @@ mc_maybe_editor_or_viewer (void)
|
||||
char *path = NULL;
|
||||
path = prepend_cwd_on_local (view_one_file);
|
||||
view_file (path, 0, 1);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
}
|
||||
#ifdef USE_INTERNAL_EDIT
|
||||
else {
|
||||
@ -2082,7 +2083,7 @@ handle_args (int argc, char *argv[])
|
||||
edit_one_file = fname;
|
||||
edit_one_file_start_line = atoi (p);
|
||||
} else {
|
||||
g_free (fname);
|
||||
mhl_mem_free (fname);
|
||||
goto try_plus_filename;
|
||||
}
|
||||
} else {
|
||||
@ -2251,15 +2252,15 @@ main (int argc, char *argv[])
|
||||
close (last_wd_fd);
|
||||
}
|
||||
}
|
||||
g_free (last_wd_string);
|
||||
mhl_mem_free (last_wd_string);
|
||||
|
||||
g_free (mc_home);
|
||||
mhl_mem_free (mc_home);
|
||||
done_key ();
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
g_free (this_dir);
|
||||
g_free (other_dir);
|
||||
mhl_mem_free (this_dir);
|
||||
mhl_mem_free (other_dir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -21,9 +21,10 @@
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "menu.h"
|
||||
@ -531,9 +532,9 @@ menubar_arrange(WMenu* menubar)
|
||||
void
|
||||
destroy_menu (Menu *menu)
|
||||
{
|
||||
g_free (menu->name);
|
||||
g_free (menu->help_node);
|
||||
g_free (menu);
|
||||
mhl_mem_free (menu->name);
|
||||
mhl_mem_free (menu->help_node);
|
||||
mhl_mem_free (menu);
|
||||
}
|
||||
|
||||
WMenu *
|
||||
|
@ -25,11 +25,12 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h" /* attrset() */
|
||||
#include "win.h"
|
||||
@ -232,7 +233,7 @@ add2panelize_cmd (void)
|
||||
if (!label)
|
||||
return;
|
||||
if (!*label) {
|
||||
g_free (label);
|
||||
mhl_mem_free (label);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -254,9 +255,9 @@ static void remove_from_panelize (struct panelize *entry)
|
||||
}
|
||||
}
|
||||
|
||||
g_free (entry->label);
|
||||
g_free (entry->command);
|
||||
g_free (entry);
|
||||
mhl_mem_free (entry->label);
|
||||
mhl_mem_free (entry->command);
|
||||
mhl_mem_free (entry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,7 +297,7 @@ external_panelize (void)
|
||||
char *cmd = g_strdup (target);
|
||||
destroy_dlg (panelize_dlg);
|
||||
do_external_panelize (cmd);
|
||||
g_free (cmd);
|
||||
mhl_mem_free (cmd);
|
||||
repaint_screen ();
|
||||
return;
|
||||
}
|
||||
@ -350,9 +351,9 @@ void done_panelize (void)
|
||||
|
||||
for (; current; current = next){
|
||||
next = current->next;
|
||||
g_free (current->label);
|
||||
g_free (current->command);
|
||||
g_free (current);
|
||||
mhl_mem_free (current->label);
|
||||
mhl_mem_free (current->command);
|
||||
mhl_mem_free (current);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "profile.h"
|
||||
|
||||
@ -248,7 +249,7 @@ static TSecHeader *load (const char *file)
|
||||
break;
|
||||
case OnSecHeader: { /* Broken initialization file */
|
||||
TSecHeader *link = SecHeader->link;
|
||||
g_free (SecHeader);
|
||||
mhl_mem_free (SecHeader);
|
||||
SecHeader = link;
|
||||
fprintf (stderr, "Warning: Corrupted initialization file `%s'\n",
|
||||
file);
|
||||
@ -298,7 +299,7 @@ GetSetProfileChar (int set, const char *AppName, const char *KeyName,
|
||||
if ( g_strcasecmp (key->KeyName, KeyName))
|
||||
continue;
|
||||
if (set){
|
||||
g_free (key->Value);
|
||||
mhl_mem_free (key->Value);
|
||||
key->Value = g_strdup (Default);
|
||||
}
|
||||
return key->Value;
|
||||
@ -382,7 +383,7 @@ static void dump_keys (FILE * profile, TKeys * p)
|
||||
dump_keys (profile, p->link);
|
||||
t = str_untranslate_newline_dup (p->Value);
|
||||
fprintf (profile, "%s=%s\n", p->KeyName, t);
|
||||
g_free (t);
|
||||
mhl_mem_free (t);
|
||||
}
|
||||
|
||||
static void dump_sections (FILE *profile, TSecHeader *p)
|
||||
@ -425,9 +426,9 @@ static void free_keys (TKeys *p)
|
||||
if (!p)
|
||||
return;
|
||||
free_keys (p->link);
|
||||
g_free (p->KeyName);
|
||||
g_free (p->Value);
|
||||
g_free (p);
|
||||
mhl_mem_free (p->KeyName);
|
||||
mhl_mem_free (p->Value);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
static void free_sections (TSecHeader *p)
|
||||
@ -436,10 +437,10 @@ static void free_sections (TSecHeader *p)
|
||||
return;
|
||||
free_sections (p->link);
|
||||
free_keys (p->Keys);
|
||||
g_free (p->AppName);
|
||||
mhl_mem_free (p->AppName);
|
||||
p->link = 0;
|
||||
p->Keys = 0;
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
static void free_profile (TProfile *p)
|
||||
@ -448,8 +449,8 @@ static void free_profile (TProfile *p)
|
||||
return;
|
||||
free_profile (p->link);
|
||||
free_sections (p->Section);
|
||||
g_free (p->FileName);
|
||||
g_free (p);
|
||||
mhl_mem_free (p->FileName);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
void free_profile_name (const char *s)
|
||||
|
@ -21,10 +21,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h" /* move, addch */
|
||||
#include "cons.saver.h"
|
||||
@ -113,6 +114,6 @@ void show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
|
||||
move (starty + (i / cols), 0);
|
||||
addch (is_printable (k[i]) ? k[i] : ' ');
|
||||
}
|
||||
g_free (k);
|
||||
mhl_mem_free (k);
|
||||
}
|
||||
|
||||
|
61
src/screen.c
61
src/screen.c
@ -25,9 +25,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "dir.h"
|
||||
@ -131,7 +132,7 @@ delete_format (format_e *format)
|
||||
|
||||
while (format){
|
||||
next = format->next;
|
||||
g_free (format);
|
||||
mhl_mem_free (format);
|
||||
format = next;
|
||||
}
|
||||
}
|
||||
@ -711,7 +712,7 @@ display_mini_info (WPanel *panel)
|
||||
|
||||
link = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
|
||||
len = mc_readlink (link, link_target, MC_MAXPATHLEN - 1);
|
||||
g_free (link);
|
||||
mhl_mem_free (link);
|
||||
if (len > 0){
|
||||
link_target[len] = 0;
|
||||
tty_printf ("-> %-*s", panel->widget.cols - 5,
|
||||
@ -796,7 +797,7 @@ show_dir (WPanel *panel)
|
||||
trim (strip_home_and_password (panel->cwd), tmp,
|
||||
max (panel->widget.cols - 9, 0));
|
||||
addstr (tmp);
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
|
||||
addch (' ');
|
||||
widget_move (&panel->widget, 0, 1);
|
||||
@ -892,7 +893,7 @@ do_try_to_select (WPanel *panel, const char *name)
|
||||
for (i = 0; i < panel->count; i++){
|
||||
if (strcmp (subdir, panel->dir.list [i].fname) == 0) {
|
||||
do_select (panel, i);
|
||||
g_free (subdir);
|
||||
mhl_mem_free (subdir);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -900,7 +901,7 @@ do_try_to_select (WPanel *panel, const char *name)
|
||||
/* Try to select a file near the file that is missing */
|
||||
if (panel->selected >= panel->count)
|
||||
do_select (panel, panel->count-1);
|
||||
g_free (subdir);
|
||||
mhl_mem_free (subdir);
|
||||
}
|
||||
|
||||
void
|
||||
@ -964,21 +965,21 @@ panel_destroy (WPanel *p)
|
||||
history_put (p->hist_name, p->dir_history);
|
||||
|
||||
p->dir_history = g_list_first (p->dir_history);
|
||||
g_list_foreach (p->dir_history, (GFunc) g_free, NULL);
|
||||
g_list_foreach (p->dir_history, (GFunc) mhl_mem_free, NULL);
|
||||
g_list_free (p->dir_history);
|
||||
}
|
||||
|
||||
g_free (p->hist_name);
|
||||
mhl_mem_free (p->hist_name);
|
||||
|
||||
delete_format (p->format);
|
||||
delete_format (p->status_format);
|
||||
|
||||
g_free (p->user_format);
|
||||
mhl_mem_free (p->user_format);
|
||||
for (i = 0; i < LIST_TYPES; i++)
|
||||
g_free (p->user_status_format[i]);
|
||||
g_free (p->dir.list);
|
||||
g_free (p->panel_name);
|
||||
g_free (name);
|
||||
mhl_mem_free (p->user_status_format[i]);
|
||||
mhl_mem_free (p->dir.list);
|
||||
mhl_mem_free (p->panel_name);
|
||||
mhl_mem_free (name);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1039,11 +1040,11 @@ panel_new (const char *panel_name)
|
||||
panel->frame_size = frame_half;
|
||||
section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
|
||||
if (!profile_has_section (section, profile_name)) {
|
||||
g_free (section);
|
||||
mhl_mem_free (section);
|
||||
section = g_strdup (panel->panel_name);
|
||||
}
|
||||
panel_load_setup (panel, section);
|
||||
g_free (section);
|
||||
mhl_mem_free (section);
|
||||
|
||||
/* Load format strings */
|
||||
err = set_panel_formats (panel);
|
||||
@ -1326,7 +1327,7 @@ parse_display_format (WPanel *panel, const char *format, char **error, int issta
|
||||
delete_format (home);
|
||||
tmp_format [pos] = 0;
|
||||
*error = g_strconcat (_("Unknown tag on display format: "), tmp_format, (char *) NULL);
|
||||
g_free (tmp_format);
|
||||
mhl_mem_free (tmp_format);
|
||||
return 0;
|
||||
}
|
||||
total_cols += darr->requested_field_len;
|
||||
@ -1415,7 +1416,7 @@ set_panel_formats (WPanel *p)
|
||||
form = use_display_format (p, panel_format (p), &err, 0);
|
||||
|
||||
if (err){
|
||||
g_free (err);
|
||||
mhl_mem_free (err);
|
||||
retcode = 1;
|
||||
}
|
||||
else {
|
||||
@ -1430,7 +1431,7 @@ set_panel_formats (WPanel *p)
|
||||
form = use_display_format (p, mini_status_format (p), &err, 1);
|
||||
|
||||
if (err){
|
||||
g_free (err);
|
||||
mhl_mem_free (err);
|
||||
retcode += 2;
|
||||
}
|
||||
else {
|
||||
@ -1447,11 +1448,11 @@ set_panel_formats (WPanel *p)
|
||||
if (retcode)
|
||||
message( 1, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) );
|
||||
if (retcode & 0x01){
|
||||
g_free (p->user_format);
|
||||
mhl_mem_free (p->user_format);
|
||||
p->user_format = g_strdup (DEFAULT_USER_FORMAT);
|
||||
}
|
||||
if (retcode & 0x02){
|
||||
g_free (p->user_status_format [p->list_type]);
|
||||
mhl_mem_free (p->user_status_format [p->list_type]);
|
||||
p->user_status_format [p->list_type] = g_strdup (DEFAULT_USER_FORMAT);
|
||||
}
|
||||
|
||||
@ -1976,10 +1977,10 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
/* Check if the file is executable */
|
||||
full_name = concat_dir_and_file (current_panel->cwd, fe->fname);
|
||||
if (!is_exe (fe->st.st_mode) || !if_link_is_exe (full_name, fe)) {
|
||||
g_free (full_name);
|
||||
mhl_mem_free (full_name);
|
||||
return 0;
|
||||
}
|
||||
g_free (full_name);
|
||||
mhl_mem_free (full_name);
|
||||
|
||||
if (confirm_execute) {
|
||||
if (query_dialog
|
||||
@ -1995,7 +1996,7 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
|
||||
tmp = concat_dir_and_file (vfs_get_current_dir (), fe->fname);
|
||||
ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL);
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
/* We took action only if the dialog was shown or the execution
|
||||
* was successful */
|
||||
return confirm_execute || (ret == 0);
|
||||
@ -2005,9 +2006,9 @@ do_enter_on_file_entry (file_entry *fe)
|
||||
{
|
||||
char *tmp = name_quote (fe->fname, 0);
|
||||
char *cmd = g_strconcat (".", PATH_SEP_STR, tmp, (char *) NULL);
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
shell_execute (cmd, 0);
|
||||
g_free (cmd);
|
||||
mhl_mem_free (cmd);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -2043,7 +2044,7 @@ chdir_other_panel (WPanel *panel)
|
||||
|
||||
move_down (panel);
|
||||
|
||||
g_free (new_dir);
|
||||
mhl_mem_free (new_dir);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2107,7 +2108,7 @@ chdir_to_readlink (WPanel *panel)
|
||||
|
||||
move_down (panel);
|
||||
|
||||
g_free (new_dir);
|
||||
mhl_mem_free (new_dir);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2254,7 +2255,7 @@ panel_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
char *cwd = strip_password (g_strdup (panel->cwd), 1);
|
||||
message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "),
|
||||
cwd, unix_error_string (errno));
|
||||
g_free(cwd);
|
||||
mhl_mem_free(cwd);
|
||||
} else
|
||||
subshell_chdir (panel->cwd);
|
||||
|
||||
@ -2474,7 +2475,7 @@ panel_re_sort (WPanel *panel)
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_free (filename);
|
||||
mhl_mem_free (filename);
|
||||
panel->top_file = panel->selected - ITEMS (panel)/2;
|
||||
if (panel->top_file < 0)
|
||||
panel->top_file = 0;
|
||||
@ -2497,7 +2498,7 @@ panel_set_sort_order (WPanel *panel, sortfn *sort_order)
|
||||
current_file = g_strdup (panel->dir.list [panel->selected].fname);
|
||||
panel_reload (panel);
|
||||
try_to_select (panel, current_file);
|
||||
g_free (current_file);
|
||||
mhl_mem_free (current_file);
|
||||
}
|
||||
panel_re_sort (panel);
|
||||
}
|
||||
|
29
src/setup.c
29
src/setup.c
@ -20,10 +20,11 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "dir.h"
|
||||
@ -292,7 +293,7 @@ save_layout (void)
|
||||
save_string ("Layout", layout [i].opt_name, buffer, profile);
|
||||
}
|
||||
|
||||
g_free (profile);
|
||||
mhl_mem_free (profile);
|
||||
}
|
||||
|
||||
void
|
||||
@ -312,7 +313,7 @@ save_configure (void)
|
||||
set_config_string (profile, str_options[i].opt_name,
|
||||
*str_options[i].opt_addr);
|
||||
|
||||
g_free (profile);
|
||||
mhl_mem_free (profile);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -379,7 +380,7 @@ save_setup (void)
|
||||
get_codepage_id( display_codepage ), profile_name );
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
g_free (profile);
|
||||
mhl_mem_free (profile);
|
||||
saving_setup = 0;
|
||||
}
|
||||
|
||||
@ -412,12 +413,12 @@ panel_load_setup (WPanel *panel, const char *section)
|
||||
}
|
||||
|
||||
/* User formats */
|
||||
g_free (panel->user_format);
|
||||
mhl_mem_free (panel->user_format);
|
||||
panel->user_format = g_strdup (get_profile_string (section, "user_format",
|
||||
DEFAULT_USER_FORMAT,
|
||||
profile_name));
|
||||
for (i = 0; i < LIST_TYPES; i++){
|
||||
g_free (panel->user_status_format [i]);
|
||||
mhl_mem_free (panel->user_status_format [i]);
|
||||
g_snprintf (buffer, sizeof (buffer), "user_status%d", i);
|
||||
panel->user_status_format [i] =
|
||||
g_strdup (get_profile_string (section, buffer,
|
||||
@ -470,7 +471,7 @@ do_load_string (const char *s, const char *ss, const char *def)
|
||||
load_string (s, ss, def, buffer, BUF_SMALL);
|
||||
|
||||
p = g_strdup (buffer);
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
return p;
|
||||
}
|
||||
#endif /* !USE_NETCODE */
|
||||
@ -488,10 +489,10 @@ setup_init (void)
|
||||
if (!exist_file (profile)){
|
||||
inifile = concat_dir_and_file (mc_home, "mc.ini");
|
||||
if (exist_file (inifile)){
|
||||
g_free (profile);
|
||||
mhl_mem_free (profile);
|
||||
profile = inifile;
|
||||
} else
|
||||
g_free (inifile);
|
||||
mhl_mem_free (inifile);
|
||||
}
|
||||
|
||||
profile_name = profile;
|
||||
@ -541,7 +542,7 @@ load_setup (void)
|
||||
if (vfs_file_is_local (buffer))
|
||||
other_dir = buffer;
|
||||
else
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
}
|
||||
|
||||
boot_current_is_left =
|
||||
@ -602,8 +603,8 @@ load_anon_passwd ()
|
||||
|
||||
void done_setup (void)
|
||||
{
|
||||
g_free (profile_name);
|
||||
g_free (global_profile_name);
|
||||
mhl_mem_free (profile_name);
|
||||
mhl_mem_free (global_profile_name);
|
||||
done_hotlist ();
|
||||
done_panelize ();
|
||||
/* directory_history_free (); */
|
||||
@ -622,7 +623,7 @@ load_keys_from_section (const char *terminal, const char *profile_name)
|
||||
|
||||
section_name = g_strconcat ("terminal:", terminal, (char *) NULL);
|
||||
profile_keys = profile_init_iterator (section_name, profile_name);
|
||||
g_free (section_name);
|
||||
mhl_mem_free (section_name);
|
||||
while (profile_keys){
|
||||
profile_keys = profile_iterator_next (profile_keys, &key, &value);
|
||||
|
||||
@ -636,7 +637,7 @@ load_keys_from_section (const char *terminal, const char *profile_name)
|
||||
if (key_code){
|
||||
valcopy = convert_controls (value);
|
||||
define_sequence (key_code, valcopy, MCKEY_NOACTION);
|
||||
g_free (valcopy);
|
||||
mhl_mem_free (valcopy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,8 @@
|
||||
# include <stropts.h> /* For I_PUSH */
|
||||
#endif /* HAVE_STROPTS_H */
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h" /* LINES */
|
||||
#include "panel.h" /* current_panel */
|
||||
@ -670,8 +672,8 @@ exit_subshell (void)
|
||||
tcsh_fifo, unix_error_string (errno));
|
||||
}
|
||||
|
||||
g_free (subshell_prompt);
|
||||
g_free (pty_buffer);
|
||||
mhl_mem_free (subshell_prompt);
|
||||
mhl_mem_free (pty_buffer);
|
||||
subshell_prompt = NULL;
|
||||
pty_buffer = NULL;
|
||||
}
|
||||
@ -762,7 +764,7 @@ do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
|
||||
char *temp = subshell_name_quote (directory);
|
||||
if (temp) {
|
||||
write_all (subshell_pty, temp, strlen (temp));
|
||||
g_free (temp);
|
||||
mhl_mem_free (temp);
|
||||
} else {
|
||||
/* Should not happen unless the directory name is so long
|
||||
that we don't have memory to quote it. */
|
||||
@ -798,7 +800,7 @@ do_subshell_chdir (const char *directory, int do_update, int reset_prompt)
|
||||
if (bPathNotEq && strcmp (current_panel->cwd, ".")) {
|
||||
char *cwd = strip_password (g_strdup (current_panel->cwd), 1);
|
||||
fprintf (stderr, _("Warning: Cannot change to %s.\n"), cwd);
|
||||
g_free (cwd);
|
||||
mhl_mem_free (cwd);
|
||||
}
|
||||
}
|
||||
|
||||
|
20
src/tree.c
20
src/tree.c
@ -33,6 +33,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "color.h"
|
||||
@ -126,7 +128,7 @@ static void tree_destroy (WTree *tree)
|
||||
tree_store_remove_entry_remove_hook (remove_callback);
|
||||
save_tree (tree);
|
||||
|
||||
g_free (tree->tree_shown);
|
||||
mhl_mem_free (tree->tree_shown);
|
||||
tree->tree_shown = 0;
|
||||
tree->selected_ptr = NULL;
|
||||
}
|
||||
@ -206,7 +208,7 @@ static void show_tree (WTree *tree)
|
||||
x = y = 1;
|
||||
}
|
||||
|
||||
g_free (tree->tree_shown);
|
||||
mhl_mem_free (tree->tree_shown);
|
||||
tree->tree_shown = g_new (tree_entry*, tree_lines);
|
||||
|
||||
for (i = 0; i < tree_lines; i++)
|
||||
@ -605,7 +607,7 @@ static void tree_copy (WTree *tree, const char *default_dest)
|
||||
return;
|
||||
|
||||
if (!*dest){
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -614,7 +616,7 @@ static void tree_copy (WTree *tree, const char *default_dest)
|
||||
copy_dir_dir (ctx, tree->selected_ptr->name, dest, 1, 0, 0, 0, &count, &bytes);
|
||||
file_op_context_destroy (ctx);
|
||||
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -646,19 +648,19 @@ static void tree_move (WTree *tree, const char *default_dest)
|
||||
if (!dest)
|
||||
return;
|
||||
if (!*dest){
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
return;
|
||||
}
|
||||
if (stat (dest, &buf)){
|
||||
message (D_ERROR, MSG_ERROR, _(" Cannot stat the destination \n %s "),
|
||||
unix_error_string (errno));
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
return;
|
||||
}
|
||||
if (!S_ISDIR (buf.st_mode)){
|
||||
file_error (_(" Destination \"%s\" must be a directory \n %s "),
|
||||
dest);
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -667,7 +669,7 @@ static void tree_move (WTree *tree, const char *default_dest)
|
||||
move_dir_dir (ctx, tree->selected_ptr->name, dest, &count, &bytes);
|
||||
file_op_context_destroy (ctx);
|
||||
|
||||
g_free (dest);
|
||||
mhl_mem_free (dest);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -716,7 +718,7 @@ tree_rmdir_cmd (WTree *tree)
|
||||
tree->selected_ptr->name);
|
||||
result =
|
||||
query_dialog (_(" Delete "), buf, D_ERROR, 2, _("&Yes"), _("&No"));
|
||||
g_free (buf);
|
||||
mhl_mem_free (buf);
|
||||
if (result != 0)
|
||||
return;
|
||||
}
|
||||
|
@ -37,11 +37,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "treestore.h"
|
||||
#include "profile.h"
|
||||
@ -236,7 +237,7 @@ tree_store_load_from(char *name)
|
||||
}
|
||||
strcpy(oldname, name);
|
||||
}
|
||||
g_free(name);
|
||||
mhl_mem_free(name);
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
@ -267,7 +268,7 @@ tree_store_load(void)
|
||||
|
||||
name = concat_dir_and_file(home_dir, MC_TREE);
|
||||
retval = tree_store_load_from(name);
|
||||
g_free(name);
|
||||
mhl_mem_free(name);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -334,12 +335,12 @@ tree_store_save_to(char *name)
|
||||
|
||||
i = fprintf(file, "%d:%d %s\n", current->scanned, common,
|
||||
encoded);
|
||||
g_free(encoded);
|
||||
mhl_mem_free(encoded);
|
||||
} else {
|
||||
char *encoded = encode(current->name);
|
||||
|
||||
i = fprintf(file, "%d:%s\n", current->scanned, encoded);
|
||||
g_free(encoded);
|
||||
mhl_mem_free(encoded);
|
||||
}
|
||||
|
||||
if (i == EOF) {
|
||||
@ -375,15 +376,15 @@ tree_store_save(void)
|
||||
retval = tree_store_save_to(tmp);
|
||||
|
||||
if (retval) {
|
||||
g_free(tmp);
|
||||
mhl_mem_free(tmp);
|
||||
return retval;
|
||||
}
|
||||
|
||||
name = concat_dir_and_file(home_dir, MC_TREE);
|
||||
retval = rename(tmp, name);
|
||||
|
||||
g_free(tmp);
|
||||
g_free(name);
|
||||
mhl_mem_free(tmp);
|
||||
mhl_mem_free(name);
|
||||
|
||||
if (retval)
|
||||
return errno;
|
||||
@ -481,7 +482,7 @@ tree_store_add_entry(const char *name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_free(parent);
|
||||
mhl_mem_free(parent);
|
||||
}
|
||||
|
||||
tree_store_dirty(TRUE);
|
||||
@ -546,8 +547,8 @@ remove_entry(tree_entry * entry)
|
||||
ts.tree_last = entry->prev;
|
||||
|
||||
/* Free the memory used by the entry */
|
||||
g_free(entry->name);
|
||||
g_free(entry);
|
||||
mhl_mem_free(entry->name);
|
||||
mhl_mem_free(entry);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -617,7 +618,7 @@ tree_store_mark_checked(const char *subname)
|
||||
current = tree_store_add_entry(name);
|
||||
ts.add_queue = g_list_prepend(ts.add_queue, g_strdup(name));
|
||||
}
|
||||
g_free(name);
|
||||
mhl_mem_free(name);
|
||||
|
||||
/* Clear the deletion mark from the subdirectory and its children */
|
||||
base = current;
|
||||
@ -716,11 +717,11 @@ tree_store_end_check(void)
|
||||
ts.add_queue = g_list_reverse(ts.add_queue);
|
||||
the_queue = ts.add_queue;
|
||||
ts.add_queue = NULL;
|
||||
g_free(ts.check_name);
|
||||
mhl_mem_free(ts.check_name);
|
||||
ts.check_name = NULL;
|
||||
|
||||
for (l = the_queue; l; l = l->next) {
|
||||
g_free(l->data);
|
||||
mhl_mem_free(l->data);
|
||||
}
|
||||
|
||||
g_list_free(the_queue);
|
||||
@ -740,7 +741,7 @@ process_special_dirs(GList ** special_dirs, char *file)
|
||||
*special_dirs = g_list_prepend(*special_dirs, g_strdup(token));
|
||||
s = NULL;
|
||||
}
|
||||
g_free(buffer);
|
||||
mhl_mem_free(buffer);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -800,7 +801,7 @@ tree_store_rescan(const char *dir)
|
||||
if (S_ISDIR(buf.st_mode))
|
||||
tree_store_mark_checked(dp->d_name);
|
||||
}
|
||||
g_free(full_name);
|
||||
mhl_mem_free(full_name);
|
||||
}
|
||||
mc_closedir(dirp);
|
||||
}
|
||||
|
38
src/user.c
38
src/user.c
@ -23,6 +23,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "color.h"
|
||||
@ -142,7 +144,7 @@ int check_format_var (const char *p, char **v)
|
||||
var_name = g_strndup (p + 4, dots-2 - (p+3));
|
||||
|
||||
value = getenv (var_name);
|
||||
g_free (var_name);
|
||||
mhl_mem_free (var_name);
|
||||
if (value){
|
||||
*v = g_strdup (value);
|
||||
return q-p;
|
||||
@ -221,7 +223,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
|
||||
|
||||
qstr = (*quote_func) (cwd, 0);
|
||||
|
||||
g_free (cwd);
|
||||
mhl_mem_free (cwd);
|
||||
|
||||
return qstr;
|
||||
}
|
||||
@ -238,7 +240,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
|
||||
if (edit_widget) {
|
||||
char *file = g_strconcat (home_dir, PATH_SEP_STR BLOCK_FILE, (char *) NULL);
|
||||
fname = (*quote_func) (file, 0);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
return fname;
|
||||
} else if (c_lc == 'b') {
|
||||
return strip_ext ((*quote_func) (fname, 0));
|
||||
@ -278,7 +280,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
|
||||
if (panel->dir.list[i].f.marked) {
|
||||
strcat (block, tmp =
|
||||
(*quote_func) (panel->dir.list[i].fname, 0));
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
strcat (block, " ");
|
||||
if (c_lc == 'u')
|
||||
do_file_mark (panel, i, 0);
|
||||
@ -468,7 +470,7 @@ debug_out (char *start, char *end, int cond)
|
||||
|
||||
}
|
||||
debug_flag = 0;
|
||||
g_free (msg);
|
||||
mhl_mem_free (msg);
|
||||
msg = NULL;
|
||||
} else {
|
||||
const char *type;
|
||||
@ -492,7 +494,7 @@ debug_out (char *start, char *end, int cond)
|
||||
else
|
||||
p = g_strdup_printf ("%s%s%.*s \n", msg ? msg : "", type,
|
||||
(int) (end - start), start);
|
||||
g_free (msg);
|
||||
mhl_mem_free (msg);
|
||||
msg = p;
|
||||
}
|
||||
}
|
||||
@ -610,15 +612,15 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
|
||||
/* User canceled */
|
||||
fclose (cmd_file);
|
||||
unlink (file_name);
|
||||
g_free (file_name);
|
||||
mhl_mem_free (file_name);
|
||||
return;
|
||||
}
|
||||
if (do_quote) {
|
||||
fputs (tmp = name_quote (parameter, 0), cmd_file);
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
} else
|
||||
fputs (parameter, cmd_file);
|
||||
g_free (parameter);
|
||||
mhl_mem_free (parameter);
|
||||
parameter = 0;
|
||||
} else {
|
||||
if (parameter < &prompt [sizeof (prompt) - 1]) {
|
||||
@ -637,7 +639,7 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
|
||||
else{
|
||||
char *text = expand_format (edit_widget, *commands, do_quote);
|
||||
fputs (text, cmd_file);
|
||||
g_free (text);
|
||||
mhl_mem_free (text);
|
||||
}
|
||||
} else {
|
||||
if (*commands == '%') {
|
||||
@ -663,10 +665,10 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
|
||||
* on no-exec filesystems. */
|
||||
char *cmd = g_strconcat("/bin/sh ", file_name, (char *)NULL);
|
||||
shell_execute (cmd, EXECUTE_HIDE);
|
||||
g_free(cmd);
|
||||
mhl_mem_free(cmd);
|
||||
}
|
||||
unlink (file_name);
|
||||
g_free (file_name);
|
||||
mhl_mem_free (file_name);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -720,11 +722,11 @@ user_menu_cmd (struct WEdit *edit_widget)
|
||||
|
||||
menu = g_strdup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
|
||||
if (!exist_file (menu) || !menu_file_own (menu)){
|
||||
g_free (menu);
|
||||
mhl_mem_free (menu);
|
||||
menu = concat_dir_and_file \
|
||||
(home_dir, edit_widget ? CEDIT_HOME_MENU : MC_HOME_MENU);
|
||||
if (!exist_file (menu)){
|
||||
g_free (menu);
|
||||
mhl_mem_free (menu);
|
||||
menu = concat_dir_and_file \
|
||||
(mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
|
||||
}
|
||||
@ -733,7 +735,7 @@ user_menu_cmd (struct WEdit *edit_widget)
|
||||
if ((data = load_file (menu)) == NULL){
|
||||
message (D_ERROR, MSG_ERROR, _(" Cannot open file %s \n %s "),
|
||||
menu, unix_error_string (errno));
|
||||
g_free (menu);
|
||||
mhl_mem_free (menu);
|
||||
menu = NULL;
|
||||
return;
|
||||
}
|
||||
@ -838,9 +840,9 @@ user_menu_cmd (struct WEdit *edit_widget)
|
||||
}
|
||||
|
||||
easy_patterns = old_patterns;
|
||||
g_free (menu);
|
||||
mhl_mem_free (menu);
|
||||
menu = NULL;
|
||||
g_free (entries);
|
||||
g_free (data);
|
||||
mhl_mem_free (entries);
|
||||
mhl_mem_free (data);
|
||||
}
|
||||
|
||||
|
73
src/util.c
73
src/util.c
@ -30,11 +30,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "profile.h"
|
||||
#include "main.h" /* mc_home */
|
||||
@ -263,7 +264,7 @@ path_trunc (const char *path, int trunc_len) {
|
||||
char *secure_path = strip_password (g_strdup (path), 1);
|
||||
|
||||
ret = name_trunc (secure_path, trunc_len);
|
||||
g_free (secure_path);
|
||||
mhl_mem_free (secure_path);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -594,12 +595,12 @@ regexp_match (const char *pattern, const char *string, int match_type)
|
||||
if (!old_pattern || STRCOMP (old_pattern, pattern) || old_type != match_type){
|
||||
if (old_pattern){
|
||||
regfree (&r);
|
||||
g_free (old_pattern);
|
||||
mhl_mem_free (old_pattern);
|
||||
old_pattern = NULL;
|
||||
}
|
||||
my_pattern = convert_pattern (pattern, match_type, 0);
|
||||
if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS)) {
|
||||
g_free (my_pattern);
|
||||
mhl_mem_free (my_pattern);
|
||||
return -1;
|
||||
}
|
||||
old_pattern = my_pattern;
|
||||
@ -674,7 +675,7 @@ load_file (const char *filename)
|
||||
if (read_size > 0)
|
||||
return data;
|
||||
else {
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -693,7 +694,7 @@ load_mc_home_file (const char *filename, char **allocated_filename)
|
||||
data = load_file (hintfile);
|
||||
|
||||
if (!data) {
|
||||
g_free (hintfile);
|
||||
mhl_mem_free (hintfile);
|
||||
/* Fall back to the two-letter language code */
|
||||
if (lang[0] && lang[1])
|
||||
lang[2] = 0;
|
||||
@ -701,21 +702,21 @@ load_mc_home_file (const char *filename, char **allocated_filename)
|
||||
data = load_file (hintfile);
|
||||
|
||||
if (!data) {
|
||||
g_free (hintfile);
|
||||
mhl_mem_free (hintfile);
|
||||
hintfile = hintfile_base;
|
||||
data = load_file (hintfile_base);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (lang);
|
||||
mhl_mem_free (lang);
|
||||
|
||||
if (hintfile != hintfile_base)
|
||||
g_free (hintfile_base);
|
||||
mhl_mem_free (hintfile_base);
|
||||
|
||||
if (allocated_filename)
|
||||
*allocated_filename = hintfile;
|
||||
else
|
||||
g_free (hintfile);
|
||||
mhl_mem_free (hintfile);
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -845,7 +846,7 @@ unix_error_string (int error_num)
|
||||
strerror_currentlocale = g_locale_from_utf8(g_strerror (error_num), -1, NULL, NULL, NULL);
|
||||
g_snprintf (buffer, sizeof (buffer), "%s (%d)",
|
||||
strerror_currentlocale, error_num);
|
||||
g_free(strerror_currentlocale);
|
||||
mhl_mem_free(strerror_currentlocale);
|
||||
#else
|
||||
g_snprintf (buffer, sizeof (buffer), "%s (%d)",
|
||||
g_strerror (error_num), error_num);
|
||||
@ -930,12 +931,12 @@ get_current_wd (char *buffer, int size)
|
||||
len = strlen(p) + 1;
|
||||
|
||||
if (len > size) {
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy (buffer, p, len);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@ -1041,7 +1042,7 @@ execute_hooks (Hook *hook_list)
|
||||
for (hook_list = p; hook_list;){
|
||||
p = hook_list;
|
||||
hook_list = hook_list->next;
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1055,7 +1056,7 @@ delete_hook (Hook **hook_list, void (*hook_fn)(void *))
|
||||
for (current = *hook_list; current; current = next){
|
||||
next = current->next;
|
||||
if (current->hook_fn == hook_fn)
|
||||
g_free (current);
|
||||
mhl_mem_free (current);
|
||||
else
|
||||
add_hook (&new_list, current->hook_fn, current->hook_data);
|
||||
}
|
||||
@ -1082,7 +1083,7 @@ wipe_password (char *passwd)
|
||||
return;
|
||||
for (;*p ; p++)
|
||||
*p = 0;
|
||||
g_free (passwd);
|
||||
mhl_mem_free (passwd);
|
||||
}
|
||||
|
||||
/* Convert "\E" -> esc character and ^x to control-x key and ^^ to ^ key */
|
||||
@ -1147,8 +1148,8 @@ resolve_symlinks (const char *path)
|
||||
c = *q;
|
||||
*q = 0;
|
||||
if (mc_lstat (path, &mybuf) < 0) {
|
||||
g_free (buf);
|
||||
g_free (buf2);
|
||||
mhl_mem_free (buf);
|
||||
mhl_mem_free (buf2);
|
||||
*q = c;
|
||||
return NULL;
|
||||
}
|
||||
@ -1157,8 +1158,8 @@ resolve_symlinks (const char *path)
|
||||
else {
|
||||
len = mc_readlink (path, buf2, MC_MAXPATHLEN - 1);
|
||||
if (len < 0) {
|
||||
g_free (buf);
|
||||
g_free (buf2);
|
||||
mhl_mem_free (buf);
|
||||
mhl_mem_free (buf2);
|
||||
*q = c;
|
||||
return NULL;
|
||||
}
|
||||
@ -1183,7 +1184,7 @@ resolve_symlinks (const char *path)
|
||||
strcpy (buf, PATH_SEP_STR);
|
||||
else if (*(r - 1) == PATH_SEP && r != buf + 1)
|
||||
*(r - 1) = 0;
|
||||
g_free (buf2);
|
||||
mhl_mem_free (buf2);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -1201,7 +1202,7 @@ diff_two_paths (const char *first, const char *second)
|
||||
return NULL;
|
||||
my_second = resolve_symlinks (second);
|
||||
if (my_second == NULL) {
|
||||
g_free (my_first);
|
||||
mhl_mem_free (my_first);
|
||||
return NULL;
|
||||
}
|
||||
for (j = 0; j < 2; j++) {
|
||||
@ -1227,10 +1228,10 @@ diff_two_paths (const char *first, const char *second)
|
||||
currlen = (i + 1) * 3 + strlen (q) + 1;
|
||||
if (j) {
|
||||
if (currlen < prevlen)
|
||||
g_free (buf);
|
||||
mhl_mem_free (buf);
|
||||
else {
|
||||
g_free (my_first);
|
||||
g_free (my_second);
|
||||
mhl_mem_free (my_first);
|
||||
mhl_mem_free (my_second);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
@ -1240,8 +1241,8 @@ diff_two_paths (const char *first, const char *second)
|
||||
strcpy (p, "../");
|
||||
strcpy (p, q);
|
||||
}
|
||||
g_free (my_first);
|
||||
g_free (my_second);
|
||||
mhl_mem_free (my_first);
|
||||
mhl_mem_free (my_second);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -1275,7 +1276,7 @@ list_append_unique (GList *list, char *text)
|
||||
while (link) {
|
||||
newlink = g_list_previous (link);
|
||||
if (!strcmp ((char *) link->data, text)) {
|
||||
g_free (link->data);
|
||||
mhl_mem_free (link->data);
|
||||
g_list_remove_link (list, link);
|
||||
g_list_free_1 (link);
|
||||
}
|
||||
@ -1294,7 +1295,7 @@ list_append_unique (GList *list, char *text)
|
||||
|
||||
/*
|
||||
* Arguments:
|
||||
* pname (output) - pointer to the name of the temp file (needs g_free).
|
||||
* pname (output) - pointer to the name of the temp file (needs mhl_mem_free).
|
||||
* NULL if the function fails.
|
||||
* prefix - part of the filename before the random part.
|
||||
* Prepend $TMPDIR or /tmp if there are no path separators.
|
||||
@ -1325,7 +1326,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
|
||||
tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, (char *) NULL);
|
||||
*pname = tmpname;
|
||||
XXXXXX = &tmpname[strlen (tmpbase)];
|
||||
g_free (tmpbase);
|
||||
mhl_mem_free (tmpbase);
|
||||
|
||||
/* Get some more or less random data. */
|
||||
gettimeofday (&tv, NULL);
|
||||
@ -1362,7 +1363,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix)
|
||||
}
|
||||
|
||||
/* Unsuccessful. Free the filename. */
|
||||
g_free (tmpname);
|
||||
mhl_mem_free (tmpname);
|
||||
*pname = NULL;
|
||||
|
||||
return -1;
|
||||
@ -1387,7 +1388,7 @@ load_file_position (const char *filename, long *line, long *column)
|
||||
/* open file with positions */
|
||||
fn = concat_dir_and_file (home_dir, MC_FILEPOS);
|
||||
f = fopen (fn, "r");
|
||||
g_free (fn);
|
||||
mhl_mem_free (fn);
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
@ -1438,8 +1439,8 @@ save_file_position (const char *filename, long line, long column)
|
||||
/* open temporary file */
|
||||
t = fopen (tmp, "w");
|
||||
if (!t) {
|
||||
g_free (tmp);
|
||||
g_free (fn);
|
||||
mhl_mem_free (tmp);
|
||||
mhl_mem_free (fn);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1466,8 +1467,8 @@ save_file_position (const char *filename, long line, long column)
|
||||
|
||||
fclose (t);
|
||||
rename (tmp, fn);
|
||||
g_free (tmp);
|
||||
g_free (fn);
|
||||
mhl_mem_free (tmp);
|
||||
mhl_mem_free (fn);
|
||||
}
|
||||
|
||||
extern const char *
|
||||
|
@ -41,6 +41,8 @@
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "execute.h"
|
||||
#include "wtools.h" /* message() */
|
||||
@ -71,7 +73,7 @@ static char *i_cache_match (int id, int_cache *cache, int size)
|
||||
static void i_cache_add (int id, int_cache *cache, int size, char *text,
|
||||
int *last)
|
||||
{
|
||||
g_free (cache [*last].string);
|
||||
mhl_mem_free (cache [*last].string);
|
||||
cache [*last].string = g_strdup (text);
|
||||
cache [*last].index = id;
|
||||
*last = ((*last)+1) % size;
|
||||
@ -202,7 +204,7 @@ tilde_expand (const char *directory)
|
||||
name = g_strndup (p, q - p);
|
||||
passwd = getpwnam (name);
|
||||
q++;
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +294,7 @@ mc_tmpdir (void)
|
||||
/* Test if sys_tmp is suitable for temporary files */
|
||||
fallback_prefix = g_strdup_printf ("%s/mctest", sys_tmp);
|
||||
test_fd = mc_mkstemps (&test_fn, fallback_prefix, NULL);
|
||||
g_free (fallback_prefix);
|
||||
mhl_mem_free (fallback_prefix);
|
||||
if (test_fd != -1) {
|
||||
close (test_fd);
|
||||
test_fd = open (test_fn, O_RDONLY);
|
||||
|
67
src/view.c
67
src/view.c
@ -39,11 +39,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "cmd.h" /* For view_other_cmd */
|
||||
@ -346,7 +347,7 @@ view_hexedit_free_change_list (WView *view)
|
||||
|
||||
for (curr = view->change_list; curr != NULL; curr = next) {
|
||||
next = curr->next;
|
||||
g_free (curr);
|
||||
mhl_mem_free (curr);
|
||||
}
|
||||
view->change_list = NULL;
|
||||
view->dirty++;
|
||||
@ -372,8 +373,8 @@ view_growbuf_free (WView *view)
|
||||
assert (view->growbuf_in_use);
|
||||
|
||||
for (i = 0; i < view->growbuf_blocks; i++)
|
||||
g_free (view->growbuf_blockptr[i]);
|
||||
g_free (view->growbuf_blockptr);
|
||||
mhl_mem_free (view->growbuf_blockptr[i]);
|
||||
mhl_mem_free (view->growbuf_blockptr);
|
||||
view->growbuf_blockptr = NULL;
|
||||
view->growbuf_in_use = FALSE;
|
||||
}
|
||||
@ -413,12 +414,12 @@ view_growbuf_read_until (WView *view, offset_type ofs)
|
||||
byte *newblock = g_try_malloc (VIEW_PAGE_SIZE);
|
||||
byte **newblocks = g_try_malloc (sizeof (*newblocks) * (view->growbuf_blocks + 1));
|
||||
if (!newblock || !newblocks) {
|
||||
g_free (newblock);
|
||||
g_free (newblocks);
|
||||
mhl_mem_free (newblock);
|
||||
mhl_mem_free (newblocks);
|
||||
return;
|
||||
}
|
||||
memcpy (newblocks, view->growbuf_blockptr, sizeof (*newblocks) * view->growbuf_blocks);
|
||||
g_free (view->growbuf_blockptr);
|
||||
mhl_mem_free (view->growbuf_blockptr);
|
||||
view->growbuf_blockptr = newblocks;
|
||||
view->growbuf_blockptr[view->growbuf_blocks++] = newblock;
|
||||
view->growbuf_lastindex = 0;
|
||||
@ -705,11 +706,11 @@ view_close_datasource (WView *view)
|
||||
case DS_FILE:
|
||||
(void) mc_close (view->ds_file_fd);
|
||||
view->ds_file_fd = -1;
|
||||
g_free (view->ds_file_data);
|
||||
mhl_mem_free (view->ds_file_data);
|
||||
view->ds_file_data = NULL;
|
||||
break;
|
||||
case DS_STRING:
|
||||
g_free (view->ds_string_data);
|
||||
mhl_mem_free (view->ds_string_data);
|
||||
view->ds_string_data = NULL;
|
||||
break;
|
||||
default:
|
||||
@ -1397,8 +1398,8 @@ view_toggle_magic_mode (WView *view)
|
||||
|
||||
view_done (view);
|
||||
view_load (view, command, filename, 0);
|
||||
g_free (filename);
|
||||
g_free (command);
|
||||
mhl_mem_free (filename);
|
||||
mhl_mem_free (command);
|
||||
view->dpy_bbar_dirty = TRUE;
|
||||
view->dirty++;
|
||||
}
|
||||
@ -1416,7 +1417,7 @@ view_done (WView *view)
|
||||
canon_fname = vfs_canon (view->filename);
|
||||
view_offset_to_coord (view, &line, &col, view->dpy_start);
|
||||
save_file_position (canon_fname, line + 1, col);
|
||||
g_free (canon_fname);
|
||||
mhl_mem_free (canon_fname);
|
||||
}
|
||||
|
||||
/* Write back the global viewer mode */
|
||||
@ -1429,8 +1430,8 @@ view_done (WView *view)
|
||||
|
||||
/* view->widget needs no destructor */
|
||||
|
||||
g_free (view->filename), view->filename = NULL;
|
||||
g_free (view->command), view->command = NULL;
|
||||
mhl_mem_free (view->filename), view->filename = NULL;
|
||||
mhl_mem_free (view->command), view->command = NULL;
|
||||
|
||||
view_close_datasource (view);
|
||||
/* the growing buffer is freed with the datasource */
|
||||
@ -1544,7 +1545,7 @@ view_load (WView *view, const char *command, const char *file,
|
||||
type = get_compression_type (fd);
|
||||
|
||||
if (view->magic_mode && (type != COMPRESSION_NONE)) {
|
||||
g_free (view->filename);
|
||||
mhl_mem_free (view->filename);
|
||||
view->filename = g_strconcat (file, decompress_extension (type), (char *) NULL);
|
||||
}
|
||||
view_set_datasource_file (view, fd, &st);
|
||||
@ -1567,7 +1568,7 @@ view_load (WView *view, const char *command, const char *file,
|
||||
|
||||
canon_fname = vfs_canon (file);
|
||||
load_file_position (file, &line, &col);
|
||||
g_free (canon_fname);
|
||||
mhl_mem_free (canon_fname);
|
||||
view_moveto (view, offset_doz(line, 1), col);
|
||||
} else if (start_line > 0) {
|
||||
view_moveto (view, start_line - 1, 0);
|
||||
@ -2163,7 +2164,7 @@ view_hexedit_save_changes (WView *view)
|
||||
view->change_list = next;
|
||||
view->dirty++;
|
||||
view_set_byte (view, curr->offset, curr->value);
|
||||
g_free (curr);
|
||||
mhl_mem_free (curr);
|
||||
}
|
||||
|
||||
if (mc_close (fp) == -1) {
|
||||
@ -2171,7 +2172,7 @@ view_hexedit_save_changes (WView *view)
|
||||
message (D_ERROR, _(" Save file "),
|
||||
_(" Error while closing the file: \n %s \n"
|
||||
" Data may have been written or not. "), error);
|
||||
g_free (error);
|
||||
mhl_mem_free (error);
|
||||
}
|
||||
view_update (view);
|
||||
return TRUE;
|
||||
@ -2179,12 +2180,12 @@ view_hexedit_save_changes (WView *view)
|
||||
save_error:
|
||||
error = g_strdup (strerror (errno));
|
||||
text = g_strdup_printf (_(" Cannot save file: \n %s "), error);
|
||||
g_free (error);
|
||||
mhl_mem_free (error);
|
||||
(void) mc_close (fp);
|
||||
|
||||
answer = query_dialog (_(" Save file "), text, D_ERROR,
|
||||
2, _("&Retry"), _("&Cancel"));
|
||||
g_free (text);
|
||||
mhl_mem_free (text);
|
||||
|
||||
if (answer == 0)
|
||||
goto retry_save;
|
||||
@ -2389,7 +2390,7 @@ search (WView *view, char *text,
|
||||
view->update_activate = 0;
|
||||
|
||||
enable_interrupt_key ();
|
||||
for (;; g_free (s)) {
|
||||
for (;; mhl_mem_free (s)) {
|
||||
if (p >= view->update_activate) {
|
||||
view->update_activate += view->update_steps;
|
||||
if (verbose) {
|
||||
@ -2408,7 +2409,7 @@ search (WView *view, char *text,
|
||||
|
||||
search_status = (*search) (view, text, s + 1, match_normal);
|
||||
if (search_status < 0) {
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2436,7 +2437,7 @@ search (WView *view, char *text,
|
||||
view->dpy_start = t;
|
||||
}
|
||||
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
break;
|
||||
}
|
||||
disable_interrupt_key ();
|
||||
@ -2597,7 +2598,7 @@ hex_search (WView *view, const char *text)
|
||||
/* No valid bytes in the user input */
|
||||
if (block_len <= 0 || parse_error) {
|
||||
message (D_NORMAL, _("Search"), _("Invalid hex search expression"));
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
view->search_length = 0;
|
||||
return;
|
||||
}
|
||||
@ -2605,7 +2606,7 @@ hex_search (WView *view, const char *text)
|
||||
/* Then start the search */
|
||||
pos = block_search (view, buffer, block_len);
|
||||
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
|
||||
if (pos == INVALID_OFFSET) {
|
||||
message (D_NORMAL, _("Search"), _(" Search string not found "));
|
||||
@ -2637,7 +2638,7 @@ regexp_view_search (WView *view, char *pattern, char *string,
|
||||
|| old_type != match_type) {
|
||||
if (old_pattern != NULL) {
|
||||
regfree (&r);
|
||||
g_free (old_pattern);
|
||||
mhl_mem_free (old_pattern);
|
||||
old_pattern = 0;
|
||||
}
|
||||
for (i = 0; pattern[i] != '\0'; i++) {
|
||||
@ -2741,7 +2742,7 @@ view_moveto_line_cmd (WView *view)
|
||||
if (*answer_end == '\0' && errno == 0 && line >= 1)
|
||||
view_moveto (view, line - 1, 0);
|
||||
}
|
||||
g_free (answer);
|
||||
mhl_mem_free (answer);
|
||||
view->dirty++;
|
||||
view_update (view);
|
||||
}
|
||||
@ -2765,7 +2766,7 @@ view_moveto_addr_cmd (WView *view)
|
||||
message (D_ERROR, _("Warning"), _(" Invalid address "));
|
||||
}
|
||||
}
|
||||
g_free (line);
|
||||
mhl_mem_free (line);
|
||||
}
|
||||
view->dirty++;
|
||||
view_update (view);
|
||||
@ -2790,11 +2791,11 @@ regexp_search (WView *view, int direction)
|
||||
|
||||
regexp = input_dialog (_("Search"), _(" Enter regexp:"), MC_HISTORY_VIEW_SEARCH_REGEX, defval);
|
||||
if (regexp == NULL || regexp[0] == '\0') {
|
||||
g_free (regexp);
|
||||
mhl_mem_free (regexp);
|
||||
return;
|
||||
}
|
||||
|
||||
g_free (last_regexp);
|
||||
mhl_mem_free (last_regexp);
|
||||
view->search_exp = last_regexp = regexp;
|
||||
|
||||
view->direction = direction;
|
||||
@ -2863,7 +2864,7 @@ view_normal_search_cmd (WView *view)
|
||||
|
||||
convert_from_input (exp);
|
||||
|
||||
g_free (last_search_string);
|
||||
mhl_mem_free (last_search_string);
|
||||
view->search_exp = last_search_string = exp;
|
||||
exp = NULL;
|
||||
|
||||
@ -2872,8 +2873,8 @@ view_normal_search_cmd (WView *view)
|
||||
view->last_search = do_normal_search;
|
||||
|
||||
cleanup:
|
||||
g_free (exp);
|
||||
g_free (defval);
|
||||
mhl_mem_free (exp);
|
||||
mhl_mem_free (defval);
|
||||
}
|
||||
|
||||
static void
|
||||
|
53
src/widget.c
53
src/widget.c
@ -32,9 +32,10 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "color.h"
|
||||
@ -188,7 +189,7 @@ button_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_DESTROY:
|
||||
g_free (b->text);
|
||||
mhl_mem_free (b->text);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -281,7 +282,7 @@ button_get_text (WButton *b)
|
||||
void
|
||||
button_set_text (WButton *b, const char *text)
|
||||
{
|
||||
g_free (b->text);
|
||||
mhl_mem_free (b->text);
|
||||
b->text = g_strdup (text);
|
||||
b->widget.cols = button_len (text, b->flags);
|
||||
button_scan_hotkey(b);
|
||||
@ -474,7 +475,7 @@ check_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_DESTROY:
|
||||
g_free (c->text);
|
||||
mhl_mem_free (c->text);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -586,7 +587,7 @@ label_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
}
|
||||
|
||||
case WIDGET_DESTROY:
|
||||
g_free (l->text);
|
||||
mhl_mem_free (l->text);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -602,7 +603,7 @@ label_set_text (WLabel *label, const char *text)
|
||||
if (label->text && text && !strcmp (label->text, text))
|
||||
return; /* Flickering is not nice */
|
||||
|
||||
g_free (label->text);
|
||||
mhl_mem_free (label->text);
|
||||
|
||||
if (text){
|
||||
label->text = g_strdup (text);
|
||||
@ -878,7 +879,7 @@ history_get (const char *input_name)
|
||||
|
||||
hist = list_append_unique (hist, g_strdup (this_entry));
|
||||
}
|
||||
g_free (profile);
|
||||
mhl_mem_free (profile);
|
||||
|
||||
/* return pointer to the last entry in the list */
|
||||
hist = g_list_last (hist);
|
||||
@ -911,7 +912,7 @@ history_put (const char *input_name, GList *h)
|
||||
|
||||
/* Make sure the history is only readable by the user */
|
||||
if (chmod (profile, S_IRUSR | S_IWUSR) == -1 && errno != ENOENT) {
|
||||
g_free (profile);
|
||||
mhl_mem_free (profile);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -940,7 +941,7 @@ history_put (const char *input_name, GList *h)
|
||||
}
|
||||
}
|
||||
|
||||
g_free (profile);
|
||||
mhl_mem_free (profile);
|
||||
}
|
||||
|
||||
/* }}} history saving and loading */
|
||||
@ -1051,7 +1052,7 @@ static void do_show_hist (WInput * in)
|
||||
r = show_hist (in->history, in->widget.x, in->widget.y);
|
||||
if (r) {
|
||||
assign_text (in, r);
|
||||
g_free (r);
|
||||
mhl_mem_free (r);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1072,13 +1073,13 @@ input_destroy (WInput *in)
|
||||
history_put (in->history_name, in->history);
|
||||
|
||||
in->history = g_list_first (in->history);
|
||||
g_list_foreach (in->history, (GFunc) g_free, NULL);
|
||||
g_list_foreach (in->history, (GFunc) mhl_mem_free, NULL);
|
||||
g_list_free (in->history);
|
||||
}
|
||||
|
||||
g_free (in->buffer);
|
||||
mhl_mem_free (in->buffer);
|
||||
free_completions (in);
|
||||
g_free (in->history_name);
|
||||
mhl_mem_free (in->history_name);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1299,7 +1300,7 @@ copy_region (WInput *in, int x_first, int x_last)
|
||||
if (last == first)
|
||||
return;
|
||||
|
||||
g_free (kill_buffer);
|
||||
mhl_mem_free (kill_buffer);
|
||||
|
||||
kill_buffer = g_strndup(in->buffer+first,last-first);
|
||||
}
|
||||
@ -1380,7 +1381,7 @@ yank (WInput *in)
|
||||
static void
|
||||
kill_line (WInput *in)
|
||||
{
|
||||
g_free (kill_buffer);
|
||||
mhl_mem_free (kill_buffer);
|
||||
kill_buffer = g_strdup (&in->buffer [in->point]);
|
||||
in->buffer [in->point] = 0;
|
||||
}
|
||||
@ -1389,7 +1390,7 @@ void
|
||||
assign_text (WInput *in, const char *text)
|
||||
{
|
||||
free_completions (in);
|
||||
g_free (in->buffer);
|
||||
mhl_mem_free (in->buffer);
|
||||
in->buffer = g_strdup (text); /* was in->buffer->text */
|
||||
in->current_max_len = strlen (in->buffer) + 1;
|
||||
in->point = strlen (in->buffer);
|
||||
@ -1857,8 +1858,8 @@ listbox_remove_list (WListbox *l)
|
||||
|
||||
while (l->count--) {
|
||||
q = p->next;
|
||||
g_free (p->text);
|
||||
g_free (p);
|
||||
mhl_mem_free (p->text);
|
||||
mhl_mem_free (p);
|
||||
p = q;
|
||||
}
|
||||
l->pos = l->count = 0;
|
||||
@ -1899,8 +1900,8 @@ listbox_remove_current (WListbox *l, int force)
|
||||
l->list = l->top = l->current = 0;
|
||||
}
|
||||
|
||||
g_free (p->text);
|
||||
g_free (p);
|
||||
mhl_mem_free (p->text);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
/* Makes *e the selected entry (sets current and pos) */
|
||||
@ -2022,8 +2023,8 @@ listbox_destroy (WListbox *l)
|
||||
|
||||
for (i = 0; i < l->count; i++){
|
||||
n = p->next;
|
||||
g_free (p->text);
|
||||
g_free (p);
|
||||
mhl_mem_free (p->text);
|
||||
mhl_mem_free (p);
|
||||
p = n;
|
||||
}
|
||||
}
|
||||
@ -2338,7 +2339,7 @@ buttonbar_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
|
||||
case WIDGET_DESTROY:
|
||||
for (i = 0; i < 10; i++)
|
||||
g_free (bb->labels[i].text);
|
||||
mhl_mem_free (bb->labels[i].text);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -2385,7 +2386,7 @@ buttonbar_new (int visible)
|
||||
static void
|
||||
set_label_text (WButtonBar * bb, int index, const char *text)
|
||||
{
|
||||
g_free (bb->labels[index - 1].text);
|
||||
mhl_mem_free (bb->labels[index - 1].text);
|
||||
|
||||
bb->labels[index - 1].text = g_strdup (text);
|
||||
}
|
||||
@ -2484,7 +2485,7 @@ groupbox_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_DESTROY:
|
||||
g_free (g->title);
|
||||
mhl_mem_free (g->title);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
@ -2507,7 +2508,7 @@ groupbox_new (int x, int y, int width, int height, const char *title)
|
||||
char *t;
|
||||
t = g_strstrip (g_strdup (title));
|
||||
g->title = g_strconcat (" ", t, " ", (char *) NULL);
|
||||
g_free (t);
|
||||
mhl_mem_free (t);
|
||||
}
|
||||
|
||||
return g;
|
||||
|
18
src/wtools.c
18
src/wtools.c
@ -29,6 +29,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "tty.h"
|
||||
#include "color.h" /* dialog_colors */
|
||||
@ -87,7 +89,7 @@ int run_listbox (Listbox *l)
|
||||
else
|
||||
val = l->list->pos;
|
||||
destroy_dlg (l->dlg);
|
||||
g_free (l);
|
||||
mhl_mem_free (l);
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -207,7 +209,7 @@ do_create_message (int flags, const char *title, const char *text)
|
||||
query_dialog (title, p, flags, 0);
|
||||
d = last_query_dlg;
|
||||
init_dlg (d);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
return d;
|
||||
}
|
||||
@ -229,7 +231,7 @@ create_message (int flags, const char *title, const char *text, ...)
|
||||
va_end (args);
|
||||
|
||||
d = do_create_message (flags, title, p);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
return d;
|
||||
}
|
||||
@ -259,7 +261,7 @@ bg_message (int dummy, int *flags, char *title, const char *text)
|
||||
(void) dummy;
|
||||
title = g_strconcat (_("Background process:"), " ", title, (char *) NULL);
|
||||
fg_message (*flags, title, text);
|
||||
g_free (title);
|
||||
mhl_mem_free (title);
|
||||
}
|
||||
#endif /* WITH_BACKGROUND */
|
||||
|
||||
@ -286,7 +288,7 @@ message (int flags, const char *title, const char *text, ...)
|
||||
#endif /* WITH_BACKGROUND */
|
||||
fg_message (flags, title, p);
|
||||
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
|
||||
@ -413,7 +415,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
|
||||
}
|
||||
return_val = dd->ret_value;
|
||||
destroy_dlg (dd);
|
||||
g_free (widgets);
|
||||
mhl_mem_free (widgets);
|
||||
|
||||
return return_val;
|
||||
}
|
||||
@ -514,7 +516,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
|
||||
|
||||
Quick_input.widgets = quick_widgets;
|
||||
ret = quick_dialog (&Quick_input);
|
||||
g_free (p_text);
|
||||
mhl_mem_free (p_text);
|
||||
|
||||
if (ret != B_CANCEL) {
|
||||
return my_str;
|
||||
@ -561,7 +563,7 @@ input_expand_dialog (const char *header, const char *text,
|
||||
result = input_dialog (header, text, history_name, def_text);
|
||||
if (result) {
|
||||
expanded = tilde_expand (result);
|
||||
g_free (result);
|
||||
mhl_mem_free (result);
|
||||
return expanded;
|
||||
}
|
||||
return result;
|
||||
|
@ -35,9 +35,10 @@ typedef int dummy; /* C99 forbids empty compilation unit */
|
||||
#else
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#ifdef HAVE_GMODULE
|
||||
@ -132,7 +133,7 @@ static gboolean x11_available(void)
|
||||
if (x11_module == NULL)
|
||||
x11_module = g_module_open ("libX11.so.6", G_MODULE_BIND_LAZY);
|
||||
|
||||
g_free (x11_module_fname);
|
||||
mhl_mem_free (x11_module_fname);
|
||||
|
||||
if (x11_module == NULL)
|
||||
return FALSE;
|
||||
|
25
vfs/cpio.c
25
vfs/cpio.c
@ -19,8 +19,11 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -143,7 +146,7 @@ static void cpio_free_archive(struct vfs_class *me, struct vfs_s_super *super)
|
||||
super->u.arch.fd = -1;
|
||||
for (l = super->u.arch.deferred; l; l = lnext) {
|
||||
lnext = l->next;
|
||||
g_free (l);
|
||||
mhl_mem_free (l);
|
||||
}
|
||||
super->u.arch.deferred = NULL;
|
||||
}
|
||||
@ -174,10 +177,10 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super,
|
||||
s = g_strconcat (name, decompress_extension (type), (char *) NULL);
|
||||
if ((fd = mc_open (s, O_RDONLY)) == -1) {
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
return -1;
|
||||
}
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
}
|
||||
|
||||
super->u.arch.fd = fd;
|
||||
@ -290,7 +293,7 @@ static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe
|
||||
}
|
||||
name = g_malloc(u.buf.c_namesize);
|
||||
if((len = mc_read(super->u.arch.fd, name, u.buf.c_namesize)) < u.buf.c_namesize) {
|
||||
g_free(name);
|
||||
mhl_mem_free(name);
|
||||
return STATUS_EOF;
|
||||
}
|
||||
name[u.buf.c_namesize - 1] = '\0';
|
||||
@ -298,7 +301,7 @@ static ssize_t cpio_read_bin_head(struct vfs_class *me, struct vfs_s_super *supe
|
||||
cpio_skip_padding(super);
|
||||
|
||||
if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
|
||||
g_free(name);
|
||||
mhl_mem_free(name);
|
||||
return STATUS_TRAIL;
|
||||
}
|
||||
|
||||
@ -349,7 +352,7 @@ static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup
|
||||
name = g_malloc(hd.c_namesize);
|
||||
if((len = mc_read(super->u.arch.fd, name, hd.c_namesize)) == -1 ||
|
||||
(unsigned long) len < hd.c_namesize) {
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
return STATUS_EOF;
|
||||
}
|
||||
name[hd.c_namesize - 1] = '\0';
|
||||
@ -357,7 +360,7 @@ static ssize_t cpio_read_oldc_head(struct vfs_class *me, struct vfs_s_super *sup
|
||||
cpio_skip_padding(super);
|
||||
|
||||
if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
|
||||
g_free(name);
|
||||
mhl_mem_free(name);
|
||||
return STATUS_TRAIL;
|
||||
}
|
||||
|
||||
@ -414,7 +417,7 @@ static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *supe
|
||||
name = g_malloc(hd.c_namesize);
|
||||
if((len = mc_read (super->u.arch.fd, name, hd.c_namesize)) == -1 ||
|
||||
(unsigned long) len < hd.c_namesize) {
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
return STATUS_EOF;
|
||||
}
|
||||
name[hd.c_namesize - 1] = '\0';
|
||||
@ -422,7 +425,7 @@ static ssize_t cpio_read_crc_head(struct vfs_class *me, struct vfs_s_super *supe
|
||||
cpio_skip_padding(super);
|
||||
|
||||
if(!strcmp("TRAILER!!!", name)) { /* We got to the last record */
|
||||
g_free(name);
|
||||
mhl_mem_free(name);
|
||||
return STATUS_TRAIL;
|
||||
}
|
||||
|
||||
@ -545,7 +548,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super,
|
||||
if (mc_read (super->u.arch.fd, inode->linkname, st->st_size)
|
||||
< st->st_size) {
|
||||
inode->linkname[0] = 0;
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
return STATUS_EOF;
|
||||
}
|
||||
inode->linkname[st->st_size] = 0; /* Linkname stored without terminating \0 !!! */
|
||||
@ -557,7 +560,7 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super,
|
||||
|
||||
} /* !entry */
|
||||
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,11 @@
|
||||
* archive/site is simply "". Beware. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -95,14 +98,14 @@ vfs_s_free_inode (struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
}
|
||||
|
||||
CALL (free_inode) (me, ino);
|
||||
g_free (ino->linkname);
|
||||
mhl_mem_free (ino->linkname);
|
||||
if (ino->localname){
|
||||
unlink (ino->localname);
|
||||
g_free(ino->localname);
|
||||
mhl_mem_free(ino->localname);
|
||||
}
|
||||
total_inodes--;
|
||||
ino->super->ino_usage--;
|
||||
g_free(ino);
|
||||
mhl_mem_free(ino);
|
||||
} else ino->st.st_nlink--;
|
||||
}
|
||||
|
||||
@ -115,7 +118,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent)
|
||||
ent->next->prevp = ent->prevp;
|
||||
}
|
||||
|
||||
g_free (ent->name);
|
||||
mhl_mem_free (ent->name);
|
||||
ent->name = NULL;
|
||||
|
||||
if (ent->ino){
|
||||
@ -125,7 +128,7 @@ vfs_s_free_entry (struct vfs_class *me, struct vfs_s_entry *ent)
|
||||
}
|
||||
|
||||
total_entries--;
|
||||
g_free(ent);
|
||||
mhl_mem_free(ent);
|
||||
}
|
||||
|
||||
void
|
||||
@ -227,14 +230,14 @@ vfs_s_resolve_symlink (struct vfs_class *me, struct vfs_s_entry *entry,
|
||||
if (fullpath) {
|
||||
fullname = g_strconcat (fullpath, "/", linkname, NULL);
|
||||
linkname = fullname;
|
||||
g_free (fullpath);
|
||||
mhl_mem_free (fullpath);
|
||||
}
|
||||
}
|
||||
|
||||
target =
|
||||
(MEDATA->find_entry) (me, entry->dir->super->root, linkname,
|
||||
follow - 1, 0);
|
||||
g_free (fullname);
|
||||
mhl_mem_free (fullname);
|
||||
return target;
|
||||
}
|
||||
|
||||
@ -258,7 +261,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
path++;
|
||||
|
||||
if (!path[0]) {
|
||||
g_free (pathref);
|
||||
mhl_mem_free (pathref);
|
||||
return ent;
|
||||
}
|
||||
|
||||
@ -289,7 +292,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
root = ent->ino;
|
||||
}
|
||||
cleanup:
|
||||
g_free (pathref);
|
||||
mhl_mem_free (pathref);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -336,7 +339,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
if (save)
|
||||
*save = PATH_SEP;
|
||||
retval = vfs_s_find_entry_tree (me, ino, name, follow, flags);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -361,7 +364,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
ent = vfs_s_new_entry (me, path, ino);
|
||||
if ((MEDATA->dir_load) (me, ino, path) == -1) {
|
||||
vfs_s_free_entry (me, ent);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
return NULL;
|
||||
}
|
||||
vfs_s_insert_entry (me, root, ent);
|
||||
@ -375,11 +378,11 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root,
|
||||
|
||||
#if 0
|
||||
if (!vfs_s_resolve_symlink (me, ent, follow)) {
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
return ent;
|
||||
}
|
||||
|
||||
@ -446,8 +449,8 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super)
|
||||
}
|
||||
|
||||
CALL (free_archive) (me, super);
|
||||
g_free (super->name);
|
||||
g_free(super);
|
||||
mhl_mem_free (super->name);
|
||||
mhl_mem_free(super);
|
||||
}
|
||||
|
||||
|
||||
@ -521,7 +524,7 @@ vfs_s_get_path (struct vfs_class *me, const char *inname,
|
||||
|
||||
buf = g_strdup (inname);
|
||||
retval = g_strdup (vfs_s_get_path_mangle (me, buf, archive, flags));
|
||||
g_free (buf);
|
||||
mhl_mem_free (buf);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -549,7 +552,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
if (ino == ino->super->root)
|
||||
break;
|
||||
newpath = g_strconcat (ino->ent->name, "/", path, (char *) NULL);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
path = newpath;
|
||||
}
|
||||
return path;
|
||||
@ -587,7 +590,7 @@ vfs_s_inode_from_path (struct vfs_class *me, const char *name, int flags)
|
||||
flags & FL_FOLLOW ? LINK_FOLLOW :
|
||||
LINK_NO_FOLLOW,
|
||||
FL_DIR | (flags & ~FL_FOLLOW));
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
return ino;
|
||||
}
|
||||
|
||||
@ -648,7 +651,7 @@ vfs_s_closedir (void *data)
|
||||
struct vfs_s_inode *dir = info->dir;
|
||||
|
||||
vfs_s_free_inode (dir->super->me, dir);
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -731,7 +734,7 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
|
||||
return NULL;
|
||||
ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE);
|
||||
if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) {
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
ERRNOR (EEXIST, NULL);
|
||||
}
|
||||
if (!ino) {
|
||||
@ -742,7 +745,7 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
|
||||
|
||||
/* If the filesystem is read-only, disable file creation */
|
||||
if (!(flags & O_CREAT) || !(me->write)) {
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -756,14 +759,14 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
|
||||
vfs_s_insert_entry (me, dir, ent);
|
||||
tmp_handle = vfs_mkstemps (&ino->localname, me->name, name);
|
||||
if (tmp_handle == -1) {
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
return NULL;
|
||||
}
|
||||
close (tmp_handle);
|
||||
was_changed = 1;
|
||||
}
|
||||
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
|
||||
if (S_ISDIR (ino->st.st_mode))
|
||||
ERRNOR (EISDIR, NULL);
|
||||
@ -782,14 +785,14 @@ vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
|
||||
}
|
||||
} else if ((MEDATA->fh_open)
|
||||
&& (MEDATA->fh_open (me, fh, flags, mode))) {
|
||||
g_free (fh);
|
||||
mhl_mem_free (fh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fh->ino->localname) {
|
||||
fh->handle = open (fh->ino->localname, NO_LINEAR (flags), mode);
|
||||
if (fh->handle == -1) {
|
||||
g_free (fh);
|
||||
mhl_mem_free (fh);
|
||||
ERRNOR (errno, NULL);
|
||||
}
|
||||
}
|
||||
@ -898,7 +901,7 @@ vfs_s_close (void *fh)
|
||||
res = -1;
|
||||
else {
|
||||
res = MEDATA->file_store (me, fh, s, FH->ino->localname);
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
}
|
||||
vfs_s_invalidate (me, FH_SUPER);
|
||||
}
|
||||
@ -906,7 +909,7 @@ vfs_s_close (void *fh)
|
||||
close (FH->handle);
|
||||
|
||||
vfs_s_free_inode (me, FH->ino);
|
||||
g_free (fh);
|
||||
mhl_mem_free (fh);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -992,7 +995,7 @@ vfs_s_retrieve_file (struct vfs_class *me, struct vfs_s_inode *ino)
|
||||
close (handle);
|
||||
unlink (ino->localname);
|
||||
error_4:
|
||||
g_free (ino->localname);
|
||||
mhl_mem_free (ino->localname);
|
||||
ino->localname = NULL;
|
||||
return -1;
|
||||
}
|
||||
@ -1008,7 +1011,7 @@ vfs_s_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
while (a){
|
||||
name = g_strconcat ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL);
|
||||
(*func)(name);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
@ -1092,7 +1095,7 @@ vfs_s_getid (struct vfs_class *me, const char *path)
|
||||
|
||||
if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN)))
|
||||
return NULL;
|
||||
g_free(p);
|
||||
mhl_mem_free(p);
|
||||
return (vfsid) archive;
|
||||
}
|
||||
|
||||
|
103
vfs/extfs.c
103
vfs/extfs.c
@ -35,6 +35,9 @@
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -122,7 +125,7 @@ extfs_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
g_strconcat (a->name ? a->name : "", "#",
|
||||
extfs_prefixes[a->fstype], (char *) NULL);
|
||||
(*func) (name);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
a = a->next;
|
||||
}
|
||||
}
|
||||
@ -215,10 +218,10 @@ static void extfs_free_archive (struct archive *archive)
|
||||
mc_stat (archive->local_name, &my);
|
||||
mc_ungetlocalcopy (archive->name, archive->local_name,
|
||||
archive->local_stat.st_mtime != my.st_mtime);
|
||||
g_free(archive->local_name);
|
||||
mhl_mem_free(archive->local_name);
|
||||
}
|
||||
g_free (archive->name);
|
||||
g_free (archive);
|
||||
mhl_mem_free (archive->name);
|
||||
mhl_mem_free (archive);
|
||||
}
|
||||
|
||||
static FILE *
|
||||
@ -250,16 +253,16 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc)
|
||||
cmd =
|
||||
g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ",
|
||||
local_name ? local_name : tmp, (char *) NULL);
|
||||
g_free (tmp);
|
||||
g_free (mc_extfsdir);
|
||||
mhl_mem_free (tmp);
|
||||
mhl_mem_free (mc_extfsdir);
|
||||
open_error_pipe ();
|
||||
result = popen (cmd, "r");
|
||||
g_free (cmd);
|
||||
mhl_mem_free (cmd);
|
||||
if (result == NULL) {
|
||||
close_error_pipe (D_ERROR, NULL);
|
||||
if (local_name) {
|
||||
mc_ungetlocalcopy (name, local_name, 0);
|
||||
g_free(local_name);
|
||||
mhl_mem_free(local_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -352,7 +355,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
|
||||
0);
|
||||
if (pent == NULL) {
|
||||
/* FIXME: Should clean everything one day */
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
pclose (extfsd);
|
||||
close_error_pipe (D_ERROR, _("Inconsistent extfs archive"));
|
||||
return -1;
|
||||
@ -371,7 +374,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
|
||||
current_link_name, 0, 0);
|
||||
if (pent == NULL) {
|
||||
/* FIXME: Should clean everything one day */
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
pclose (extfsd);
|
||||
close_error_pipe (D_ERROR,
|
||||
_("Inconsistent extfs archive"));
|
||||
@ -416,11 +419,11 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc)
|
||||
}
|
||||
}
|
||||
read_extfs_continue:
|
||||
g_free (current_file_name);
|
||||
g_free (current_link_name);
|
||||
mhl_mem_free (current_file_name);
|
||||
mhl_mem_free (current_link_name);
|
||||
}
|
||||
}
|
||||
g_free (buffer);
|
||||
mhl_mem_free (buffer);
|
||||
|
||||
/* Check if extfs 'list' returned 0 */
|
||||
if (pclose (extfsd) != 0) {
|
||||
@ -495,7 +498,7 @@ extfs_get_path (struct vfs_class *me, const char *inname, struct archive **archi
|
||||
char *res2 = NULL;
|
||||
if (res)
|
||||
res2 = g_strdup (res);
|
||||
g_free (buf);
|
||||
mhl_mem_free (buf);
|
||||
return res2;
|
||||
}
|
||||
|
||||
@ -529,7 +532,7 @@ static char *extfs_get_path_from_entry (struct entry *entry)
|
||||
strcat (localpath, "/");
|
||||
p = head;
|
||||
head = head->next;
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
return (localpath);
|
||||
}
|
||||
@ -564,7 +567,7 @@ extfs_resolve_symlinks_int (struct entry *entry,
|
||||
looping->entry = entry;
|
||||
looping->next = list;
|
||||
pent = extfs_find_entry_int (entry->dir, entry->inode->linkname, looping, 0, 0);
|
||||
g_free (looping);
|
||||
mhl_mem_free (looping);
|
||||
if (pent == NULL)
|
||||
my_errno = ENOENT;
|
||||
return pent;
|
||||
@ -617,7 +620,7 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive,
|
||||
|
||||
file = extfs_get_path_from_entry (entry);
|
||||
quoted_file = name_quote (file, 0);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
archive_name = name_quote (extfs_get_archive_name (archive), 0);
|
||||
quoted_localname = name_quote (localname, 0);
|
||||
|
||||
@ -625,14 +628,14 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive,
|
||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
|
||||
extfs_cmd, archive_name, " ", quoted_file, " ",
|
||||
quoted_localname, (char *) NULL);
|
||||
g_free (quoted_file);
|
||||
g_free (quoted_localname);
|
||||
g_free (mc_extfsdir);
|
||||
g_free (archive_name);
|
||||
mhl_mem_free (quoted_file);
|
||||
mhl_mem_free (quoted_localname);
|
||||
mhl_mem_free (mc_extfsdir);
|
||||
mhl_mem_free (archive_name);
|
||||
|
||||
open_error_pipe ();
|
||||
retval = my_system (EXECUTE_AS_SHELL, shell, cmd);
|
||||
g_free (cmd);
|
||||
mhl_mem_free (cmd);
|
||||
close_error_pipe (D_ERROR, NULL);
|
||||
return retval;
|
||||
}
|
||||
@ -647,17 +650,17 @@ extfs_run (struct vfs_class *me, const char *file)
|
||||
if ((p = extfs_get_path (me, file, &archive, 0)) == NULL)
|
||||
return;
|
||||
q = name_quote (p, 0);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
archive_name = name_quote (extfs_get_archive_name (archive), 0);
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR);
|
||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype],
|
||||
" run ", archive_name, " ", q, (char *) NULL);
|
||||
g_free (mc_extfsdir);
|
||||
g_free (archive_name);
|
||||
g_free (q);
|
||||
mhl_mem_free (mc_extfsdir);
|
||||
mhl_mem_free (archive_name);
|
||||
mhl_mem_free (q);
|
||||
shell_execute (cmd, 0);
|
||||
g_free (cmd);
|
||||
mhl_mem_free (cmd);
|
||||
}
|
||||
|
||||
static void *
|
||||
@ -679,7 +682,7 @@ extfs_open (struct vfs_class *me, const char *file, int flags, int mode)
|
||||
created = (entry != NULL);
|
||||
}
|
||||
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
if (entry == NULL)
|
||||
return NULL;
|
||||
if ((entry = extfs_resolve_symlinks (entry)) == NULL)
|
||||
@ -762,7 +765,7 @@ extfs_close (void *data)
|
||||
if (!file->archive->fd_usage)
|
||||
vfs_stamp_create (&vfs_extfs_ops, file->archive);
|
||||
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
if (errno_code)
|
||||
ERRNOR (EIO, -1);
|
||||
return 0;
|
||||
@ -878,7 +881,7 @@ static void * extfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
if ((q = extfs_get_path (me, dirname, &archive, 0)) == NULL)
|
||||
return NULL;
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
if (entry == NULL)
|
||||
return NULL;
|
||||
if ((entry = extfs_resolve_symlinks (entry)) == NULL)
|
||||
@ -910,7 +913,7 @@ static void * extfs_readdir(void *data)
|
||||
|
||||
static int extfs_closedir (void *data)
|
||||
{
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -957,7 +960,7 @@ extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf,
|
||||
extfs_stat_move (buf, entry->inode);
|
||||
result = 0;
|
||||
cleanup:
|
||||
g_free (path2);
|
||||
mhl_mem_free (path2);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1004,7 +1007,7 @@ extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
|
||||
/* readlink() does not append a NUL character to buf */
|
||||
memcpy (buf, entry->inode->linkname, result = len);
|
||||
cleanup:
|
||||
g_free (mpath);
|
||||
mhl_mem_free (mpath);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1049,7 +1052,7 @@ static int extfs_unlink (struct vfs_class *me, const char *file)
|
||||
extfs_remove_entry (entry);
|
||||
result = 0;
|
||||
cleanup:
|
||||
g_free (mpath);
|
||||
mhl_mem_free (mpath);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1086,7 +1089,7 @@ static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode)
|
||||
}
|
||||
result = 0;
|
||||
cleanup:
|
||||
g_free (mpath);
|
||||
mhl_mem_free (mpath);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1116,7 +1119,7 @@ static int extfs_rmdir (struct vfs_class *me, const char *path)
|
||||
extfs_remove_entry (entry);
|
||||
result = 0;
|
||||
cleanup:
|
||||
g_free (mpath);
|
||||
mhl_mem_free (mpath);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1131,7 +1134,7 @@ extfs_chdir (struct vfs_class *me, const char *path)
|
||||
if ((q = extfs_get_path (me, path, &archive, 0)) == NULL)
|
||||
return -1;
|
||||
entry = extfs_find_entry (archive->root_entry, q, 0, 0);
|
||||
g_free (q);
|
||||
mhl_mem_free (q);
|
||||
if (!entry)
|
||||
return -1;
|
||||
entry = extfs_resolve_symlinks (entry);
|
||||
@ -1156,7 +1159,7 @@ extfs_getid (struct vfs_class *me, const char *path)
|
||||
|
||||
if (!(p = extfs_get_path (me, path, &archive, 1)))
|
||||
return NULL;
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
return (vfsid) archive;
|
||||
}
|
||||
|
||||
@ -1198,12 +1201,12 @@ static void extfs_remove_entry (struct entry *e)
|
||||
unlink (e->inode->local_filename);
|
||||
free (e->inode->local_filename);
|
||||
}
|
||||
g_free (e->inode->linkname);
|
||||
g_free (e->inode);
|
||||
mhl_mem_free (e->inode->linkname);
|
||||
mhl_mem_free (e->inode);
|
||||
}
|
||||
|
||||
g_free (e->name);
|
||||
g_free (e);
|
||||
mhl_mem_free (e->name);
|
||||
mhl_mem_free (e);
|
||||
}
|
||||
|
||||
static void extfs_free_entry (struct entry *e)
|
||||
@ -1220,13 +1223,13 @@ static void extfs_free_entry (struct entry *e)
|
||||
unlink (e->inode->local_filename);
|
||||
free (e->inode->local_filename);
|
||||
}
|
||||
g_free (e->inode->linkname);
|
||||
g_free (e->inode);
|
||||
mhl_mem_free (e->inode->linkname);
|
||||
mhl_mem_free (e->inode);
|
||||
}
|
||||
if (e->next_in_dir != NULL)
|
||||
extfs_free_entry (e->next_in_dir);
|
||||
g_free (e->name);
|
||||
g_free (e);
|
||||
mhl_mem_free (e->name);
|
||||
mhl_mem_free (e);
|
||||
}
|
||||
|
||||
static void extfs_free (vfsid id)
|
||||
@ -1303,7 +1306,7 @@ static int extfs_init (struct vfs_class *me)
|
||||
* appear on screen. */
|
||||
if (!cfg) {
|
||||
fprintf (stderr, _("Warning: file %s not found\n"), mc_extfsini);
|
||||
g_free (mc_extfsini);
|
||||
mhl_mem_free (mc_extfsini);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1319,7 +1322,7 @@ static int extfs_init (struct vfs_class *me)
|
||||
fprintf(stderr, "Warning: You need to update your %s file.\n",
|
||||
mc_extfsini);
|
||||
fclose(cfg);
|
||||
g_free (mc_extfsini);
|
||||
mhl_mem_free (mc_extfsini);
|
||||
return 0;
|
||||
}
|
||||
if (*key == '#' || *key == '\n')
|
||||
@ -1339,7 +1342,7 @@ static int extfs_init (struct vfs_class *me)
|
||||
extfs_prefixes [extfs_no++] = g_strdup (key);
|
||||
}
|
||||
fclose(cfg);
|
||||
g_free (mc_extfsini);
|
||||
mhl_mem_free (mc_extfsini);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1368,7 +1371,7 @@ static void extfs_done (struct vfs_class *me)
|
||||
}
|
||||
|
||||
for (i = 0; i < extfs_no; i++ )
|
||||
g_free (extfs_prefixes [i]);
|
||||
mhl_mem_free (extfs_prefixes [i]);
|
||||
extfs_no = 0;
|
||||
}
|
||||
|
||||
|
42
vfs/fish.c
42
vfs/fish.c
@ -144,7 +144,7 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super,
|
||||
enable_interrupt_key ();
|
||||
|
||||
status = write (SUP.sockw, str, strlen (str));
|
||||
g_free (str);
|
||||
mhl_mem_free (str);
|
||||
|
||||
disable_interrupt_key ();
|
||||
if (status < 0)
|
||||
@ -168,10 +168,10 @@ fish_free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
close (SUP.sockr);
|
||||
SUP.sockw = SUP.sockr = -1;
|
||||
}
|
||||
g_free (SUP.host);
|
||||
g_free (SUP.user);
|
||||
g_free (SUP.cwdir);
|
||||
g_free (SUP.password);
|
||||
mhl_mem_free (SUP.host);
|
||||
mhl_mem_free (SUP.user);
|
||||
mhl_mem_free (SUP.cwdir);
|
||||
mhl_mem_free (SUP.password);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -251,7 +251,7 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
p = g_strconcat (_(" fish: Password required for "),
|
||||
SUP.user, " ", (char *) NULL);
|
||||
op = vfs_get_password (p);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
if (op == NULL)
|
||||
ERRNOR (EPERM, -1);
|
||||
SUP.password = op;
|
||||
@ -314,7 +314,7 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super,
|
||||
p = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags,
|
||||
&password, 0, URL_NOSLASH);
|
||||
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
SUP.host = host;
|
||||
SUP.user = user;
|
||||
@ -341,12 +341,12 @@ fish_archive_same (struct vfs_class *me, struct vfs_s_super *super,
|
||||
op = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags, 0, 0,
|
||||
URL_NOSLASH);
|
||||
|
||||
g_free (op);
|
||||
mhl_mem_free (op);
|
||||
|
||||
flags = ((strcmp (host, SUP.host) == 0)
|
||||
&& (strcmp (user, SUP.user) == 0) && (flags == SUP.flags));
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
mhl_mem_free (host);
|
||||
mhl_mem_free (user);
|
||||
|
||||
return flags;
|
||||
}
|
||||
@ -585,7 +585,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
vfs_s_free_entry (me, ent);
|
||||
reply_code = fish_decode_reply(buffer + 4, 0);
|
||||
if (reply_code == COMPLETE) {
|
||||
g_free (SUP.cwdir);
|
||||
mhl_mem_free (SUP.cwdir);
|
||||
SUP.cwdir = g_strdup (remote_path);
|
||||
print_vfs_message (_("%s: done."), me->name);
|
||||
return 0;
|
||||
@ -771,7 +771,7 @@ fish_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
|
||||
"echo '### 500'\n"
|
||||
"fi\n",
|
||||
quoted_name, quoted_name, quoted_name, quoted_name );
|
||||
g_free (quoted_name);
|
||||
mhl_mem_free (quoted_name);
|
||||
if (offset != PRELIM) ERRNOR (E_REMOTE, 0);
|
||||
fh->linear = LS_LINEAR_OPEN;
|
||||
fh->u.fish.got = 0;
|
||||
@ -883,14 +883,14 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super *super, const char *c
|
||||
char *rpath, *mpath = g_strdup (path); \
|
||||
struct vfs_s_super *super; \
|
||||
if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \
|
||||
g_free (mpath); \
|
||||
mhl_mem_free (mpath); \
|
||||
return -1; \
|
||||
} \
|
||||
rpath = mhl_shell_escape_dup(crpath); \
|
||||
g_free (mpath);
|
||||
mhl_mem_free (mpath);
|
||||
|
||||
#define POSTFIX(flags) \
|
||||
g_free (rpath); \
|
||||
mhl_mem_free (rpath); \
|
||||
return fish_send_command(me, super, buf, flags);
|
||||
|
||||
static int
|
||||
@ -913,18 +913,18 @@ static int fish_##name (struct vfs_class *me, const char *path1, const char *pat
|
||||
char *rpath1, *rpath2, *mpath1, *mpath2; \
|
||||
struct vfs_s_super *super1, *super2; \
|
||||
if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0))) { \
|
||||
g_free (mpath1); \
|
||||
mhl_mem_free (mpath1); \
|
||||
return -1; \
|
||||
} \
|
||||
if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0))) { \
|
||||
g_free (mpath1); \
|
||||
g_free (mpath2); \
|
||||
mhl_mem_free (mpath1); \
|
||||
mhl_mem_free (mpath2); \
|
||||
return -1; \
|
||||
} \
|
||||
rpath1 = mhl_shell_escape_dup (crpath1); \
|
||||
g_free (mpath1); \
|
||||
mhl_mem_free (mpath1); \
|
||||
rpath2 = mhl_shell_escape_dup (crpath2); \
|
||||
g_free (mpath2); \
|
||||
mhl_mem_free (mpath2); \
|
||||
g_snprintf(buf, sizeof(buf), string "\n", rpath1, rpath2, rpath1, rpath2); \
|
||||
mhl_mem_free (rpath1); \
|
||||
mhl_mem_free (rpath2); \
|
||||
@ -1078,7 +1078,7 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
name = g_strconcat ("/#sh:", SUP.user, "@", SUP.host, flags,
|
||||
"/", SUP.cwdir, (char *) NULL);
|
||||
(*func)(name);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
super = super->next;
|
||||
}
|
||||
}
|
||||
|
93
vfs/ftpfs.c
93
vfs/ftpfs.c
@ -45,7 +45,7 @@ What to do with this?
|
||||
if (f || !strncmp( remote_path, "/~/", 3 )) {
|
||||
char *s;
|
||||
s = concat_dir_and_file( qhome (*bucket), remote_path +3-f );
|
||||
g_free (remote_path);
|
||||
mhl_mem_free (remote_path);
|
||||
remote_path = s;
|
||||
}
|
||||
}
|
||||
@ -56,6 +56,7 @@ What to do with this?
|
||||
/* Namespace pollution: horrible */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <sys/types.h> /* POSIX-required by sys/socket.h and netdb.h */
|
||||
#include <netdb.h> /* struct hostent */
|
||||
#include <sys/socket.h> /* AF_INET */
|
||||
@ -69,6 +70,8 @@ What to do with this?
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -244,14 +247,14 @@ ftpfs_split_url(char *path, char **host, char **user, int *port, char **pass)
|
||||
|
||||
/* If user is different, remove password */
|
||||
if (new_user && strcmp (*user, new_user)) {
|
||||
g_free (*pass);
|
||||
mhl_mem_free (*pass);
|
||||
*pass = NULL;
|
||||
}
|
||||
|
||||
g_free (new_user);
|
||||
mhl_mem_free (new_user);
|
||||
}
|
||||
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
|
||||
/* Returns a reply code, check /usr/include/arpa/ftp.h for possible values */
|
||||
@ -308,7 +311,7 @@ ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super)
|
||||
if (!cwdir)
|
||||
return 1;
|
||||
sock = ftpfs_chdir_internal (me, super, cwdir);
|
||||
g_free (cwdir);
|
||||
mhl_mem_free (cwdir);
|
||||
return sock == COMPLETE;
|
||||
}
|
||||
SUP.cwdir = cwdir;
|
||||
@ -362,7 +365,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
|
||||
}
|
||||
got_sigpipe = 1;
|
||||
}
|
||||
g_free (cmdstr);
|
||||
mhl_mem_free (cmdstr);
|
||||
disable_interrupt_key ();
|
||||
return TRANSIENT;
|
||||
}
|
||||
@ -386,10 +389,10 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
|
||||
}
|
||||
}
|
||||
retry = 0;
|
||||
g_free (cmdstr);
|
||||
mhl_mem_free (cmdstr);
|
||||
return status;
|
||||
}
|
||||
g_free (cmdstr);
|
||||
mhl_mem_free (cmdstr);
|
||||
return COMPLETE;
|
||||
}
|
||||
|
||||
@ -401,10 +404,10 @@ ftpfs_free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
ftpfs_command(me, super, NONE, "QUIT");
|
||||
close(SUP.sock);
|
||||
}
|
||||
g_free (SUP.host);
|
||||
g_free (SUP.user);
|
||||
g_free (SUP.cwdir);
|
||||
g_free (SUP.password);
|
||||
mhl_mem_free (SUP.host);
|
||||
mhl_mem_free (SUP.user);
|
||||
mhl_mem_free (SUP.cwdir);
|
||||
mhl_mem_free (SUP.password);
|
||||
}
|
||||
|
||||
/* some defines only used by ftpfs_changetype */
|
||||
@ -455,7 +458,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
|
||||
p = g_strconcat (_(" FTP: Password required for "), SUP.user, " ",
|
||||
NULL);
|
||||
op = vfs_get_password (p);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
if (op == NULL)
|
||||
ERRNOR (EPERM, 0);
|
||||
SUP.password = g_strdup (op);
|
||||
@ -501,13 +504,13 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
|
||||
("FTP: Account required for user %s"),
|
||||
SUP.user);
|
||||
op = input_dialog (p, _("Account:"), MC_HISTORY_FTPFS_ACCOUNT, "");
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
if (op == NULL)
|
||||
ERRNOR (EPERM, 0);
|
||||
print_vfs_message (_("ftpfs: sending user account"));
|
||||
code =
|
||||
ftpfs_command (me, super, WAIT_REPLY, "ACCT %s", op);
|
||||
g_free (op);
|
||||
mhl_mem_free (op);
|
||||
}
|
||||
if (code != COMPLETE)
|
||||
break;
|
||||
@ -516,7 +519,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
|
||||
case COMPLETE:
|
||||
print_vfs_message (_("ftpfs: logged in"));
|
||||
wipe_password (pass);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
return 1;
|
||||
|
||||
default:
|
||||
@ -532,7 +535,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
|
||||
SUP.user);
|
||||
login_fail:
|
||||
wipe_password (pass);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
ERRNOR (EPERM, 0);
|
||||
}
|
||||
|
||||
@ -582,7 +585,7 @@ ftpfs_load_no_proxy_list (void)
|
||||
|
||||
fclose (npf);
|
||||
}
|
||||
g_free (mc_file);
|
||||
mhl_mem_free (mc_file);
|
||||
}
|
||||
|
||||
/* Return 1 if FTP proxy should be used for this host, 0 otherwise */
|
||||
@ -634,8 +637,8 @@ ftpfs_get_proxy_host_and_port (const char *proxy, char **host, int *port)
|
||||
dir =
|
||||
vfs_split_url (proxy, host, &user, port, 0, FTP_COMMAND_PORT,
|
||||
URL_ALLOW_ANON);
|
||||
g_free (user);
|
||||
g_free (dir);
|
||||
mhl_mem_free (user);
|
||||
mhl_mem_free (dir);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -678,7 +681,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
print_vfs_message (_("ftpfs: Invalid host address."));
|
||||
ftpfs_errno = EINVAL;
|
||||
if (free_host)
|
||||
g_free (host);
|
||||
mhl_mem_free (host);
|
||||
return -1;
|
||||
}
|
||||
server_address.sin_family = hp->h_addrtype;
|
||||
@ -694,13 +697,13 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
disable_interrupt_key();
|
||||
ftpfs_errno = errno;
|
||||
if (free_host)
|
||||
g_free (host);
|
||||
mhl_mem_free (host);
|
||||
return -1;
|
||||
}
|
||||
|
||||
print_vfs_message (_("ftpfs: making connection to %s"), host);
|
||||
if (free_host)
|
||||
g_free (host);
|
||||
mhl_mem_free (host);
|
||||
|
||||
if (connect (my_socket, (struct sockaddr *) &server_address,
|
||||
sizeof (server_address)) < 0){
|
||||
@ -815,8 +818,8 @@ ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super,
|
||||
port = ((strcmp (host, SUP.host) == 0)
|
||||
&& (strcmp (user, SUP.user) == 0) && (port == SUP.port));
|
||||
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
mhl_mem_free (host);
|
||||
mhl_mem_free (user);
|
||||
|
||||
return port;
|
||||
}
|
||||
@ -967,7 +970,7 @@ ftpfs_open_data_connection (struct vfs_class *me, struct vfs_s_super *super, con
|
||||
j = ftpfs_command (me, super, WAIT_REPLY, "%s /%s", cmd,
|
||||
/* WarFtpD can't STORE //filename */
|
||||
(*remote_path == '/') ? remote_path + 1 : remote_path);
|
||||
g_free (remote_path);
|
||||
mhl_mem_free (remote_path);
|
||||
} else
|
||||
j = ftpfs_command (me, super, WAIT_REPLY, "%s", cmd);
|
||||
if (j != PRELIM)
|
||||
@ -1153,7 +1156,7 @@ resolve_symlink_with_ls_options(struct vfs_class *me, struct vfs_s_super *super,
|
||||
vfs_die("This code should be commented out\n");
|
||||
if (vfs_parse_ls_lga (buffer, &s, &filename, NULL)) {
|
||||
int r = strcmp(fe->name, filename);
|
||||
g_free(filename);
|
||||
mhl_mem_free(filename);
|
||||
if (r == 0) {
|
||||
if (S_ISLNK (s.st_mode)) {
|
||||
/* This server doesn't understand LIST -lLa */
|
||||
@ -1234,7 +1237,7 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
|
||||
sock =
|
||||
ftpfs_open_data_connection (me, super, "LIST -la", path, TYPE_ASCII,
|
||||
0);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
}
|
||||
|
||||
if (sock == -1)
|
||||
@ -1407,7 +1410,7 @@ ftpfs_linear_start (struct vfs_class *me, struct vfs_s_fh *fh, off_t offset)
|
||||
if (!name)
|
||||
return 0;
|
||||
FH_SOCK = ftpfs_open_data_connection(me, FH_SUPER, "RETR", name, TYPE_BINARY, offset);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
if (FH_SOCK == -1)
|
||||
ERRNOR (EACCES, 0);
|
||||
fh->linear = LS_LINEAR_OPEN;
|
||||
@ -1483,23 +1486,23 @@ ftpfs_send_command(struct vfs_class *me, const char *filename, const char *cmd,
|
||||
int flush_directory_cache = (flags & OPT_FLUSH);
|
||||
|
||||
if (!(rpath = vfs_s_get_path_mangle(me, mpath, &super, 0))) {
|
||||
g_free(mpath);
|
||||
mhl_mem_free(mpath);
|
||||
return -1;
|
||||
}
|
||||
p = ftpfs_translate_path (me, super, rpath);
|
||||
r = ftpfs_command (me, super, WAIT_REPLY, cmd, p);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
vfs_stamp_create (&vfs_ftpfs_ops, super);
|
||||
if (flags & OPT_IGNORE_ERROR)
|
||||
r = COMPLETE;
|
||||
if (r != COMPLETE) {
|
||||
me->verrno = EPERM;
|
||||
g_free (mpath);
|
||||
mhl_mem_free (mpath);
|
||||
return -1;
|
||||
}
|
||||
if (flush_directory_cache)
|
||||
vfs_s_invalidate(me, super);
|
||||
g_free(mpath);
|
||||
mhl_mem_free(mpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1575,12 +1578,12 @@ ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, const cha
|
||||
|
||||
p = ftpfs_translate_path (me, super, remote_path);
|
||||
r = ftpfs_command (me, super, WAIT_REPLY, "CWD /%s", p);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
|
||||
if (r != COMPLETE) {
|
||||
ftpfs_errno = EIO;
|
||||
} else {
|
||||
g_free(SUP.cwdir);
|
||||
mhl_mem_free(SUP.cwdir);
|
||||
SUP.cwdir = g_strdup (remote_path);
|
||||
SUP.cwd_deferred = 0;
|
||||
}
|
||||
@ -1643,7 +1646,7 @@ ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
|
||||
ftpfs_open_data_connection (me, fh->ino->super,
|
||||
(flags & O_APPEND) ? "APPE" :
|
||||
"STOR", name, TYPE_BINARY, 0);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
|
||||
if (fh->handle < 0)
|
||||
return -1;
|
||||
@ -1655,7 +1658,7 @@ ftpfs_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags,
|
||||
|
||||
if (fh->ino->localname) {
|
||||
unlink (fh->ino->localname);
|
||||
g_free (fh->ino->localname);
|
||||
mhl_mem_free (fh->ino->localname);
|
||||
fh->ino->localname = NULL;
|
||||
}
|
||||
return 0;
|
||||
@ -1694,12 +1697,12 @@ ftpfs_done (struct vfs_class *me)
|
||||
|
||||
while (no_proxy) {
|
||||
np = no_proxy->next;
|
||||
g_free (no_proxy->domain);
|
||||
g_free (no_proxy);
|
||||
mhl_mem_free (no_proxy->domain);
|
||||
mhl_mem_free (no_proxy);
|
||||
no_proxy = np;
|
||||
}
|
||||
g_free (ftpfs_anonymous_passwd);
|
||||
g_free (ftpfs_proxy_host);
|
||||
mhl_mem_free (ftpfs_anonymous_passwd);
|
||||
mhl_mem_free (ftpfs_proxy_host);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1711,7 +1714,7 @@ ftpfs_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
while (super){
|
||||
name = g_strconcat ("/#ftp:", SUP.user, "@", SUP.host, "/", SUP.cwdir, (char *) NULL);
|
||||
(*func)(name);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
super = super->next;
|
||||
}
|
||||
}
|
||||
@ -1889,7 +1892,7 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass)
|
||||
netrcname = concat_dir_and_file (home_dir, ".netrc");
|
||||
netrcp = netrc = load_file (netrcname);
|
||||
if (netrc == NULL) {
|
||||
g_free (netrcname);
|
||||
mhl_mem_free (netrcname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1964,8 +1967,8 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass)
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (netrc);
|
||||
g_free (netrcname);
|
||||
mhl_mem_free (netrc);
|
||||
mhl_mem_free (netrcname);
|
||||
|
||||
rupp = g_new (struct rupcache, 1);
|
||||
rupp->host = g_strdup (host);
|
||||
|
8
vfs/gc.c
8
vfs/gc.c
@ -31,6 +31,8 @@
|
||||
#include <signal.h>
|
||||
#include <ctype.h> /* is_digit() */
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -107,7 +109,7 @@ vfs_rmstamp (struct vfs_class *v, vfsid id)
|
||||
} else {
|
||||
st1->next = stamp->next;
|
||||
}
|
||||
g_free (stamp);
|
||||
mhl_mem_free (stamp);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -126,7 +128,7 @@ vfs_getid (struct vfs_class *vclass, const char *dir)
|
||||
if (vclass->getid)
|
||||
id = (*vclass->getid) (vclass, dir1);
|
||||
|
||||
g_free (dir1);
|
||||
mhl_mem_free (dir1);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -295,7 +297,7 @@ vfs_gc_done (void)
|
||||
if (stamp->v->free)
|
||||
(*stamp->v->free) (stamp->id);
|
||||
st = stamp->next;
|
||||
g_free (stamp);
|
||||
mhl_mem_free (stamp);
|
||||
stamp = st;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
@ -68,7 +69,7 @@ local_close (void *data)
|
||||
return -1;
|
||||
|
||||
fd = *(int *) data;
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
return close (fd);
|
||||
}
|
||||
|
||||
@ -109,7 +110,7 @@ local_closedir (void *data)
|
||||
int i;
|
||||
|
||||
i = closedir (* (DIR **) data);
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
66
vfs/mcfs.c
66
vfs/mcfs.c
@ -112,7 +112,7 @@ mcfs_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
name = g_strconcat ("/#mc:", mcfs_connections[i].user,
|
||||
"@", mcfs_connections[i].host, (char *) NULL);
|
||||
(*func) (name);
|
||||
g_free (name);
|
||||
mhl_mem_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,11 +390,11 @@ mcfs_get_path (mcfs_connection **mc, const char *path)
|
||||
if ((remote_path =
|
||||
mcfs_get_host_and_username (path, &host, &user, &port, &pass)))
|
||||
if (!(*mc = mcfs_open_link (host, user, &port, pass))) {
|
||||
g_free (remote_path);
|
||||
mhl_mem_free (remote_path);
|
||||
remote_path = NULL;
|
||||
}
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
mhl_mem_free (host);
|
||||
mhl_mem_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
|
||||
@ -408,7 +408,7 @@ mcfs_get_path (mcfs_connection **mc, const char *path)
|
||||
char *s;
|
||||
s = concat_dir_and_file (mcfs_gethome (*mc),
|
||||
remote_path + 3 - f);
|
||||
g_free (remote_path);
|
||||
mhl_mem_free (remote_path);
|
||||
remote_path = s;
|
||||
}
|
||||
}
|
||||
@ -442,14 +442,14 @@ mcfs_rpc_two_paths (int command, const char *s1, const char *s2)
|
||||
return -1;
|
||||
|
||||
if ((r2 = mcfs_get_path (&mc, s2)) == 0) {
|
||||
g_free (r1);
|
||||
mhl_mem_free (r1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rpc_send (mc->sock,
|
||||
RPC_INT, command, RPC_STRING, r1, RPC_STRING, r2, RPC_END);
|
||||
g_free (r1);
|
||||
g_free (r2);
|
||||
mhl_mem_free (r1);
|
||||
mhl_mem_free (r2);
|
||||
return mcfs_handle_simple_error (mc->sock, 0);
|
||||
}
|
||||
|
||||
@ -465,7 +465,7 @@ mcfs_rpc_path (int command, const char *path)
|
||||
rpc_send (mc->sock,
|
||||
RPC_INT, command, RPC_STRING, remote_file, RPC_END);
|
||||
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
return mcfs_handle_simple_error (mc->sock, 0);
|
||||
}
|
||||
|
||||
@ -482,7 +482,7 @@ mcfs_rpc_path_int (int command, const char *path, int data)
|
||||
RPC_INT, command,
|
||||
RPC_STRING, remote_file, RPC_INT, data, RPC_END);
|
||||
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
return mcfs_handle_simple_error (mc->sock, 0);
|
||||
}
|
||||
|
||||
@ -499,7 +499,7 @@ mcfs_rpc_path_int_int (int command, const char *path, int n1, int n2)
|
||||
RPC_INT, command,
|
||||
RPC_STRING, remote_file, RPC_INT, n1, RPC_INT, n2, RPC_END);
|
||||
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
return mcfs_handle_simple_error (mc->sock, 0);
|
||||
}
|
||||
|
||||
@ -535,7 +535,7 @@ mcfs_open (struct vfs_class *me, const char *file, int flags, int mode)
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT,
|
||||
flags, RPC_INT, mode, RPC_END);
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
|
||||
if (0 ==
|
||||
rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END))
|
||||
@ -617,7 +617,7 @@ mcfs_close (void *data)
|
||||
|
||||
mcfs_is_error (result, error);
|
||||
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ mcfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_OPENDIR, RPC_STRING, remote_dir,
|
||||
RPC_END);
|
||||
g_free (remote_dir);
|
||||
mhl_mem_free (remote_dir);
|
||||
|
||||
if (0 ==
|
||||
rpc_get (mc->sock, RPC_INT, &result, RPC_INT, &error_num, RPC_END))
|
||||
@ -742,8 +742,8 @@ mcfs_free_dir (dir_entry *de)
|
||||
if (!de)
|
||||
return;
|
||||
mcfs_free_dir (de->next);
|
||||
g_free (de->text);
|
||||
g_free (de);
|
||||
mhl_mem_free (de->text);
|
||||
mhl_mem_free (de);
|
||||
}
|
||||
|
||||
static union vfs_dirent mcfs_readdir_data;
|
||||
@ -793,10 +793,10 @@ mcfs_closedir (void *info)
|
||||
for (p = mcfs_info->entries; p;) {
|
||||
q = p;
|
||||
p = p->next;
|
||||
g_free (q->text);
|
||||
g_free (q);
|
||||
mhl_mem_free (q->text);
|
||||
mhl_mem_free (q);
|
||||
}
|
||||
g_free (info);
|
||||
mhl_mem_free (info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -824,7 +824,7 @@ mcfs_get_time (mcfs_connection *mc)
|
||||
|
||||
rpc_get (sock, RPC_STRING, &buf, RPC_END);
|
||||
sscanf (buf, "%lx", &tm);
|
||||
g_free (buf);
|
||||
mhl_mem_free (buf);
|
||||
|
||||
return (time_t) tm;
|
||||
}
|
||||
@ -877,7 +877,7 @@ mcfs_stat_cmd (int cmd, const char *path, struct stat *buf)
|
||||
return -1;
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, cmd, RPC_STRING, remote_file, RPC_END);
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return mcfs_set_error (-1, errno);
|
||||
|
||||
@ -984,7 +984,7 @@ mcfs_utime (struct vfs_class *me, const char *path, struct utimbuf *times)
|
||||
status = mcfs_handle_simple_error (mc->sock, 0);
|
||||
|
||||
}
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
return (status);
|
||||
}
|
||||
|
||||
@ -1003,7 +1003,7 @@ mcfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_READLINK, RPC_STRING, remote_file,
|
||||
RPC_END);
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
@ -1018,7 +1018,7 @@ mcfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size)
|
||||
size = len;
|
||||
/* readlink() does not append a NUL character to buf */
|
||||
memcpy (buf, stat_str, size);
|
||||
g_free (stat_str);
|
||||
mhl_mem_free (stat_str);
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -1060,7 +1060,7 @@ mcfs_chdir (struct vfs_class *me, const char *path)
|
||||
|
||||
rpc_send (mc->sock, RPC_INT, MC_CHDIR, RPC_STRING, remote_dir,
|
||||
RPC_END);
|
||||
g_free (remote_dir);
|
||||
mhl_mem_free (remote_dir);
|
||||
if (!rpc_get (mc->sock, RPC_INT, &status, RPC_INT, &error, RPC_END))
|
||||
return mcfs_set_error (-1, EIO);
|
||||
|
||||
@ -1136,8 +1136,8 @@ mcfs_forget (const char *path)
|
||||
if ((p =
|
||||
mcfs_get_host_and_username (path, &host, &user, &port,
|
||||
&pass)) == 0) {
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
mhl_mem_free (host);
|
||||
mhl_mem_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
return;
|
||||
@ -1155,9 +1155,9 @@ mcfs_forget (const char *path)
|
||||
mcfs_open_tcp_link (host, user, &port, pass, &vers);
|
||||
}
|
||||
}
|
||||
g_free (p);
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
mhl_mem_free (p);
|
||||
mhl_mem_free (host);
|
||||
mhl_mem_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
}
|
||||
@ -1213,9 +1213,9 @@ init_mcfs (void)
|
||||
static void
|
||||
mcfs_free_bucket (int bucket)
|
||||
{
|
||||
g_free (mcfs_connections[bucket].host);
|
||||
g_free (mcfs_connections[bucket].user);
|
||||
g_free (mcfs_connections[bucket].home);
|
||||
mhl_mem_free (mcfs_connections[bucket].host);
|
||||
mhl_mem_free (mcfs_connections[bucket].user);
|
||||
mhl_mem_free (mcfs_connections[bucket].home);
|
||||
|
||||
/* Set all the fields to zero */
|
||||
mcfs_connections[bucket].host =
|
||||
|
56
vfs/mcserv.c
56
vfs/mcserv.c
@ -124,10 +124,6 @@
|
||||
# define INADDR_NONE (0xffffffffU)
|
||||
#endif
|
||||
|
||||
/* replacement for g_free() from glib */
|
||||
#undef g_free
|
||||
#define g_free(x) do {if (x) free (x);} while (0)
|
||||
|
||||
/* We don't care about SIGPIPE */
|
||||
int got_sigpipe = 0;
|
||||
|
||||
@ -214,7 +210,7 @@ do_open (void)
|
||||
|
||||
handle = open (arg, flags, mode);
|
||||
send_status (handle, errno);
|
||||
g_free (arg);
|
||||
mhl_mem_free (arg);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -241,7 +237,7 @@ do_read (void)
|
||||
send_status (n, 0);
|
||||
rpc_send (msock, RPC_BLOCK, n, data, RPC_END);
|
||||
|
||||
g_free (data);
|
||||
mhl_mem_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -381,7 +377,7 @@ do_lstat (void)
|
||||
send_status (n, errno);
|
||||
if (n >= 0)
|
||||
send_stat_info (&st);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -413,7 +409,7 @@ do_stat (void)
|
||||
send_status (n, errno);
|
||||
if (n >= 0)
|
||||
send_stat_info (&st);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
@ -433,7 +429,7 @@ close_handle (int handle)
|
||||
mcfs_DIR.used--;
|
||||
if (mcfs_DIR.dirs[handle])
|
||||
closedir (mcfs_DIR.dirs[handle]);
|
||||
g_free (mcfs_DIR.names[handle]);
|
||||
mhl_mem_free (mcfs_DIR.names[handle]);
|
||||
mcfs_DIR.dirs[handle] = 0;
|
||||
mcfs_DIR.names[handle] = 0;
|
||||
}
|
||||
@ -449,7 +445,7 @@ do_opendir (void)
|
||||
|
||||
if (mcfs_DIR.used == OPENDIR_HANDLES) {
|
||||
send_status (-1, ENFILE); /* Error */
|
||||
g_free (arg);
|
||||
mhl_mem_free (arg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -463,7 +459,7 @@ do_opendir (void)
|
||||
|
||||
if (handle == -1) {
|
||||
send_status (-1, EMFILE);
|
||||
g_free (arg);
|
||||
mhl_mem_free (arg);
|
||||
if (!inetd_started)
|
||||
fprintf (stderr,
|
||||
"OOPS! you have found a bug in mc - do_opendir()!\n");
|
||||
@ -483,7 +479,7 @@ do_opendir (void)
|
||||
|
||||
} else {
|
||||
send_status (-1, errno);
|
||||
g_free (arg);
|
||||
mhl_mem_free (arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,7 +514,7 @@ do_readdir (void)
|
||||
snprintf (fname, fname_len, "%s/%s", mcfs_DIR.names[handle],
|
||||
dirent->d_name);
|
||||
n = lstat (fname, &st);
|
||||
g_free (fname);
|
||||
mhl_mem_free (fname);
|
||||
send_status (n, errno);
|
||||
if (n >= 0)
|
||||
send_stat_info (&st);
|
||||
@ -549,7 +545,7 @@ do_chdir (void)
|
||||
|
||||
status = chdir (file);
|
||||
send_status (status, errno);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -562,7 +558,7 @@ do_rmdir (void)
|
||||
|
||||
status = rmdir (file);
|
||||
send_status (status, errno);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -575,7 +571,7 @@ do_mkdir (void)
|
||||
|
||||
status = mkdir (file, mode);
|
||||
send_status (status, errno);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -589,7 +585,7 @@ do_mknod (void)
|
||||
|
||||
status = mknod (file, mode, dev);
|
||||
send_status (status, errno);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -606,7 +602,7 @@ do_readlink (void)
|
||||
buffer[n] = 0;
|
||||
rpc_send (msock, RPC_STRING, buffer, RPC_END);
|
||||
}
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -618,7 +614,7 @@ do_unlink (void)
|
||||
rpc_get (msock, RPC_STRING, &file, RPC_END);
|
||||
status = unlink (file);
|
||||
send_status (status, errno);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -630,8 +626,8 @@ do_rename (void)
|
||||
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
|
||||
status = rename (f1, f2);
|
||||
send_status (status, errno);
|
||||
g_free (f1);
|
||||
g_free (f2);
|
||||
mhl_mem_free (f1);
|
||||
mhl_mem_free (f2);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -643,8 +639,8 @@ do_symlink (void)
|
||||
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
|
||||
status = symlink (f1, f2);
|
||||
send_status (status, errno);
|
||||
g_free (f1);
|
||||
g_free (f2);
|
||||
mhl_mem_free (f1);
|
||||
mhl_mem_free (f2);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -656,8 +652,8 @@ do_link (void)
|
||||
rpc_get (msock, RPC_STRING, &f1, RPC_STRING, &f2, RPC_END);
|
||||
status = link (f1, f2);
|
||||
send_status (status, errno);
|
||||
g_free (f1);
|
||||
g_free (f2);
|
||||
mhl_mem_free (f1);
|
||||
mhl_mem_free (f2);
|
||||
}
|
||||
|
||||
|
||||
@ -686,7 +682,7 @@ do_chmod (void)
|
||||
rpc_get (msock, RPC_STRING, &file, RPC_INT, &mode, RPC_END);
|
||||
status = chmod (file, mode);
|
||||
send_status (status, errno);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -699,7 +695,7 @@ do_chown (void)
|
||||
RPC_END);
|
||||
status = chown (file, owner, group);
|
||||
send_status (status, errno);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -720,13 +716,13 @@ do_utime (void)
|
||||
if (verbose)
|
||||
printf ("Got a = %s, m = %s, comp a = %ld, m = %ld\n", as, ms,
|
||||
atime, mtime);
|
||||
g_free (as);
|
||||
g_free (ms);
|
||||
mhl_mem_free (as);
|
||||
mhl_mem_free (ms);
|
||||
times.actime = (time_t) atime;
|
||||
times.modtime = (time_t) mtime;
|
||||
status = utime (file, ×);
|
||||
send_status (status, errno);
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
|
32
vfs/sfs.c
32
vfs/sfs.c
@ -34,6 +34,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -80,7 +82,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
|
||||
vfs_die ("This cannot happen... Hopefully.\n");
|
||||
|
||||
if (!(sfs_flags[w] & F_1) && strcmp (pname, "/")) {
|
||||
g_free (pname);
|
||||
mhl_mem_free (pname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -88,19 +90,19 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
|
||||
if (!(sfs_flags[w] & F_NOLOCALCOPY)) {
|
||||
s = mc_getlocalcopy (pname);
|
||||
if (!s) {
|
||||
g_free (pname);
|
||||
mhl_mem_free (pname);
|
||||
return -1;
|
||||
}
|
||||
pqname = name_quote (s, 0);
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
} else {
|
||||
pqname = name_quote (pname, 0);
|
||||
}
|
||||
g_free (pname);
|
||||
mhl_mem_free (pname);
|
||||
|
||||
#define COPY_CHAR \
|
||||
if ((size_t) (t-pad) > sizeof(pad)) { \
|
||||
g_free (pqname); \
|
||||
mhl_mem_free (pqname); \
|
||||
return -1; \
|
||||
} \
|
||||
else \
|
||||
@ -108,7 +110,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
|
||||
|
||||
#define COPY_STRING(a) \
|
||||
if ((t-pad)+strlen(a)>sizeof(pad)) { \
|
||||
g_free (pqname); \
|
||||
mhl_mem_free (pqname); \
|
||||
return -1; \
|
||||
} else { \
|
||||
strcpy (t, a); \
|
||||
@ -144,7 +146,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
|
||||
}
|
||||
}
|
||||
|
||||
g_free (pqname);
|
||||
mhl_mem_free (pqname);
|
||||
open_error_pipe ();
|
||||
if (my_system (EXECUTE_AS_SHELL, "/bin/sh", pad)) {
|
||||
close_error_pipe (D_ERROR, NULL);
|
||||
@ -191,7 +193,7 @@ sfs_redirect (struct vfs_class *me, const char *name)
|
||||
}
|
||||
|
||||
unlink (cache);
|
||||
g_free (cache);
|
||||
mhl_mem_free (cache);
|
||||
return "/I_MUST_NOT_EXIST";
|
||||
}
|
||||
|
||||
@ -285,9 +287,9 @@ static void sfs_free (vfsid id)
|
||||
else
|
||||
head = cur->next;
|
||||
|
||||
g_free (cur->cache);
|
||||
g_free (cur->name);
|
||||
g_free (cur);
|
||||
mhl_mem_free (cur->cache);
|
||||
mhl_mem_free (cur->name);
|
||||
mhl_mem_free (cur);
|
||||
}
|
||||
|
||||
static void sfs_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
@ -341,10 +343,10 @@ static int sfs_init (struct vfs_class *me)
|
||||
|
||||
if (!cfg){
|
||||
fprintf (stderr, _("Warning: file %s not found\n"), mc_sfsini);
|
||||
g_free (mc_sfsini);
|
||||
mhl_mem_free (mc_sfsini);
|
||||
return 0;
|
||||
}
|
||||
g_free (mc_sfsini);
|
||||
mhl_mem_free (mc_sfsini);
|
||||
|
||||
sfs_no = 0;
|
||||
while (sfs_no < MAXFS && fgets (key, sizeof (key), cfg)) {
|
||||
@ -406,8 +408,8 @@ sfs_done (struct vfs_class *me)
|
||||
(void) me;
|
||||
|
||||
for (i = 0; i < sfs_no; i++){
|
||||
g_free (sfs_prefix [i]);
|
||||
g_free (sfs_command [i]);
|
||||
mhl_mem_free (sfs_prefix [i]);
|
||||
mhl_mem_free (sfs_command [i]);
|
||||
sfs_prefix [i] = sfs_command [i] = NULL;
|
||||
}
|
||||
sfs_no = 0;
|
||||
|
122
vfs/smbfs.c
122
vfs/smbfs.c
@ -112,7 +112,7 @@ static GSList *auth_list;
|
||||
static inline char *
|
||||
free_after (char *result, char *string_to_free)
|
||||
{
|
||||
g_free(string_to_free);
|
||||
mhl_mem_free(string_to_free);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -120,10 +120,10 @@ free_after (char *result, char *string_to_free)
|
||||
static void
|
||||
smbfs_auth_free (struct smb_authinfo const *a)
|
||||
{
|
||||
g_free (a->host);
|
||||
g_free (a->share);
|
||||
g_free (a->domain);
|
||||
g_free (a->user);
|
||||
mhl_mem_free (a->host);
|
||||
mhl_mem_free (a->share);
|
||||
mhl_mem_free (a->domain);
|
||||
mhl_mem_free (a->user);
|
||||
wipe_password (a->password);
|
||||
}
|
||||
|
||||
@ -197,8 +197,8 @@ smbfs_auth_remove (const char *host, const char *share)
|
||||
list = g_slist_find_custom (auth_list,
|
||||
&data,
|
||||
smbfs_auth_cmp_host_and_share);
|
||||
g_free (data.host);
|
||||
g_free (data.share);
|
||||
mhl_mem_free (data.host);
|
||||
mhl_mem_free (data.share);
|
||||
if (!list)
|
||||
return;
|
||||
auth = list->data;
|
||||
@ -219,9 +219,9 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket,
|
||||
GSList *list;
|
||||
|
||||
if (domain && user && pass) {
|
||||
g_free (bucket->domain);
|
||||
g_free (bucket->user);
|
||||
g_free (bucket->password);
|
||||
mhl_mem_free (bucket->domain);
|
||||
mhl_mem_free (bucket->user);
|
||||
mhl_mem_free (bucket->password);
|
||||
bucket->domain = g_strdup (domain);
|
||||
bucket->user = g_strdup (user);
|
||||
bucket->password = g_strdup (pass);
|
||||
@ -256,9 +256,9 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket,
|
||||
(domain ? domain : lp_workgroup ()),
|
||||
user);
|
||||
if (auth) {
|
||||
g_free (bucket->domain);
|
||||
g_free (bucket->user);
|
||||
g_free (bucket->password);
|
||||
mhl_mem_free (bucket->domain);
|
||||
mhl_mem_free (bucket->user);
|
||||
mhl_mem_free (bucket->password);
|
||||
bucket->domain = g_strdup (auth->domain);
|
||||
bucket->user = g_strdup (auth->user);
|
||||
bucket->password = g_strdup (auth->password);
|
||||
@ -357,7 +357,7 @@ smbfs_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
"/", smbfs_connections[i].service,
|
||||
NULL);
|
||||
(*func)(path);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -606,10 +606,10 @@ smbfs_reconnect(smbfs_connection *conn, int *retries)
|
||||
if (!(conn->cli = smbfs_do_connect(host, conn->service))) {
|
||||
message (D_ERROR, MSG_ERROR,
|
||||
_(" reconnect to %s failed\n "), conn->host);
|
||||
g_free(host);
|
||||
mhl_mem_free(host);
|
||||
return False;
|
||||
}
|
||||
g_free(host);
|
||||
mhl_mem_free(host);
|
||||
if (++(*retries) == 2)
|
||||
return False;
|
||||
return True;
|
||||
@ -777,12 +777,12 @@ smbfs_loaddir (opendir_info *smbfs_info)
|
||||
smbfs_loaddir_helper, NULL) < 0) {
|
||||
/* cli_list returns -1 if directory empty or cannot read socket */
|
||||
my_errno = cli_error (smbfs_info->conn->cli, NULL, &err, NULL);
|
||||
g_free (my_dirname);
|
||||
mhl_mem_free (my_dirname);
|
||||
return 0;
|
||||
}
|
||||
if (*(my_dirname) == 0)
|
||||
smbfs_info->dirname = smbfs_info->conn->service;
|
||||
g_free (my_dirname);
|
||||
mhl_mem_free (my_dirname);
|
||||
/* do_dskattr(); */
|
||||
|
||||
done:
|
||||
@ -799,8 +799,8 @@ smbfs_free_dir (dir_entry *de)
|
||||
if (!de) return;
|
||||
|
||||
smbfs_free_dir (de->next);
|
||||
g_free (de->text);
|
||||
g_free (de);
|
||||
mhl_mem_free (de->text);
|
||||
mhl_mem_free (de);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -849,10 +849,10 @@ smbfs_closedir (void *info)
|
||||
/* for (p = smbfs_info->entries; p;){
|
||||
q = p;
|
||||
p = p->next;
|
||||
g_free (q->text);
|
||||
g_free (q);
|
||||
mhl_mem_free (q->text);
|
||||
mhl_mem_free (q);
|
||||
}
|
||||
g_free (info); */
|
||||
mhl_mem_free (info); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1037,12 +1037,12 @@ smbfs_get_master_browser(char **host)
|
||||
static void
|
||||
smbfs_free_bucket (smbfs_connection *bucket)
|
||||
{
|
||||
g_free (bucket->host);
|
||||
g_free (bucket->service);
|
||||
g_free (bucket->domain);
|
||||
g_free (bucket->user);
|
||||
mhl_mem_free (bucket->host);
|
||||
mhl_mem_free (bucket->service);
|
||||
mhl_mem_free (bucket->domain);
|
||||
mhl_mem_free (bucket->user);
|
||||
wipe_password (bucket->password);
|
||||
g_free (bucket->home);
|
||||
mhl_mem_free (bucket->home);
|
||||
memset (bucket, 0, sizeof (smbfs_connection));
|
||||
}
|
||||
|
||||
@ -1148,7 +1148,7 @@ smbfs_open_link (char *host, char *path, const char *user, int *port,
|
||||
if (!(*host)) { /* if blank host name, browse for servers */
|
||||
if (!smbfs_get_master_browser (&host)) /* set host to ip of master browser */
|
||||
return 0; /* could not find master browser? */
|
||||
g_free (host);
|
||||
mhl_mem_free (host);
|
||||
bucket->host = g_strdup (""); /* blank host means master browser */
|
||||
} else
|
||||
bucket->host = g_strdup (host);
|
||||
@ -1195,11 +1195,11 @@ smbfs_get_path (smbfs_connection ** sc, const char *path)
|
||||
smbfs_get_host_and_username (&path, &host, &user, &port, &pass)))
|
||||
if ((*sc =
|
||||
smbfs_open_link (host, remote_path, user, &port, pass)) == NULL) {
|
||||
g_free (remote_path);
|
||||
mhl_mem_free (remote_path);
|
||||
remote_path = NULL;
|
||||
}
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
mhl_mem_free (host);
|
||||
mhl_mem_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
|
||||
@ -1212,7 +1212,7 @@ smbfs_get_path (smbfs_connection ** sc, const char *path)
|
||||
if (f || !strncmp (remote_path, "/~/", 3)) {
|
||||
char *s;
|
||||
s = concat_dir_and_file ((*sc)->home, remote_path + 3 - f);
|
||||
g_free (remote_path);
|
||||
mhl_mem_free (remote_path);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@ -1302,7 +1302,7 @@ smbfs_fake_share_stat (const char *server_url, const char *path, struct stat *bu
|
||||
smbfs_connection *sc;
|
||||
char *p;
|
||||
p = smbfs_get_path (&sc, path);
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
if (p) {
|
||||
memset (buf, 0, sizeof (*buf));
|
||||
/* show this as dir */
|
||||
@ -1366,16 +1366,16 @@ smbfs_get_remote_stat (smbfs_connection * sc, const char *path, struct stat *buf
|
||||
if (cli_list
|
||||
(sc->cli, mypath, attribute, smbfs_loaddir_helper, single_entry) < 1) {
|
||||
my_errno = ENOENT;
|
||||
g_free (mypath);
|
||||
mhl_mem_free (mypath);
|
||||
return -1; /* cli_list returns number of files */
|
||||
}
|
||||
|
||||
memcpy (buf, &single_entry->my_stat, sizeof (struct stat));
|
||||
|
||||
/* don't free here, use for smbfs_fstat() */
|
||||
/* g_free(single_entry->text);
|
||||
g_free(single_entry); */
|
||||
g_free (mypath);
|
||||
/* mhl_mem_free(single_entry->text);
|
||||
mhl_mem_free(single_entry); */
|
||||
mhl_mem_free (mypath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1433,11 +1433,11 @@ smbfs_get_stat_info (smbfs_connection * sc, const char *path, struct stat *buf)
|
||||
memset (buf, 0, sizeof (struct stat));
|
||||
buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask;
|
||||
memcpy (&single_entry->my_stat, buf, sizeof (struct stat));
|
||||
g_free (mdp);
|
||||
mhl_mem_free (mdp);
|
||||
DEBUG (1, (" PARENT:found in %s\n", current_info->dirname));
|
||||
return 0;
|
||||
}
|
||||
g_free (mdp);
|
||||
mhl_mem_free (mdp);
|
||||
}
|
||||
/* now try to identify as CURRENT dir? */
|
||||
{
|
||||
@ -1495,7 +1495,7 @@ smbfs_chdir (struct vfs_class *me, const char *path)
|
||||
DEBUG (3, ("smbfs_chdir(path:%s)\n", path));
|
||||
if (!(remote_dir = smbfs_get_path (&sc, path)))
|
||||
return -1;
|
||||
g_free (remote_dir);
|
||||
mhl_mem_free (remote_dir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1514,7 +1514,7 @@ smbfs_loaddir_by_name (struct vfs_class *me, const char *path)
|
||||
DEBUG(6, ("smbfs_loaddir_by_name(%s)\n", mypath));
|
||||
smbfs_chdir(me, mypath);
|
||||
info = smbfs_opendir (me, mypath);
|
||||
g_free(mypath);
|
||||
mhl_mem_free(mypath);
|
||||
if (!info)
|
||||
return -1;
|
||||
smbfs_readdir(info);
|
||||
@ -1592,7 +1592,7 @@ smbfs_stat (struct vfs_class * me, const char *path, struct stat *buf)
|
||||
DEBUG (1, ("smbfs_stat: showing server as directory\n"));
|
||||
memset (buf, 0, sizeof (struct stat));
|
||||
buf->st_mode = (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH) & myumask;
|
||||
g_free (service);
|
||||
mhl_mem_free (service);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1613,12 +1613,12 @@ smbfs_stat (struct vfs_class * me, const char *path, struct stat *buf)
|
||||
if (strncmp (p, pp, strlen (p)) != 0) {
|
||||
DEBUG (6, ("desired '%s' is not loaded, we have '%s'\n", p, pp));
|
||||
if (smbfs_loaddir_by_name (me, path) < 0) {
|
||||
g_free (service);
|
||||
mhl_mem_free (service);
|
||||
return -1;
|
||||
}
|
||||
DEBUG (6, ("loaded dir: '%s'\n", current_info->dirname));
|
||||
}
|
||||
g_free (service);
|
||||
mhl_mem_free (service);
|
||||
/* stat dirs & files under shares now */
|
||||
return smbfs_get_stat_info (sc, path, buf);
|
||||
}
|
||||
@ -1680,17 +1680,17 @@ smbfs_mkdir (struct vfs_class * me, const char *path, mode_t mode)
|
||||
DEBUG (3, ("smbfs_mkdir(path:%s, mode:%d)\n", path, (int) mode));
|
||||
if ((remote_file = smbfs_get_path (&sc, path)) == 0)
|
||||
return -1;
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
cpath = smbfs_convert_path (path, FALSE);
|
||||
|
||||
if (!cli_mkdir (sc->cli, cpath)) {
|
||||
my_errno = cli_error (sc->cli, NULL, &err, NULL);
|
||||
message (D_ERROR, MSG_ERROR, _(" Error %s creating directory %s "),
|
||||
cli_errstr (sc->cli), CNV_LANG (cpath));
|
||||
g_free (cpath);
|
||||
mhl_mem_free (cpath);
|
||||
return -1;
|
||||
}
|
||||
g_free (cpath);
|
||||
mhl_mem_free (cpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1706,18 +1706,18 @@ smbfs_rmdir (struct vfs_class *me, const char *path)
|
||||
DEBUG(3, ("smbfs_rmdir(path:%s)\n", path));
|
||||
if ((remote_file = smbfs_get_path (&sc, path)) == 0)
|
||||
return -1;
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
cpath = smbfs_convert_path (path, FALSE);
|
||||
|
||||
if (!cli_rmdir(sc->cli, cpath)) {
|
||||
my_errno = cli_error(sc->cli, NULL, &err, NULL);
|
||||
message (D_ERROR, MSG_ERROR, _(" Error %s removing directory %s "),
|
||||
cli_errstr(sc->cli), CNV_LANG(cpath));
|
||||
g_free (cpath);
|
||||
mhl_mem_free (cpath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_free (cpath);
|
||||
mhl_mem_free (cpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1757,7 +1757,7 @@ smbfs_forget (const char *path)
|
||||
path += 2;
|
||||
|
||||
if ((p = smbfs_get_host_and_username (&path, &host, &user, &port, NULL))) {
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
for (i = 0; i < SMBFS_MAX_CONNECTIONS; i++) {
|
||||
if (smbfs_connections[i].cli
|
||||
&& (strcmp (host, smbfs_connections[i].host) == 0)
|
||||
@ -1773,8 +1773,8 @@ smbfs_forget (const char *path)
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
mhl_mem_free (host);
|
||||
mhl_mem_free (user);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1871,9 +1871,9 @@ smbfs_open (struct vfs_class *me, const char *file, int flags, int mode)
|
||||
|
||||
ret = smbfs_open_readwrite (remote_handle, remote_file, flags, mode);
|
||||
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
if (!ret)
|
||||
g_free (remote_handle);
|
||||
mhl_mem_free (remote_handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1894,10 +1894,10 @@ smbfs_unlink (struct vfs_class *me, const char *path)
|
||||
if (!cli_unlink(sc->cli, remote_file)) {
|
||||
message (D_ERROR, MSG_ERROR, _(" %s removing remote file %s "),
|
||||
cli_errstr(sc->cli), CNV_LANG(remote_file));
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
return -1;
|
||||
}
|
||||
g_free (remote_file);
|
||||
mhl_mem_free (remote_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1914,7 +1914,7 @@ smbfs_rename (struct vfs_class *me, const char *a, const char *b)
|
||||
return -1;
|
||||
|
||||
if ((rb = smbfs_get_path (&sc, b)) == 0) {
|
||||
g_free (ra);
|
||||
mhl_mem_free (ra);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1923,8 +1923,8 @@ smbfs_rename (struct vfs_class *me, const char *a, const char *b)
|
||||
|
||||
retval = cli_rename(sc->cli, ra, rb);
|
||||
|
||||
g_free (ra);
|
||||
g_free (rb);
|
||||
mhl_mem_free (ra);
|
||||
mhl_mem_free (rb);
|
||||
|
||||
if (!retval) {
|
||||
message (D_ERROR, MSG_ERROR, _(" %s renaming files\n"),
|
||||
|
20
vfs/tar.c
20
vfs/tar.c
@ -31,6 +31,8 @@
|
||||
#include <sys/mknod.h>
|
||||
#endif
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -242,7 +244,7 @@ tar_open_archive_int (struct vfs_class *me, const char *name,
|
||||
result = mc_open (s, O_RDONLY);
|
||||
if (result == -1)
|
||||
message (D_ERROR, MSG_ERROR, _("Cannot open tar archive\n%s"), s);
|
||||
g_free (s);
|
||||
mhl_mem_free (s);
|
||||
if (result == -1)
|
||||
ERRNOR (ENOENT, -1);
|
||||
}
|
||||
@ -490,13 +492,13 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
|
||||
longp = ((header->header.linkflag == LF_LONGNAME)
|
||||
? &next_long_name : &next_long_link);
|
||||
|
||||
g_free (*longp);
|
||||
mhl_mem_free (*longp);
|
||||
bp = *longp = g_malloc (*h_size + 1);
|
||||
|
||||
for (size = *h_size; size > 0; size -= written) {
|
||||
data = tar_get_next_record (archive, tard)->charptr;
|
||||
if (data == NULL) {
|
||||
g_free (*longp);
|
||||
mhl_mem_free (*longp);
|
||||
*longp = NULL;
|
||||
message (D_ERROR, MSG_ERROR,
|
||||
_("Unexpected EOF on archive file"));
|
||||
@ -511,7 +513,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
|
||||
}
|
||||
|
||||
if (bp - *longp == MC_MAXPATHLEN && bp[-1] != '\0') {
|
||||
g_free (*longp);
|
||||
mhl_mem_free (*longp);
|
||||
*longp = NULL;
|
||||
message (D_ERROR, MSG_ERROR, _("Inconsistent tar archive"));
|
||||
return STATUS_BADCHECKSUM;
|
||||
@ -556,8 +558,8 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
|
||||
PREFIX_SIZE);
|
||||
current_file_name = g_strconcat (temp_prefix, PATH_SEP_STR,
|
||||
temp_name, (char *) NULL);
|
||||
g_free (temp_name);
|
||||
g_free (temp_prefix);
|
||||
mhl_mem_free (temp_name);
|
||||
mhl_mem_free (temp_prefix);
|
||||
}
|
||||
break;
|
||||
case TAR_GNU:
|
||||
@ -601,7 +603,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
|
||||
} else {
|
||||
entry = vfs_s_new_entry (me, p, inode);
|
||||
vfs_s_insert_entry (me, parent, entry);
|
||||
g_free (current_link_name);
|
||||
mhl_mem_free (current_link_name);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@ -613,12 +615,12 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
|
||||
if (*current_link_name) {
|
||||
inode->linkname = current_link_name;
|
||||
} else if (current_link_name != next_long_link) {
|
||||
g_free (current_link_name);
|
||||
mhl_mem_free (current_link_name);
|
||||
}
|
||||
entry = vfs_s_new_entry (me, p, inode);
|
||||
|
||||
vfs_s_insert_entry (me, parent, entry);
|
||||
g_free (current_file_name);
|
||||
mhl_mem_free (current_file_name);
|
||||
|
||||
done:
|
||||
next_long_link = next_long_name = NULL;
|
||||
|
@ -35,8 +35,8 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -51,6 +51,8 @@
|
||||
#include <ext2fs/ext2fs.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -98,11 +100,11 @@ undelfs_shutdown (void)
|
||||
if (fs)
|
||||
ext2fs_close (fs);
|
||||
fs = NULL;
|
||||
g_free (ext2_fname);
|
||||
mhl_mem_free (ext2_fname);
|
||||
ext2_fname = NULL;
|
||||
g_free (delarray);
|
||||
mhl_mem_free (delarray);
|
||||
delarray = NULL;
|
||||
g_free (block_buf);
|
||||
mhl_mem_free (block_buf);
|
||||
block_buf = NULL;
|
||||
}
|
||||
|
||||
@ -143,7 +145,7 @@ undelfs_get_path (const char *dirname, char **fsname, char **file)
|
||||
*file = g_strdup (p+1);
|
||||
tmp = g_strndup (dirname, p - dirname);
|
||||
*fsname = g_strconcat ("/dev/", tmp, (char *) NULL);
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
return;
|
||||
}
|
||||
p--;
|
||||
@ -273,10 +275,10 @@ undelfs_loaddel (void)
|
||||
error_out:
|
||||
ext2fs_close_inode_scan (scan);
|
||||
free_block_buf:
|
||||
g_free (block_buf);
|
||||
mhl_mem_free (block_buf);
|
||||
block_buf = NULL;
|
||||
free_delarray:
|
||||
g_free (delarray);
|
||||
mhl_mem_free (delarray);
|
||||
delarray = NULL;
|
||||
return 0;
|
||||
}
|
||||
@ -298,7 +300,7 @@ com_err (const char *whoami, long err_code, const char *fmt, ...)
|
||||
|
||||
message (D_ERROR, _(" Ext2lib error "), " %s (%s: %ld) ", str, whoami,
|
||||
err_code);
|
||||
g_free (str);
|
||||
mhl_mem_free (str);
|
||||
}
|
||||
|
||||
static void *
|
||||
@ -311,7 +313,7 @@ undelfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
return 0;
|
||||
|
||||
/* We don't use the file name */
|
||||
g_free (f);
|
||||
mhl_mem_free (f);
|
||||
|
||||
if (!ext2_fname || strcmp (ext2_fname, file)){
|
||||
undelfs_shutdown ();
|
||||
@ -319,7 +321,7 @@ undelfs_opendir (struct vfs_class *me, const char *dirname)
|
||||
} else {
|
||||
/* To avoid expensive re-scannings */
|
||||
readdir_ptr = READDIR_PTR_INIT;
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
return fs;
|
||||
}
|
||||
|
||||
@ -415,8 +417,8 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
|
||||
if (!ext2_fname || strcmp (ext2_fname, file)) {
|
||||
message (D_ERROR, undelfserr,
|
||||
_(" You have to chdir to extract files first "));
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
mhl_mem_free (file);
|
||||
mhl_mem_free (f);
|
||||
return 0;
|
||||
}
|
||||
inode = atol (f);
|
||||
@ -429,15 +431,15 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
|
||||
/* Found: setup all the structures needed by read */
|
||||
p = (undelfs_file *) g_try_malloc (((gsize) sizeof (undelfs_file)));
|
||||
if (!p) {
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
mhl_mem_free (file);
|
||||
mhl_mem_free (f);
|
||||
return 0;
|
||||
}
|
||||
p->buf = g_try_malloc (fs->blocksize);
|
||||
if (!p->buf) {
|
||||
g_free (p);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
mhl_mem_free (p);
|
||||
mhl_mem_free (file);
|
||||
mhl_mem_free (f);
|
||||
return 0;
|
||||
}
|
||||
p->inode = inode;
|
||||
@ -447,8 +449,8 @@ undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
|
||||
p->pos = 0;
|
||||
p->size = delarray[i].size;
|
||||
}
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
mhl_mem_free (file);
|
||||
mhl_mem_free (f);
|
||||
undelfs_usage++;
|
||||
return p;
|
||||
}
|
||||
@ -457,8 +459,8 @@ static int
|
||||
undelfs_close (void *vfs_info)
|
||||
{
|
||||
undelfs_file *p = vfs_info;
|
||||
g_free (p->buf);
|
||||
g_free (p);
|
||||
mhl_mem_free (p->buf);
|
||||
mhl_mem_free (p);
|
||||
undelfs_usage--;
|
||||
return 0;
|
||||
}
|
||||
@ -592,20 +594,20 @@ undelfs_lstat (struct vfs_class *me, const char *path, struct stat *buf)
|
||||
f = "sda1" f ="401:1"
|
||||
If the first char in f is no digit -> return error */
|
||||
if (!isdigit (*f)) {
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
mhl_mem_free (file);
|
||||
mhl_mem_free (f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ext2_fname || strcmp (ext2_fname, file)){
|
||||
message (D_ERROR, undelfserr, _(" You have to chdir to extract files first "));
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
mhl_mem_free (file);
|
||||
mhl_mem_free (f);
|
||||
return 0;
|
||||
}
|
||||
inode_index = undelfs_getindex (f);
|
||||
g_free (file);
|
||||
g_free (f);
|
||||
mhl_mem_free (file);
|
||||
mhl_mem_free (f);
|
||||
|
||||
if (inode_index == -1)
|
||||
return -1;
|
||||
@ -638,13 +640,13 @@ undelfs_chdir(struct vfs_class *me, const char *path)
|
||||
/* our vfs, but that is left as an excercise for the reader */
|
||||
if ((fd = open (file, O_RDONLY)) == -1){
|
||||
message (D_ERROR, undelfserr, _(" Cannot open file %s "), file);
|
||||
g_free (f);
|
||||
g_free (file);
|
||||
mhl_mem_free (f);
|
||||
mhl_mem_free (file);
|
||||
return -1;
|
||||
}
|
||||
close (fd);
|
||||
g_free (f);
|
||||
g_free (file);
|
||||
mhl_mem_free (f);
|
||||
mhl_mem_free (file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -664,8 +666,8 @@ undelfs_getid (struct vfs_class *me, const char *path)
|
||||
|
||||
if (!fsname)
|
||||
return NULL;
|
||||
g_free (fname);
|
||||
g_free (fsname);
|
||||
mhl_mem_free (fname);
|
||||
mhl_mem_free (fsname);
|
||||
return (vfsid) fs;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,11 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -133,7 +136,7 @@ vfs_split_url (const char *path, char **host, char **user, int *port,
|
||||
if (host)
|
||||
*host = g_strdup (rest);
|
||||
|
||||
g_free (pcopy);
|
||||
mhl_mem_free (pcopy);
|
||||
return retval;
|
||||
}
|
||||
#endif /* USE_NETCODE */
|
||||
@ -238,7 +241,7 @@ vfs_mkstemps (char **pname, const char *prefix, const char *basename)
|
||||
*q = 0;
|
||||
|
||||
fd = mc_mkstemps (pname, prefix, suffix);
|
||||
g_free (suffix);
|
||||
mhl_mem_free (suffix);
|
||||
return fd;
|
||||
}
|
||||
|
||||
@ -869,7 +872,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename,
|
||||
t[p] = 0;
|
||||
}
|
||||
|
||||
g_free (p_copy);
|
||||
mhl_mem_free (p_copy);
|
||||
return 1;
|
||||
|
||||
error:
|
||||
@ -884,7 +887,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename,
|
||||
_("More parsing errors will be ignored."));
|
||||
}
|
||||
|
||||
g_free (p_copy);
|
||||
mhl_mem_free (p_copy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
52
vfs/vfs.c
52
vfs/vfs.c
@ -38,6 +38,8 @@
|
||||
#include <signal.h>
|
||||
#include <ctype.h> /* is_digit() */
|
||||
|
||||
#include <mhl/memory.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/wtools.h" /* message() */
|
||||
@ -220,7 +222,7 @@ path_magic (const char *path)
|
||||
|
||||
/*
|
||||
* Splits path '/p1#op/inpath' into inpath,op; returns which vfs it is.
|
||||
* What is left in path is p1. You still want to g_free(path), you DON'T
|
||||
* What is left in path is p1. You still want to mhl_mem_free(path), you DON'T
|
||||
* want to free neither *inpath nor *op
|
||||
*/
|
||||
struct vfs_class *
|
||||
@ -301,7 +303,7 @@ vfs_get_class (const char *pathname)
|
||||
char *path = g_strdup (pathname);
|
||||
|
||||
vfs = _vfs_get_class (path);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
|
||||
if (!vfs)
|
||||
vfs = localfs_class;
|
||||
@ -335,13 +337,13 @@ mc_open (const char *filename, int flags, ...)
|
||||
mode = 0;
|
||||
|
||||
if (!vfs->open) {
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
errno = -EOPNOTSUPP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */
|
||||
g_free (file);
|
||||
mhl_mem_free (file);
|
||||
if (!info){
|
||||
errno = ferrno (vfs);
|
||||
return -1;
|
||||
@ -359,7 +361,7 @@ int mc_##name inarg \
|
||||
char *mpath = vfs_canon (path); \
|
||||
vfs = vfs_get_class (mpath); \
|
||||
result = vfs->name ? (*vfs->name)callarg : -1; \
|
||||
g_free (mpath); \
|
||||
mhl_mem_free (mpath); \
|
||||
if (result == -1) \
|
||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
||||
return result; \
|
||||
@ -404,13 +406,13 @@ int mc_##name (const char *fname1, const char *fname2) \
|
||||
name2 = vfs_canon (fname2); \
|
||||
if (vfs != vfs_get_class (name2)){ \
|
||||
errno = EXDEV; \
|
||||
g_free (name1); \
|
||||
g_free (name2); \
|
||||
mhl_mem_free (name1); \
|
||||
mhl_mem_free (name2); \
|
||||
return -1; \
|
||||
} \
|
||||
result = vfs->name ? (*vfs->name)(vfs, name1, name2) : -1; \
|
||||
g_free (name1); \
|
||||
g_free (name2); \
|
||||
mhl_mem_free (name1); \
|
||||
mhl_mem_free (name2); \
|
||||
if (result == -1) \
|
||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP; \
|
||||
return result; \
|
||||
@ -441,7 +443,7 @@ mc_setctl (const char *path, int ctlop, void *arg)
|
||||
mpath = vfs_canon (path);
|
||||
vfs = vfs_get_class (mpath);
|
||||
result = vfs->setctl ? (*vfs->setctl)(vfs, mpath, ctlop, arg) : 0;
|
||||
g_free (mpath);
|
||||
mhl_mem_free (mpath);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -480,7 +482,7 @@ mc_opendir (const char *dirname)
|
||||
vfs = vfs_get_class (dname);
|
||||
|
||||
info = vfs->opendir ? (*vfs->opendir)(vfs, dname) : NULL;
|
||||
g_free (dname);
|
||||
mhl_mem_free (dname);
|
||||
if (!info){
|
||||
errno = vfs->opendir ? ferrno (vfs) : E_NOTSUPP;
|
||||
return NULL;
|
||||
@ -521,7 +523,7 @@ mc_closedir (DIR *dirp)
|
||||
|
||||
result = vfs->closedir ? (*vfs->closedir)(vfs_info (handle)) : -1;
|
||||
vfs_free_handle (handle);
|
||||
g_free (dirp);
|
||||
mhl_mem_free (dirp);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -531,7 +533,7 @@ int mc_stat (const char *filename, struct stat *buf) {
|
||||
char *path;
|
||||
path = vfs_canon (filename); vfs = vfs_get_class (path);
|
||||
result = vfs->stat ? (*vfs->stat) (vfs, path, buf) : -1;
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
if (result == -1)
|
||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP;
|
||||
return result;
|
||||
@ -543,7 +545,7 @@ int mc_lstat (const char *filename, struct stat *buf) {
|
||||
char *path;
|
||||
path = vfs_canon (filename); vfs = vfs_get_class (path);
|
||||
result = vfs->lstat ? (*vfs->lstat) (vfs, path, buf) : -1;
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
if (result == -1)
|
||||
errno = vfs->name ? ferrno (vfs) : E_NOTSUPP;
|
||||
return result;
|
||||
@ -582,11 +584,11 @@ _vfs_get_cwd (void)
|
||||
|| mc_stat (current_dir, &my_stat2)
|
||||
|| my_stat.st_ino != my_stat2.st_ino
|
||||
|| my_stat.st_dev != my_stat2.st_dev) {
|
||||
g_free (current_dir);
|
||||
mhl_mem_free (current_dir);
|
||||
current_dir = p;
|
||||
return p;
|
||||
} /* Otherwise we return current_dir below */
|
||||
g_free (p);
|
||||
mhl_mem_free (p);
|
||||
}
|
||||
return current_dir;
|
||||
}
|
||||
@ -659,7 +661,7 @@ vfs_canon (const char *path)
|
||||
local = concat_dir_and_file (current_dir, path);
|
||||
|
||||
result = vfs_canon (local);
|
||||
g_free (local);
|
||||
mhl_mem_free (local);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -689,7 +691,7 @@ mc_chdir (const char *path)
|
||||
new_dir = vfs_canon (path);
|
||||
new_vfs = vfs_get_class (new_dir);
|
||||
if (!new_vfs->chdir) {
|
||||
g_free (new_dir);
|
||||
mhl_mem_free (new_dir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -697,7 +699,7 @@ mc_chdir (const char *path)
|
||||
|
||||
if (result == -1) {
|
||||
errno = ferrno (new_vfs);
|
||||
g_free (new_dir);
|
||||
mhl_mem_free (new_dir);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -705,7 +707,7 @@ mc_chdir (const char *path)
|
||||
old_vfs = current_vfs;
|
||||
|
||||
/* Actually change directory */
|
||||
g_free (current_dir);
|
||||
mhl_mem_free (current_dir);
|
||||
current_dir = new_dir;
|
||||
current_vfs = new_vfs;
|
||||
|
||||
@ -739,7 +741,7 @@ vfs_file_class_flags (const char *filename)
|
||||
|
||||
fname = vfs_canon (filename);
|
||||
vfs = vfs_get_class (fname);
|
||||
g_free (fname);
|
||||
mhl_mem_free (fname);
|
||||
return vfs->flags;
|
||||
}
|
||||
|
||||
@ -784,7 +786,7 @@ mc_def_getlocalcopy (const char *filename)
|
||||
close (fdout);
|
||||
if (fdin != -1)
|
||||
mc_close (fdin);
|
||||
g_free (tmp);
|
||||
mhl_mem_free (tmp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -797,7 +799,7 @@ mc_getlocalcopy (const char *pathname)
|
||||
|
||||
result = vfs->getlocalcopy ? (*vfs->getlocalcopy)(vfs, path) :
|
||||
mc_def_getlocalcopy (path);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
if (!result)
|
||||
errno = ferrno (vfs);
|
||||
return result;
|
||||
@ -860,7 +862,7 @@ mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed)
|
||||
return_value = vfs->ungetlocalcopy ?
|
||||
(*vfs->ungetlocalcopy)(vfs, path, local, has_changed) :
|
||||
mc_def_ungetlocalcopy (vfs, path, local, has_changed);
|
||||
g_free (path);
|
||||
mhl_mem_free (path);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
@ -904,7 +906,7 @@ vfs_shut (void)
|
||||
|
||||
vfs_gc_done ();
|
||||
|
||||
g_free (current_dir);
|
||||
mhl_mem_free (current_dir);
|
||||
|
||||
for (vfs = vfs_list; vfs; vfs = vfs->next)
|
||||
if (vfs->done)
|
||||
|
Loading…
Reference in New Issue
Block a user