From f921cc40cddc155ce54d51054171e231575034ad Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT service" Date: Fri, 30 Jan 2009 20:10:40 +0100 Subject: [PATCH] replaced calls to g_strdup() by mhl_str_dup() --- ChangeLog | 3 ++ edit/choosesyntax.c | 7 +++-- edit/editcmd.c | 39 +++++++++++++------------ edit/editlock.c | 7 +++-- edit/syntax.c | 43 +++++++++++++-------------- edit/usermap.c | 7 +++-- src/boxes.c | 25 ++++++++-------- src/charsets.c | 6 ++-- src/cmd.c | 15 +++++----- src/color.c | 12 ++++---- src/command.c | 6 ++-- src/complete.c | 21 +++++++------- src/dialog.c | 4 ++- src/dir.c | 9 +++--- src/ecs.c | 6 ++-- src/execute.c | 6 ++-- src/ext.c | 5 ++-- src/file.c | 17 +++++------ src/filegui.c | 11 +++---- src/filenot.c | 4 ++- src/find.c | 35 +++++++++++----------- src/help.c | 5 ++-- src/hotlist.c | 37 +++++++++++------------ src/key.c | 5 ++-- src/layout.c | 8 +++-- src/listmode.c | 5 ++-- src/main.c | 31 ++++++++++---------- src/menu.c | 7 +++-- src/panelize.c | 19 ++++++------ src/profile.c | 19 ++++++------ src/screen.c | 27 ++++++++--------- src/setup.c | 11 +++---- src/subshell.c | 6 ++-- src/treestore.c | 17 ++++++----- src/user.c | 16 +++++----- src/util.c | 15 +++++----- src/utilunix.c | 8 +++-- src/vfsdummy.h | 8 +++-- src/view.c | 21 +++++++------- src/widget.c | 31 ++++++++++---------- src/wtools.c | 6 ++-- vfs/cpio.c | 5 +++- vfs/direntry.c | 19 +++++++----- vfs/extfs.c | 33 +++++++++++---------- vfs/fish.c | 13 +++++---- vfs/ftpfs.c | 48 +++++++++++++++--------------- vfs/local.c | 3 +- vfs/mcfs.c | 14 +++++---- vfs/sfs.c | 12 ++++---- vfs/smbfs.c | 71 +++++++++++++++++++++++---------------------- vfs/tar.c | 6 +++- vfs/undelfs.c | 8 +++-- vfs/utilvfs.c | 27 +++++++++-------- vfs/vfs.c | 18 +++++++----- 54 files changed, 477 insertions(+), 390 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ff022ebf..d5f2a56ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-01-30 Enrico Weigelt, metux IT service + + * replaced calls to g_strdup() by mhl_str_dup() 2009-01-29 Mikhail S. Pobolovets * lib/mc.ext.in: update for OpenOffice and StarOffice viewer. diff --git a/edit/choosesyntax.c b/edit/choosesyntax.c index 670f81fdd..47628eb53 100644 --- a/edit/choosesyntax.c +++ b/edit/choosesyntax.c @@ -17,6 +17,9 @@ */ #include + +#include + #include "edit.h" #include "../src/global.h" #include "../src/wtools.h" @@ -77,7 +80,7 @@ edit_syntax_dialog (void) { } old_auto_syntax = option_auto_syntax; - old_syntax_type = g_strdup (option_syntax_type); + old_syntax_type = mhl_str_dup (option_syntax_type); switch (syntax) { case 0: /* auto syntax */ @@ -89,7 +92,7 @@ edit_syntax_dialog (void) { default: option_auto_syntax = 0; g_free (option_syntax_type); - option_syntax_type = g_strdup (names[syntax - N_DFLT_ENTRIES]); + option_syntax_type = mhl_str_dup (names[syntax - N_DFLT_ENTRIES]); } /* Load or unload syntax rules if the option has changed */ diff --git a/edit/editcmd.c b/edit/editcmd.c index 46ae06bd8..1b54e7c4b 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -36,9 +36,10 @@ #include #include #include - #include +#include + #include "../src/global.h" #include "../src/history.h" @@ -297,10 +298,10 @@ edit_save_file (WEdit *edit, const char *filename) const char *slashpos; slashpos = strrchr (filename, PATH_SEP); if (slashpos) { - savedir = g_strdup (filename); + savedir = mhl_str_dup (filename); savedir[slashpos - filename + 1] = '\0'; } else - savedir = g_strdup ("."); + savedir = mhl_str_dup ("."); saveprefix = concat_dir_and_file (savedir, "cooledit"); g_free (savedir); fd = mc_mkstemps (&savename, saveprefix, NULL); @@ -314,7 +315,7 @@ edit_save_file (WEdit *edit, const char *filename) */ close (fd); } else - savename = g_strdup (filename); + savename = mhl_str_dup (filename); mc_chown (savename, edit->stat1.st_uid, edit->stat1.st_gid); mc_chmod (savename, edit->stat1.st_mode); @@ -503,10 +504,10 @@ edit_set_filename (WEdit *edit, const char *f) g_free (edit->filename); if (!f) f = ""; - edit->filename = g_strdup (f); + edit->filename = mhl_str_dup (f); if (edit->dir == NULL && *f != PATH_SEP) #ifdef USE_VFS - edit->dir = g_strdup (vfs_get_current_dir ()); + edit->dir = mhl_str_dup (vfs_get_current_dir ()); #else edit->dir = g_get_current_dir (); #endif @@ -877,7 +878,7 @@ static int edit_load_file_from_filename (WEdit * edit, char *exp) { int prev_locked = edit->locked; - char *prev_filename = g_strdup (edit->filename); + char *prev_filename = mhl_str_dup (edit->filename); if (!edit_reload (edit, exp)) { g_free (prev_filename); @@ -1458,7 +1459,7 @@ string_regexp_search (char *pattern, char *string, int match_type, *found_len = 0; return -3; } - old_pattern = g_strdup (pattern); + old_pattern = mhl_str_dup (pattern); old_type = match_type; old_icase = icase; } @@ -1840,13 +1841,13 @@ edit_replace_cmd (WEdit *edit, int again) again = 0; if (again) { - input1 = g_strdup (saved1 ? saved1 : ""); - input2 = g_strdup (saved2 ? saved2 : ""); - input3 = g_strdup (saved3 ? saved3 : ""); + input1 = mhl_str_dup (saved1 ? saved1 : ""); + input2 = mhl_str_dup (saved2 ? saved2 : ""); + input3 = mhl_str_dup (saved3 ? saved3 : ""); } else { - char *disp1 = g_strdup (saved1 ? saved1 : ""); - char *disp2 = g_strdup (saved2 ? saved2 : ""); - char *disp3 = g_strdup (saved3 ? saved3 : ""); + char *disp1 = mhl_str_dup (saved1 ? saved1 : ""); + char *disp2 = mhl_str_dup (saved2 ? saved2 : ""); + char *disp3 = mhl_str_dup (saved3 ? saved3 : ""); convert_to_display (disp1); convert_to_display (disp2); @@ -1870,9 +1871,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); + g_free (saved1), saved1 = mhl_str_dup (input1); + g_free (saved2), saved2 = mhl_str_dup (input2); + g_free (saved3), saved3 = mhl_str_dup (input3); } @@ -2087,7 +2088,7 @@ void edit_search_cmd (WEdit * edit, int again) if (again) { /*ctrl-hotkey for search again. */ if (!old) return; - exp = g_strdup (old); + exp = mhl_str_dup (old); } else { #ifdef HAVE_CHARSET @@ -2109,7 +2110,7 @@ void edit_search_cmd (WEdit * edit, int again) if (*exp) { int len = 0; g_free (old); - old = g_strdup (exp); + old = mhl_str_dup (exp); if (search_create_bookmark) { int found = 0, books = 0; diff --git a/edit/editlock.c b/edit/editlock.c index fb945f266..72e433c80 100644 --- a/edit/editlock.c +++ b/edit/editlock.c @@ -22,8 +22,8 @@ */ #include -#include /* kill() */ +#include /* kill() */ #include #include #include @@ -34,9 +34,10 @@ #include #include #include - #include +#include + #include "../src/global.h" #include "edit.h" @@ -96,7 +97,7 @@ lock_build_symlink_name (const char *fname) return NULL; fname = x_basename (absolute_fname); - fname_copy = g_strdup (fname); + fname_copy = mhl_str_dup (fname); absolute_fname[fname - absolute_fname] = '\0'; symlink_name = g_strconcat (absolute_fname, ".#", fname_copy, (char *) NULL); g_free (fname_copy); diff --git a/edit/syntax.c b/edit/syntax.c index 23e8b6ccd..fd821223b 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -30,9 +30,10 @@ #include #include #include - #include +#include + #include "../src/global.h" #include "edit.h" @@ -667,7 +668,7 @@ static FILE *open_include_file (const char *filename) FILE *f; syntax_g_free (error_file_name); - error_file_name = g_strdup (filename); + error_file_name = mhl_str_dup (filename); if (*filename == PATH_SEP) return fopen (filename, "r"); @@ -773,8 +774,8 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) } a++; c = r[0] = g_malloc0 (sizeof (struct context_rule)); - c->left = g_strdup (" "); - c->right = g_strdup (" "); + c->left = mhl_str_dup (" "); + c->right = mhl_str_dup (" "); num_contexts = 0; } else { /* Terminate previous context. */ @@ -787,14 +788,14 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) check_a; if (!strcmp (*a, "whole")) { a++; - c->whole_word_chars_left = g_strdup (whole_left); - c->whole_word_chars_right = g_strdup (whole_right); + c->whole_word_chars_left = mhl_str_dup (whole_left); + c->whole_word_chars_right = mhl_str_dup (whole_right); } else if (!strcmp (*a, "wholeleft")) { a++; - c->whole_word_chars_left = g_strdup (whole_left); + c->whole_word_chars_left = mhl_str_dup (whole_left); } else if (!strcmp (*a, "wholeright")) { a++; - c->whole_word_chars_right = g_strdup (whole_right); + c->whole_word_chars_right = mhl_str_dup (whole_right); } check_a; if (!strcmp (*a, "linestart")) { @@ -802,14 +803,14 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) c->line_start_left = 1; } check_a; - c->left = g_strdup (*a++); + c->left = mhl_str_dup (*a++); check_a; if (!strcmp (*a, "linestart")) { a++; c->line_start_right = 1; } check_a; - c->right = g_strdup (*a++); + c->right = mhl_str_dup (*a++); c->first_left = *c->left; c->first_right = *c->right; } @@ -826,7 +827,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) g_strlcpy (last_fg, fg ? fg : "", sizeof (last_fg)); g_strlcpy (last_bg, bg ? bg : "", sizeof (last_bg)); c->keyword[0]->color = this_try_alloc_color_pair (fg, bg); - c->keyword[0]->keyword = g_strdup (" "); + c->keyword[0]->keyword = mhl_str_dup (" "); check_not_a; alloc_words_per_context = MAX_WORDS_PER_CONTEXT; @@ -852,14 +853,14 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) k = r[num_contexts - 1]->keyword[num_words] = g_malloc0 (sizeof (struct key_word)); if (!strcmp (*a, "whole")) { a++; - k->whole_word_chars_left = g_strdup (whole_left); - k->whole_word_chars_right = g_strdup (whole_right); + k->whole_word_chars_left = mhl_str_dup (whole_left); + k->whole_word_chars_right = mhl_str_dup (whole_right); } else if (!strcmp (*a, "wholeleft")) { a++; - k->whole_word_chars_left = g_strdup (whole_left); + k->whole_word_chars_left = mhl_str_dup (whole_left); } else if (!strcmp (*a, "wholeright")) { a++; - k->whole_word_chars_right = g_strdup (whole_right); + k->whole_word_chars_right = mhl_str_dup (whole_right); } check_a; if (!strcmp (*a, "linestart")) { @@ -870,7 +871,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) if (!strcmp (*a, "whole")) { break_a; } - k->keyword = g_strdup (*a++); + k->keyword = mhl_str_dup (*a++); k->first = *k->keyword; subst_defines (edit->defines, a, &args[1024]); fg = *a; @@ -910,12 +911,12 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) if ((argv = g_tree_lookup (edit->defines, key))) { mc_defines_destroy (NULL, argv, NULL); } else { - key = g_strdup (key); + key = mhl_str_dup (key); } argv = g_new (char *, argc - 1); g_tree_insert (edit->defines, key, argv); while (*a) { - *argv++ = g_strdup (*a++); + *argv++ = mhl_str_dup (*a++); }; *argv = NULL; } else { /* anything else is an error */ @@ -955,7 +956,7 @@ edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) for (j = 1; c->keyword[j]; j++) *p++ = c->keyword[j]->first; *p = '\0'; - c->keyword_first_chars = g_strdup (first_chars); + c->keyword_first_chars = mhl_str_dup (first_chars); } g_free (first_chars); @@ -1076,7 +1077,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, else abort (); } - (*pnames)[count++] = g_strdup (args[2]); + (*pnames)[count++] = mhl_str_dup (args[2]); (*pnames)[count] = NULL; } else if (type) { @@ -1118,7 +1119,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file, result = line_error; } else { syntax_g_free (edit->syntax_type); - edit->syntax_type = g_strdup (syntax_type); + edit->syntax_type = mhl_str_dup (syntax_type); /* if there are no rules then turn off syntax highlighting for speed */ if (!g && !edit->rules[1]) diff --git a/edit/usermap.c b/edit/usermap.c index af0f02343..914ba396c 100644 --- a/edit/usermap.c +++ b/edit/usermap.c @@ -26,11 +26,12 @@ #include #include #include - #include #include #include +#include + #include "../src/global.h" #include "edit.h" @@ -502,7 +503,7 @@ cmd_label(config_t *cfg, int argc, char *argv[]) } keymap_add(cfg->keymap, KEY_F(fn), cmd->val); - cfg->labels[fn - 1] = g_strdup(label); + cfg->labels[fn - 1] = mhl_str_dup(label); return TRUE; } @@ -550,7 +551,7 @@ parse_file(config_t *cfg, const char *file, const command_t *cmd) } if (!(c->handler(cfg, args->len, argv))) { - char *ss = g_strdup(error_msg); + char *ss = mhl_str_dup(error_msg); snprintf(error_msg, sizeof(error_msg), _("%s:%d: %s"), file, line, ss); g_free(ss); diff --git a/src/boxes.c b/src/boxes.c index 5c66f3d2b..ad9fe6a56 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -27,10 +27,11 @@ #include #include #include - #include #include +#include + #include "global.h" #include "tty.h" #include "win.h" /* Our window tools */ @@ -227,14 +228,14 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n p = get_nth_panel_name (num); panel = g_new (WPanel, 1); panel->list_type = list_full; - panel->user_format = g_strdup (DEFAULT_USER_FORMAT); + panel->user_format = mhl_str_dup (DEFAULT_USER_FORMAT); panel->user_mini_status = 0; for (i = 0; i < LIST_TYPES; i++) - panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT); + panel->user_status_format[i] = mhl_str_dup (DEFAULT_USER_FORMAT); section = g_strconcat ("Temporal:", p, (char *) NULL); if (!profile_has_section (section, profile_name)) { g_free (section); - section = g_strdup (p); + section = mhl_str_dup (p); } panel_load_setup (panel, section); g_free (section); @@ -257,8 +258,8 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n if (dd->ret_value != B_CANCEL){ result = my_radio->sel; - *userp = g_strdup (user->buffer); - *minip = g_strdup (status->buffer); + *userp = mhl_str_dup (user->buffer); + *minip = mhl_str_dup (status->buffer); *use_msformat = check_status->state & C_BOOL; } destroy_dlg (dd); @@ -691,7 +692,7 @@ tree_box (const char *current_dir) run_dlg (dlg); if (dlg->ret_value == B_ENTER) - val = g_strdup (tree_selected_name (mytree)); + val = mhl_str_dup (tree_selected_name (mytree)); else val = 0; @@ -1113,11 +1114,11 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, default: return_value = g_new (struct smb_authinfo, 1); if (return_value) { - return_value->host = g_strdup (host); - return_value->share = g_strdup (share); - return_value->domain = g_strdup (in_domain->buffer); - return_value->user = g_strdup (in_user->buffer); - return_value->password = g_strdup (in_password->buffer); + return_value->host = mhl_str_dup (host); + return_value->share = mhl_str_dup (share); + return_value->domain = mhl_str_dup (in_domain->buffer); + return_value->user = mhl_str_dup (in_user->buffer); + return_value->password = mhl_str_dup (in_password->buffer); } } diff --git a/src/charsets.c b/src/charsets.c index 5666c23e3..142fcabf5 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -86,12 +86,12 @@ load_codepages_list (void) goto fail; if (strcmp (buf, "default") == 0) { - default_codepage = g_strdup (p); + default_codepage = mhl_str_dup (p); continue; } - codepages[n_codepages].id = g_strdup (buf); - codepages[n_codepages].name = g_strdup (p); + codepages[n_codepages].id = mhl_str_dup (buf); + codepages[n_codepages].name = mhl_str_dup (p); ++n_codepages; } diff --git a/src/cmd.c b/src/cmd.c index 84f6e071a..f897cc583 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -23,7 +23,6 @@ #include #include #include - #include #include #ifdef HAVE_MMAP @@ -34,6 +33,8 @@ #endif #include +#include + #include "global.h" #include "cmd.h" /* Our definitions */ #include "fileopctx.h" /* file_op_context_new() */ @@ -369,7 +370,7 @@ mkdir_cmd (void) return; if (dir[0] == '/' || dir[0] == '~') - absdir = g_strdup (dir); + absdir = mhl_str_dup (dir); else absdir = concat_dir_and_file (current_panel->cwd, dir); @@ -611,7 +612,7 @@ menu_edit_cmd (int where) switch (dir) { case 0: - buffer = g_strdup (where ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU); + buffer = mhl_str_dup (where ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU); check_for_default (menufile, buffer); break; @@ -934,7 +935,7 @@ do_link (int symbolic_link, const char *fname) if (get_other_type () == view_listing) { d = concat_dir_and_file (other_panel->cwd, fname); } else { - d = g_strdup (fname); + d = mhl_str_dup (fname); } symlink_dialog (s, d, &dest, &src); @@ -1053,7 +1054,7 @@ char *guess_message_value (void) if (locale == NULL) locale = ""; - return g_strdup (locale); + return mhl_str_dup (locale); } /* @@ -1071,7 +1072,7 @@ get_random_hint (int force) /* Do not change hints more often than one minute */ gettimeofday (&tv, NULL); if (!force && !(tv.tv_sec > last_sec + 60)) - return g_strdup (""); + return mhl_str_dup (""); last_sec = tv.tv_sec; data = load_mc_home_file (MC_HINT, NULL); @@ -1092,7 +1093,7 @@ get_random_hint (int force) eol = strchr (&data[start], '\n'); if (eol) *eol = 0; - result = g_strdup (&data[start]); + result = mhl_str_dup (&data[start]); g_free (data); return result; } diff --git a/src/color.c b/src/color.c index 1ef19d704..96059c6d5 100644 --- a/src/color.c +++ b/src/color.c @@ -22,6 +22,8 @@ #include #include +#include + #include "global.h" #include "tty.h" #include "setup.h" /* For the externs */ @@ -226,7 +228,7 @@ static void configure_colors_string (const char *the_color_string) if (!the_color_string) return; - p = color_string = g_strdup (the_color_string); + p = color_string = mhl_str_dup (the_color_string); while (color_string && *color_string){ while (*color_string == ' ' || *color_string == '\t') color_string++; @@ -395,8 +397,8 @@ try_alloc_color_pair (const char *fg, const char *bg) p->next = g_new (struct colors_avail, 1); p = p->next; p->next = 0; - p->fg = fg ? g_strdup (fg) : 0; - p->bg = bg ? g_strdup (bg) : 0; + p->fg = fg ? mhl_str_dup (fg) : 0; + p->bg = bg ? mhl_str_dup (bg) : 0; if (!fg) /* Index in color_map array = COLOR_INDEX - 1 */ fg = color_map[EDITOR_NORMAL_COLOR_INDEX - 1].fg; @@ -434,8 +436,8 @@ try_alloc_color_pair (const char *fg, const char *bg) p->next = g_new (struct colors_avail, 1); p = p->next; p->next = 0; - p->fg = fg ? g_strdup (fg) : 0; - p->bg = bg ? g_strdup (bg) : 0; + p->fg = fg ? mhl_str_dup (fg) : 0; + p->bg = bg ? mhl_str_dup (bg) : 0; if (!fg) /* Index in color_map array = COLOR_INDEX - 1 */ fg_index = color_map[EDITOR_NORMAL_COLOR_INDEX - 1].fg; diff --git a/src/command.c b/src/command.c index d118c03c7..49cf09c38 100644 --- a/src/command.c +++ b/src/command.c @@ -27,6 +27,8 @@ #include #include +#include + #include "global.h" /* home_dir */ #include "tty.h" #include "widget.h" /* WInput */ @@ -111,7 +113,7 @@ examine_cd (char *path) /* CDPATH handling */ if (*q != PATH_SEP && !result) { - char * const cdpath = g_strdup (getenv ("CDPATH")); + char * const cdpath = mhl_str_dup (getenv ("CDPATH")); char *p = cdpath; if (p == NULL) c = 0; @@ -182,7 +184,7 @@ void do_cd_command (char *cmd) } } else if (!examine_cd (&cmd [3])) { - char *d = strip_password (g_strdup (&cmd [3]), 1); + char *d = strip_password (mhl_str_dup (&cmd [3]), 1); message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "), d, unix_error_string (errno)); g_free (d); diff --git a/src/complete.c b/src/complete.c index 1742b85be..4fcd088bc 100644 --- a/src/complete.c +++ b/src/complete.c @@ -26,11 +26,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "tty.h" #include "win.h" @@ -72,11 +73,11 @@ filename_completion_function (char *text, int state) g_free (users_dirname); if ((*text) && (temp = strrchr (text, PATH_SEP))){ - filename = g_strdup (++temp); + filename = mhl_str_dup (++temp); dirname = g_strndup (text, temp - text); } else { - dirname = g_strdup ("."); - filename = g_strdup (text); + dirname = mhl_str_dup ("."); + filename = mhl_str_dup (text); } /* We aren't done yet. We also support the "~user" syntax. */ @@ -428,7 +429,7 @@ command_completion_function (char *text, int state) words = bash_reserved; phase = 0; text_len = strlen (text); - if (!path && (path = g_strdup (getenv ("PATH"))) != NULL) { + if (!path && (path = mhl_str_dup (getenv ("PATH"))) != NULL) { p = path; path_end = strchr (p, 0); while ((p = strchr (p, PATH_ENV_SEP))) { @@ -450,7 +451,7 @@ command_completion_function (char *text, int state) case 0: /* Reserved words */ while (*words) { if (!strncmp (*words, text, text_len)) - return g_strdup (*(words++)); + return mhl_str_dup (*(words++)); words++; } phase++; @@ -458,7 +459,7 @@ command_completion_function (char *text, int state) case 1: /* Builtin commands */ while (*words) { if (!strncmp (*words, text, text_len)) - return g_strdup (*(words++)); + return mhl_str_dup (*(words++)); words++; } phase++; @@ -498,7 +499,7 @@ command_completion_function (char *text, int state) } if ((p = strrchr (found, PATH_SEP)) != NULL) { p++; - p = g_strdup (p); + p = mhl_str_dup (p); g_free (found); return p; } @@ -634,7 +635,7 @@ try_complete (char *text, int *start, int *end, int flags) ignore_filenames = 0; c = text [*end]; text [*end] = 0; - word = g_strdup (text + *start); + word = mhl_str_dup (text + *start); text [*end] = c; /* Determine if this could be a command word. It is if it appears at @@ -725,7 +726,7 @@ try_complete (char *text, int *start, int *end, int flags) if (!strncmp (p, "cd", 2)) for (p += 2; *p && p < q && (*p == ' ' || *p == '\t'); p++); if (p == q){ - char * const cdpath_ref = g_strdup (getenv ("CDPATH")); + char * const cdpath_ref = mhl_str_dup (getenv ("CDPATH")); char *cdpath = cdpath_ref; char c, *s, *r; diff --git a/src/dialog.c b/src/dialog.c index f8467b9d6..a07628801 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -24,6 +24,8 @@ #include #include +#include + #include "global.h" #include "tty.h" #include "mouse.h" @@ -216,7 +218,7 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set, /* Strip existing spaces, add one space before and after the title */ if (title) { char *t; - t = g_strstrip (g_strdup (title)); + t = g_strstrip (mhl_str_dup (title)); new_d->title = g_strconcat (" ", t, " ", (char *) NULL); g_free (t); } diff --git a/src/dir.c b/src/dir.c index 847af6698..c98271af1 100644 --- a/src/dir.c +++ b/src/dir.c @@ -22,9 +22,10 @@ #include #include #include - #include +#include + #include "global.h" #include "tty.h" #include "dir.h" @@ -273,7 +274,7 @@ add_dotdot_to_list (dir_list *list, int index) memset (&(list->list) [index], 0, sizeof(file_entry)); (list->list) [index].fnamelen = 2; - (list->list) [index].fname = g_strdup (".."); + (list->list) [index].fname = mhl_str_dup (".."); (list->list) [index].f.link_to_dir = 0; (list->list) [index].f.stale_link = 0; (list->list) [index].f.dir_size_computed = 0; @@ -420,7 +421,7 @@ do_load_dir (const char *path, dir_list *list, sortfn *sort, int reverse, return next_free; } list->list[next_free].fnamelen = NLENGTH (dp); - list->list[next_free].fname = g_strdup (dp->d_name); + list->list[next_free].fname = mhl_str_dup (dp->d_name); list->list[next_free].f.marked = 0; list->list[next_free].f.link_to_dir = link_to_dir; list->list[next_free].f.stale_link = stale_link; @@ -572,7 +573,7 @@ do_reload_dir (const char *path, dir_list *list, sortfn *sort, int count, } list->list[next_free].fnamelen = NLENGTH (dp); - list->list[next_free].fname = g_strdup (dp->d_name); + list->list[next_free].fname = mhl_str_dup (dp->d_name); list->list[next_free].f.link_to_dir = link_to_dir; list->list[next_free].f.stale_link = stale_link; list->list[next_free].f.dir_size_computed = 0; diff --git a/src/ecs.c b/src/ecs.c index 8c7582761..2b0df7226 100644 --- a/src/ecs.c +++ b/src/ecs.c @@ -27,6 +27,8 @@ #include #include +#include + #include "global.h" #include "ecs.h" @@ -53,7 +55,7 @@ extern gboolean ecs_mbstr_to_str(ecs_char **ret_str, const char *s) *ret_str = g_renew(ecs_char, str, len + 1); return TRUE; #else - *ret_str = g_strdup(s); + *ret_str = mhl_str_dup(s); return TRUE; #endif } @@ -77,7 +79,7 @@ extern gboolean ecs_str_to_mbstr(char **ret_str, const ecs_char *s) *ret_str = g_renew(char, str, len + 1); return TRUE; #else - *ret_str = g_strdup(s); + *ret_str = mhl_str_dup(s); return TRUE; #endif } diff --git a/src/execute.c b/src/execute.c index 970a1772c..913a48693 100644 --- a/src/execute.c +++ b/src/execute.c @@ -19,6 +19,8 @@ #include +#include + #include "global.h" #include "tty.h" #include "win.h" @@ -99,7 +101,7 @@ do_execute (const char *shell, const char *command, int flags) char *old_vfs_dir = 0; if (!vfs_current_is_local ()) - old_vfs_dir = g_strdup (vfs_get_current_dir ()); + old_vfs_dir = mhl_str_dup (vfs_get_current_dir ()); #endif /* USE_VFS */ save_cwds_stat (); @@ -362,7 +364,7 @@ execute_with_vfs_arg (const char *command, const char *filename) * the command, so make a copy. Smarter VFS code would make the code * below unnecessary. */ - fn = g_strdup (filename); + fn = mhl_str_dup (filename); mc_stat (localcopy, &st); mtime = st.st_mtime; do_execute (command, localcopy, EXECUTE_INTERNAL); diff --git a/src/ext.c b/src/ext.c index 14d888fa3..58da08221 100644 --- a/src/ext.c +++ b/src/ext.c @@ -25,9 +25,10 @@ #include #include #include - #include +#include + #include "global.h" #include "tty.h" #include "user.h" @@ -590,7 +591,7 @@ regex_command (const char *filename, const char *action, int *move_dir) * we get filename as a pointer from current_panel->dir). */ if (p < q) { - char *filename_copy = g_strdup (filename); + char *filename_copy = mhl_str_dup (filename); exec_extension (filename_copy, r + 1, move_dir, view_at_line_number); diff --git a/src/file.c b/src/file.c index 5606691f1..ec56d783b 100644 --- a/src/file.c +++ b/src/file.c @@ -45,7 +45,6 @@ #include #include #include - #include #include #include @@ -236,7 +235,7 @@ do_transform_source (FileOpContext *ctx, const char *source) static const char * transform_source (FileOpContext *ctx, const char *source) { - char *s = g_strdup (source); + char *s = mhl_str_dup (source); char *q; const char *p; @@ -383,7 +382,7 @@ make_symlink (FileOpContext *ctx, const char *src_path, const char *dst_path) if (r) { p = g_strndup (src_path, r - src_path + 1); if (*dst_path == PATH_SEP) - q = g_strdup (dst_path); + q = mhl_str_dup (dst_path); else q = g_strconcat (p, dst_path, (char *) NULL); s = strrchr (q, PATH_SEP); @@ -893,7 +892,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, return FILE_CONT; } } - dest_dir = g_strdup (d); + dest_dir = mhl_str_dup (d); } else { /* * If the destination directory exists, we want to copy the whole @@ -915,7 +914,7 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, if (toplevel && ctx->dive_into_subdirs) { dest_dir = concat_dir_and_file (d, x_basename (s)); } else { - dest_dir = g_strdup (d); + dest_dir = mhl_str_dup (d); goto dont_mkdir; } } @@ -1159,9 +1158,9 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d, mc_stat (s, &sbuf); if (mc_stat (d, &dbuf)) - destdir = g_strdup (d); /* destination doesn't exist */ + destdir = mhl_str_dup (d); /* destination doesn't exist */ else if (!ctx->dive_into_subdirs) { - destdir = g_strdup (d); + destdir = mhl_str_dup (d); move_over = 1; } else destdir = concat_dir_and_file (d, x_basename (s)); @@ -1853,11 +1852,11 @@ panel_operate (void *source_panel, FileOperation operation, invalid data. */ if (dest) { if (mc_setctl (dest, VFS_SETCTL_STALE_DATA, (void *) 1)) - save_dest = g_strdup (dest); + save_dest = mhl_str_dup (dest); } if (panel->cwd) { if (mc_setctl (panel->cwd, VFS_SETCTL_STALE_DATA, (void *) 1)) - save_cwd = g_strdup (panel->cwd); + save_cwd = mhl_str_dup (panel->cwd); } /* Now, let's do the job */ diff --git a/src/filegui.c b/src/filegui.c index 299d80f80..c2c71f5ee 100644 --- a/src/filegui.c +++ b/src/filegui.c @@ -48,11 +48,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "setup.h" /* verbose */ #include "dialog.h" /* do_refresh() */ @@ -881,7 +882,7 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, fmd_widgets[FMCB21].result = &ctx->dive_into_subdirs; /* filter out a possible password from def_text */ - def_text_secure = strip_password (g_strdup (def_text), 1); + def_text_secure = strip_password (mhl_str_dup (def_text), 1); /* Create the dialog */ @@ -971,14 +972,14 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, && ((!only_one && !is_wildcarded (ctx->dest_mask)) || (only_one && !mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode))))) - ctx->dest_mask = g_strdup ("*"); + ctx->dest_mask = mhl_str_dup ("*"); else { - ctx->dest_mask = g_strdup (ctx->dest_mask); + ctx->dest_mask = mhl_str_dup (ctx->dest_mask); *orig_mask = 0; } if (!*dest_dir) { g_free (dest_dir); - dest_dir = g_strdup ("./"); + dest_dir = mhl_str_dup ("./"); } if (val == B_USER) *do_background = 1; diff --git a/src/filenot.c b/src/filenot.c index f614ce1e6..25e6a8a6e 100644 --- a/src/filenot.c +++ b/src/filenot.c @@ -27,6 +27,8 @@ #include #include +#include + #include "global.h" static char * @@ -35,7 +37,7 @@ get_absolute_name (const char *file) char dir[MC_MAXPATHLEN]; if (file[0] == PATH_SEP) - return g_strdup (file); + return mhl_str_dup (file); mc_get_current_wd (dir, MC_MAXPATHLEN); return concat_dir_and_file (dir, file); } diff --git a/src/find.c b/src/find.c index 9fce56555..58d700bc2 100644 --- a/src/find.c +++ b/src/find.c @@ -25,9 +25,10 @@ #include #include #include - #include +#include + #include "global.h" #include "tty.h" #include "win.h" @@ -247,11 +248,11 @@ find_parameters (char **start_dir, char **pattern, char **content) find_par_start: if (!in_start_dir) - in_start_dir = g_strdup ("."); + in_start_dir = mhl_str_dup ("."); if (!in_start_name) - in_start_name = g_strdup (easy_patterns ? "*" : "."); + in_start_name = mhl_str_dup (easy_patterns ? "*" : "."); if (!in_contents) - in_contents = g_strdup (""); + in_contents = mhl_str_dup (""); find_dlg = create_dlg (0, 0, FIND_Y, FIND_X, dialog_colors, @@ -301,7 +302,7 @@ find_parameters (char **start_dir, char **pattern, char **content) break; case B_TREE: - temp_dir = g_strdup (in_start->buffer); + temp_dir = mhl_str_dup (in_start->buffer); case_sensitive = case_sense->state & C_BOOL; find_regex_flag = find_regex_cbox->state & C_BOOL; find_recursively = recursively_cbox->state & C_BOOL; @@ -309,7 +310,7 @@ find_parameters (char **start_dir, char **pattern, char **content) g_free (in_start_dir); if (strcmp (temp_dir, ".") == 0) { g_free (temp_dir); - temp_dir = g_strdup (current_panel->cwd); + temp_dir = mhl_str_dup (current_panel->cwd); } in_start_dir = tree_box (temp_dir); if (in_start_dir) @@ -323,8 +324,8 @@ find_parameters (char **start_dir, char **pattern, char **content) default: g_free (in_contents); if (in_with->buffer[0]) { - *content = g_strdup (in_with->buffer); - in_contents = g_strdup (*content); + *content = mhl_str_dup (in_with->buffer); + in_contents = mhl_str_dup (*content); } else { *content = in_contents = NULL; r = 0; @@ -334,13 +335,13 @@ 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; return_value = 1; - *start_dir = g_strdup (in_start->buffer); - *pattern = g_strdup (in_name->buffer); + *start_dir = mhl_str_dup (in_start->buffer); + *pattern = mhl_str_dup (in_name->buffer); g_free (in_start_dir); - in_start_dir = g_strdup (*start_dir); + in_start_dir = mhl_str_dup (*start_dir); g_free (in_start_name); - in_start_name = g_strdup (*pattern); + in_start_name = mhl_str_dup (*pattern); } destroy_dlg (find_dlg); @@ -387,11 +388,11 @@ insert_file (const char *dir, const char *file) if (old_dir){ if (strcmp (old_dir, dir)){ g_free (old_dir); - old_dir = g_strdup (dir); + old_dir = mhl_str_dup (dir); dirname = add_to_list (dir, NULL); } } else { - old_dir = g_strdup (dir); + old_dir = mhl_str_dup (dir); dirname = add_to_list (dir, NULL); } @@ -750,7 +751,7 @@ make_fullname (const char *dirname, const char *filename) { if (strcmp(dirname, ".") == 0 || strcmp(dirname, "."PATH_SEP_STR) == 0) - return g_strdup (filename); + return mhl_str_dup (filename); if (strncmp(dirname, "."PATH_SEP_STR, 2) == 0) return concat_dir_and_file (dirname + 2, filename); return concat_dir_and_file (dirname, filename); @@ -981,9 +982,9 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname, get_list_info (&file_tmp, &dir_tmp); if (dir_tmp) - *dirname = g_strdup (dir_tmp); + *dirname = mhl_str_dup (dir_tmp); if (file_tmp) - *filename = g_strdup (file_tmp); + *filename = mhl_str_dup (file_tmp); if (return_value == B_PANELIZE && *filename) { int status, link_to_dir, stale_link; diff --git a/src/help.c b/src/help.c index 5ce68685b..3c157656b 100644 --- a/src/help.c +++ b/src/help.c @@ -45,10 +45,11 @@ #include #include - #include #include +#include + #include "global.h" #include "tty.h" #include "color.h" @@ -104,7 +105,7 @@ static const char * search_string (const char *start, const char *text) { const char *result = NULL; - char *local_text = g_strdup (text); + char *local_text = mhl_str_dup (text); char *d = local_text; const char *e = start; diff --git a/src/hotlist.c b/src/hotlist.c index 90678fe00..083542ba4 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -32,11 +32,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "tty.h" /* COLS */ #include "color.h" /* dialog_colors */ @@ -933,7 +934,7 @@ static void add_new_entry_cmd (void) int ret; /* Take current directory as default value for input fields */ - to_free = title = url = strip_password (g_strdup (current_panel->cwd), 1); + to_free = title = url = strip_password (mhl_str_dup (current_panel->cwd), 1); ret = add_new_entry_input (_("New hotlist entry"), _("Directory label"), _("Directory path"), "[Hotlist]", &title, &url); @@ -1038,7 +1039,7 @@ void add2hotlist_cmd (void) char *prompt, *label; const char *cp = _("Label for \"%s\":"); int l = strlen (cp); - char *label_string = g_strdup (current_panel->cwd); + char *label_string = mhl_str_dup (current_panel->cwd); strip_password (label_string, 1); @@ -1155,9 +1156,9 @@ char *hotlist_cmd (int vfs_or_hotlist) case B_ENTER: if (l_hotlist->current->data) { struct hotlist *hlp = (struct hotlist*) l_hotlist->current->data; - target = g_strdup (hlp->directory); + target = mhl_str_dup (hlp->directory); } else - target = g_strdup (l_hotlist->current->text); + target = mhl_str_dup (l_hotlist->current->text); break; } @@ -1181,7 +1182,7 @@ load_group (struct hotlist *grp) while (profile_keys){ profile_keys = profile_iterator_next (profile_keys, &key, &value); - add2hotlist (g_strdup (value), g_strdup (key), HL_TYPE_GROUP, 0); + add2hotlist (mhl_str_dup (value), mhl_str_dup (key), HL_TYPE_GROUP, 0); } g_free (group_section); @@ -1189,7 +1190,7 @@ load_group (struct hotlist *grp) while (profile_keys){ profile_keys = profile_iterator_next (profile_keys, &key, &value); - add2hotlist (g_strdup (value),g_strdup (key), HL_TYPE_ENTRY, 0); + add2hotlist (mhl_str_dup (value),mhl_str_dup (key), HL_TYPE_ENTRY, 0); } for (current = grp->head; current; current = current->next) @@ -1331,22 +1332,22 @@ hot_load_group (struct hotlist * grp) switch (tkn) { case TKN_GROUP: CHECK_TOKEN(TKN_STRING); - new_grp = add2hotlist (g_strdup (tkn_buf), 0, HL_TYPE_GROUP, 0); + new_grp = add2hotlist (mhl_str_dup (tkn_buf), 0, HL_TYPE_GROUP, 0); SKIP_TO_EOL; hot_load_group (new_grp); current_group = grp; break; case TKN_ENTRY: CHECK_TOKEN(TKN_STRING); - label = g_strdup (tkn_buf); + label = mhl_str_dup (tkn_buf); CHECK_TOKEN(TKN_URL); CHECK_TOKEN(TKN_STRING); - url = g_strdup (tkn_buf); + url = mhl_str_dup (tkn_buf); add2hotlist (label, url, HL_TYPE_ENTRY, 0); SKIP_TO_EOL; break; case TKN_COMMENT: - label = g_strdup (tkn_buf); + label = mhl_str_dup (tkn_buf); add2hotlist (label, 0, HL_TYPE_COMMENT, 0); break; case TKN_EOF: @@ -1379,22 +1380,22 @@ hot_load_file (struct hotlist * grp) switch (tkn) { case TKN_GROUP: CHECK_TOKEN(TKN_STRING); - new_grp = add2hotlist (g_strdup (tkn_buf), 0, HL_TYPE_GROUP, 0); + new_grp = add2hotlist (mhl_str_dup (tkn_buf), 0, HL_TYPE_GROUP, 0); SKIP_TO_EOL; hot_load_group (new_grp); current_group = grp; break; case TKN_ENTRY: CHECK_TOKEN(TKN_STRING); - label = g_strdup (tkn_buf); + label = mhl_str_dup (tkn_buf); CHECK_TOKEN(TKN_URL); CHECK_TOKEN(TKN_STRING); - url = g_strdup (tkn_buf); + url = mhl_str_dup (tkn_buf); add2hotlist (label, url, HL_TYPE_ENTRY, 0); SKIP_TO_EOL; break; case TKN_COMMENT: - label = g_strdup (tkn_buf); + label = mhl_str_dup (tkn_buf); add2hotlist (label, 0, HL_TYPE_COMMENT, 0); break; case TKN_EOL: @@ -1451,12 +1452,12 @@ load_hotlist (void) hotlist = new_hotlist (); hotlist->type = HL_TYPE_GROUP; - hotlist->label = g_strdup (_(" Top level group ")); + hotlist->label = mhl_str_dup (_(" Top level group ")); hotlist->up = hotlist; /* * compatibility :-( */ - hotlist->directory = g_strdup ("Hotlist"); + hotlist->directory = mhl_str_dup ("Hotlist"); if ((hotlist_file = fopen (hotlist_file_name, "r")) == 0) { int result; @@ -1611,6 +1612,6 @@ add_dotdot_to_list (void) { if (current_group != hotlist) { if (hotlist_has_dot_dot != 0) - add2hotlist (g_strdup (".."), g_strdup (".."), HL_TYPE_DOTDOT, 0); + add2hotlist (mhl_str_dup (".."), mhl_str_dup (".."), HL_TYPE_DOTDOT, 0); } } diff --git a/src/key.c b/src/key.c index d531541f5..8e306971e 100644 --- a/src/key.c +++ b/src/key.c @@ -29,10 +29,11 @@ #include #include #include - #include #include +#include + #include "global.h" #include "tty.h" #include "mouse.h" @@ -1232,7 +1233,7 @@ char *learn_key (void) keypad(stdscr, TRUE); nodelay (stdscr, FALSE); *p = 0; - return g_strdup (buffer); + return mhl_str_dup (buffer); } /* xterm and linux console only: set keypad to numeric or application diff --git a/src/layout.c b/src/layout.c index 8bd8e7ec2..b802c6e37 100644 --- a/src/layout.c +++ b/src/layout.c @@ -26,9 +26,9 @@ #include #include #include - #include #include + /* * If TIOCGWINSZ supported, make it available here, because window- * resizing code depends on it... @@ -41,6 +41,8 @@ #endif #include +#include + #include "global.h" #include "tty.h" /* COLS */ #include "win.h" @@ -1051,13 +1053,13 @@ void swap_panels () if (panels [0].type == view_listing) { if (!strcmp (panel1->panel_name, get_nth_panel_name (0))) { g_free (panel1->panel_name); - panel1->panel_name = g_strdup (get_nth_panel_name (1)); + panel1->panel_name = mhl_str_dup (get_nth_panel_name (1)); } } if (panels [1].type == view_listing) { if (!strcmp (panel2->panel_name, get_nth_panel_name (1))) { g_free (panel2->panel_name); - panel2->panel_name = g_strdup (get_nth_panel_name (0)); + panel2->panel_name = mhl_str_dup (get_nth_panel_name (0)); } } diff --git a/src/listmode.c b/src/listmode.c index 69e499d70..84af11321 100644 --- a/src/listmode.c +++ b/src/listmode.c @@ -26,11 +26,12 @@ #include #include - #include #include #include +#include + #include "global.h" #include "tty.h" #include "win.h" @@ -287,7 +288,7 @@ listmode_edit (char *oldlistformat) char *s; Dlg_head *listmode_dlg; - s = g_strdup (oldlistformat); + s = mhl_str_dup (oldlistformat); listmode_dlg = init_listmode (s); g_free (s); diff --git a/src/main.c b/src/main.c index 6ba72e0c1..39687f51f 100644 --- a/src/main.c +++ b/src/main.c @@ -29,11 +29,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "tty.h" #include "dir.h" @@ -335,7 +336,7 @@ update_one_panel_widget (WPanel *panel, int force_update, /* If current_file == -1 (an invalid pointer) then preserve selection */ if (current_file == UP_KEEPSEL) { free_pointer = 1; - my_current_file = g_strdup (panel->dir.list[panel->selected].fname); + my_current_file = mhl_str_dup (panel->dir.list[panel->selected].fname); current_file = my_current_file; } else free_pointer = 0; @@ -532,7 +533,7 @@ directory_history_add (struct WPanel *panel, const char *dir) { char *tmp; - tmp = g_strdup (dir); + tmp = mhl_str_dup (dir); strip_password (tmp, 1); panel->dir_history = list_append_unique (panel->dir_history, tmp); @@ -574,7 +575,7 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type) new_dir++; } - olddir = g_strdup (panel->cwd); + olddir = mhl_str_dup (panel->cwd); new_dir = translated_url = vfs_translate_url (new_dir); /* Convert *new_path to a suitable pathname, handle ~user */ @@ -1612,7 +1613,7 @@ update_xterm_title_path (void) char *p, *s; if (xterm_flag && xterm_title) { - p = s = g_strdup (strip_home_and_password (current_panel->cwd)); + p = s = mhl_str_dup (strip_home_and_password (current_panel->cwd)); do { if (!is_printable ((unsigned char) *s)) *s = '?'; @@ -1686,7 +1687,7 @@ prepend_cwd_on_local (const char *filename) if (vfs_file_is_local (filename)) { if (*filename == PATH_SEP) /* an absolute pathname */ - return g_strdup (filename); + return mhl_str_dup (filename); d = g_malloc (MC_MAXPATHLEN + strlen (filename) + 2); mc_get_current_wd (d, MC_MAXPATHLEN); l = strlen (d); @@ -1695,7 +1696,7 @@ prepend_cwd_on_local (const char *filename) canonicalize_pathname (d); return d; } else - return g_strdup (filename); + return mhl_str_dup (filename); } static int @@ -1753,7 +1754,7 @@ do_nc (void) /* destroy_dlg destroys even current_panel->cwd, so we have to save a copy :) */ if (last_wd_file && vfs_current_is_local ()) { - last_wd_string = g_strdup (current_panel->cwd); + last_wd_string = mhl_str_dup (current_panel->cwd); } done_mc (); @@ -1772,7 +1773,7 @@ OS_Setup (void) struct passwd *pwd; pwd = getpwuid (geteuid ()); if (pwd != NULL) - shell = g_strdup (pwd->pw_shell); + shell = mhl_str_dup (pwd->pw_shell); } if (!shell || !*shell) shell = "/bin/sh"; @@ -1780,9 +1781,9 @@ OS_Setup (void) /* This is the directory, where MC was installed, on Unix this is DATADIR */ /* and can be overriden by the MC_DATADIR environment variable */ if ((mc_libdir = getenv ("MC_DATADIR")) != NULL) { - mc_home = g_strdup (mc_libdir); + mc_home = mhl_str_dup (mc_libdir); } else { - mc_home = g_strdup (DATADIR); + mc_home = mhl_str_dup (DATADIR); } } @@ -2097,12 +2098,12 @@ handle_args (int argc, char *argv[]) } } } - edit_one_file = g_strdup (tmp); + edit_one_file = mhl_str_dup (tmp); } } } else if (!STRNCOMP (base, "mcv", 3) || !STRCOMP (base, "view")) { if (tmp) - view_one_file = g_strdup (tmp); + view_one_file = mhl_str_dup (tmp); else { fputs ("No arguments given to the viewer\n", stderr); exit (1); @@ -2110,9 +2111,9 @@ handle_args (int argc, char *argv[]) } else { /* sets the current dir and the other dir */ if (tmp) { - this_dir = g_strdup (tmp); + this_dir = mhl_str_dup (tmp); if ((tmp = poptGetArg (ctx))) - other_dir = g_strdup (tmp); + other_dir = mhl_str_dup (tmp); } } diff --git a/src/menu.c b/src/menu.c index f291071a6..41bda66d1 100644 --- a/src/menu.c +++ b/src/menu.c @@ -21,9 +21,10 @@ #include #include #include - #include +#include + #include "global.h" #include "tty.h" #include "menu.h" @@ -81,10 +82,10 @@ create_menu (const char *name, menu_entry *entries, int count, const char *help_ } } - menu->name = g_strdup (name); + menu->name = mhl_str_dup (name); menu_scan_hotkey(menu); menu->start_x = 0; - menu->help_node = g_strdup (help_node); + menu->help_node = mhl_str_dup (help_node); return menu; } diff --git a/src/panelize.c b/src/panelize.c index f102812bf..26c61969f 100644 --- a/src/panelize.c +++ b/src/panelize.c @@ -25,11 +25,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "tty.h" /* attrset() */ #include "win.h" @@ -236,7 +237,7 @@ add2panelize_cmd (void) return; } - add2panelize (label, g_strdup (pname->buffer)); + add2panelize (label, mhl_str_dup (pname->buffer)); } } @@ -293,7 +294,7 @@ external_panelize (void) case B_ENTER: target = pname->buffer; if (target != NULL && *target) { - char *cmd = g_strdup (target); + char *cmd = mhl_str_dup (target); destroy_dlg (panelize_dlg); do_external_panelize (cmd); g_free (cmd); @@ -313,18 +314,18 @@ void load_panelize (void) profile_keys = profile_init_iterator (panelize_section, profile_name); - add2panelize (g_strdup (_("Other command")), g_strdup ("")); + add2panelize (mhl_str_dup (_("Other command")), mhl_str_dup ("")); if (!profile_keys){ - add2panelize (g_strdup (_("Find rejects after patching")), g_strdup ("find . -name \\*.rej -print")); - add2panelize (g_strdup (_("Find *.orig after patching")), g_strdup ("find . -name \\*.orig -print")); - add2panelize (g_strdup (_("Find SUID and SGID programs")), g_strdup ("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print")); + add2panelize (mhl_str_dup (_("Find rejects after patching")), mhl_str_dup ("find . -name \\*.rej -print")); + add2panelize (mhl_str_dup (_("Find *.orig after patching")), mhl_str_dup ("find . -name \\*.orig -print")); + add2panelize (mhl_str_dup (_("Find SUID and SGID programs")), mhl_str_dup ("find . \\( \\( -perm -04000 -a -perm +011 \\) -o \\( -perm -02000 -a -perm +01 \\) \\) -print")); return; } while (profile_keys){ profile_keys = profile_iterator_next (profile_keys, &key, &value); - add2panelize (g_strdup (key), g_strdup (value)); + add2panelize (mhl_str_dup (key), mhl_str_dup (value)); } } @@ -398,7 +399,7 @@ static void do_external_panelize (char *command) if (status == -1) break; list->list [next_free].fnamelen = strlen (name); - list->list [next_free].fname = g_strdup (name); + list->list [next_free].fname = mhl_str_dup (name); file_mark (current_panel, next_free, 0); list->list [next_free].f.link_to_dir = link_to_dir; list->list [next_free].f.stale_link = stale_link; diff --git a/src/profile.c b/src/profile.c index cbd60e536..05d774c23 100644 --- a/src/profile.c +++ b/src/profile.c @@ -26,9 +26,10 @@ #include #include #include - #include +#include + #include "global.h" #include "profile.h" @@ -168,7 +169,7 @@ static TSecHeader *load (const char *file) if (c == ']' || overflow){ *next = '\0'; next = CharBuffer; - SecHeader->AppName = g_strdup (CharBuffer); + SecHeader->AppName = mhl_str_dup (CharBuffer); state = IgnoreToEOL; } else *next++ = c; @@ -214,7 +215,7 @@ static TSecHeader *load (const char *file) *next = '\0'; SecHeader->Keys =g_new (TKeys, 1); SecHeader->Keys->link = temp; - SecHeader->Keys->KeyName = g_strdup (CharBuffer); + SecHeader->Keys->KeyName = mhl_str_dup (CharBuffer); state = KeyValue; next = CharBuffer; } else { @@ -265,8 +266,8 @@ static void new_key (TSecHeader *section, const char *KeyName, const char *Value TKeys *key; key = g_new (TKeys, 1); - key->KeyName = g_strdup (KeyName); - key->Value = g_strdup (Value); + key->KeyName = mhl_str_dup (KeyName); + key->Value = mhl_str_dup (Value); key->link = section->Keys; section->Keys = key; } @@ -284,7 +285,7 @@ GetSetProfileChar (int set, const char *AppName, const char *KeyName, if (!Current) { Current = g_new (TProfile, 1); Current->link = Base; - Current->FileName = g_strdup (FileName); + Current->FileName = mhl_str_dup (FileName); Current->Section = load (FileName); Base = Current; section = Current->Section; @@ -299,7 +300,7 @@ GetSetProfileChar (int set, const char *AppName, const char *KeyName, continue; if (set){ g_free (key->Value); - key->Value = g_strdup (Default); + key->Value = mhl_str_dup (Default); } return key->Value; } @@ -315,7 +316,7 @@ GetSetProfileChar (int set, const char *AppName, const char *KeyName, /* Non existent section */ if (set && Default){ section = g_new (TSecHeader, 1); - section->AppName = g_strdup (AppName); + section->AppName = mhl_str_dup (AppName); section->Keys = 0; new_key (section, KeyName, Default); section->link = Current->Section; @@ -483,7 +484,7 @@ void *profile_init_iterator (const char *appname, const char *file) if (!Current) { Current = g_new (TProfile, 1); Current->link = Base; - Current->FileName = g_strdup (file); + Current->FileName = mhl_str_dup (file); Current->Section = load (file); Base = Current; section = Current->Section; diff --git a/src/screen.c b/src/screen.c index a1ae53124..03effeee1 100644 --- a/src/screen.c +++ b/src/screen.c @@ -25,9 +25,10 @@ #include #include #include - #include +#include + #include "global.h" #include "tty.h" #include "dir.h" @@ -944,7 +945,7 @@ panel_save_name (WPanel *panel) /* If the program is shuting down */ if ((midnight_shutdown && auto_save_setup) || saving_setup) - return g_strdup (panel->panel_name); + return mhl_str_dup (panel->panel_name); else return g_strconcat ("Temporal:", panel->panel_name, (char *) NULL); } @@ -1029,18 +1030,18 @@ panel_new (const char *panel_name) panel->status_format = 0; panel->format_modified = 1; - panel->panel_name = g_strdup (panel_name); - panel->user_format = g_strdup (DEFAULT_USER_FORMAT); + panel->panel_name = mhl_str_dup (panel_name); + panel->user_format = mhl_str_dup (DEFAULT_USER_FORMAT); for (i = 0; i < LIST_TYPES; i++) - panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT); + panel->user_status_format[i] = mhl_str_dup (DEFAULT_USER_FORMAT); panel->search_buffer[0] = 0; panel->frame_size = frame_half; section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL); if (!profile_has_section (section, profile_name)) { g_free (section); - section = g_strdup (panel->panel_name); + section = mhl_str_dup (panel->panel_name); } panel_load_setup (panel, section); g_free (section); @@ -1320,7 +1321,7 @@ parse_display_format (WPanel *panel, const char *format, char **error, int issta break; } if (!found){ - char *tmp_format = g_strdup (format); + char *tmp_format = mhl_str_dup (format); int pos = min (8, strlen (format)); delete_format (home); @@ -1448,11 +1449,11 @@ set_panel_formats (WPanel *p) message( 1, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) ); if (retcode & 0x01){ g_free (p->user_format); - p->user_format = g_strdup (DEFAULT_USER_FORMAT); + p->user_format = mhl_str_dup (DEFAULT_USER_FORMAT); } if (retcode & 0x02){ g_free (p->user_status_format [p->list_type]); - p->user_status_format [p->list_type] = g_strdup (DEFAULT_USER_FORMAT); + p->user_status_format [p->list_type] = mhl_str_dup (DEFAULT_USER_FORMAT); } return retcode; @@ -2097,7 +2098,7 @@ chdir_to_readlink (WPanel *panel) p[1] = 0; } if (*buffer == PATH_SEP) - new_dir = g_strdup (buffer); + new_dir = mhl_str_dup (buffer); else new_dir = concat_dir_and_file (panel->cwd, buffer); @@ -2251,7 +2252,7 @@ panel_callback (Widget *w, widget_msg_t msg, int parm) current_panel = panel; panel->active = 1; if (mc_chdir (panel->cwd) != 0) { - char *cwd = strip_password (g_strdup (panel->cwd), 1); + char *cwd = strip_password (mhl_str_dup (panel->cwd), 1); message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "), cwd, unix_error_string (errno)); g_free(cwd); @@ -2463,7 +2464,7 @@ panel_re_sort (WPanel *panel) if (panel == NULL) return; - filename = g_strdup (selection (panel)->fname); + filename = mhl_str_dup (selection (panel)->fname); unselect_item (panel); do_sort (&panel->dir, panel->sort_type, panel->count-1, panel->reverse, panel->case_sensitive, panel->exec_first); @@ -2494,7 +2495,7 @@ panel_set_sort_order (WPanel *panel, sortfn *sort_order) if (sort_order == (sortfn *) unsorted){ char *current_file; - current_file = g_strdup (panel->dir.list [panel->selected].fname); + current_file = mhl_str_dup (panel->dir.list [panel->selected].fname); panel_reload (panel); try_to_select (panel, current_file); g_free (current_file); diff --git a/src/setup.c b/src/setup.c index e806f10ca..4e044acd8 100644 --- a/src/setup.c +++ b/src/setup.c @@ -20,10 +20,11 @@ #include #include - #include #include +#include + #include "global.h" #include "tty.h" #include "dir.h" @@ -413,14 +414,14 @@ panel_load_setup (WPanel *panel, const char *section) /* User formats */ g_free (panel->user_format); - panel->user_format = g_strdup (get_profile_string (section, "user_format", + panel->user_format = mhl_str_dup (get_profile_string (section, "user_format", DEFAULT_USER_FORMAT, profile_name)); for (i = 0; i < LIST_TYPES; i++){ g_free (panel->user_status_format [i]); g_snprintf (buffer, sizeof (buffer), "user_status%d", i); panel->user_status_format [i] = - g_strdup (get_profile_string (section, buffer, + mhl_str_dup (get_profile_string (section, buffer, DEFAULT_USER_FORMAT, profile_name)); } @@ -469,7 +470,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); + p = mhl_str_dup (buffer); g_free (buffer); return p; } @@ -594,7 +595,7 @@ load_anon_passwd () load_string ("Misc", "ftpfs_password", "", buffer, sizeof (buffer)); if (buffer [0]) - return g_strdup (buffer); + return mhl_str_dup (buffer); else return 0; } diff --git a/src/subshell.c b/src/subshell.c index 99cf28ce4..6c7fc3405 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -44,6 +44,8 @@ # include /* For I_PUSH */ #endif /* HAVE_STROPTS_H */ +#include + #include "global.h" #include "tty.h" /* LINES */ #include "panel.h" /* current_panel */ @@ -229,7 +231,7 @@ init_subshell_child (const char *pty_name) char sid_str[BUF_SMALL]; g_snprintf (sid_str, sizeof (sid_str), "MC_SID=%ld", (long) mc_sid); - putenv (g_strdup (sid_str)); + putenv (mhl_str_dup (sid_str)); } #endif /* HAVE_GETSID */ @@ -796,7 +798,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); + char *cwd = strip_password (mhl_str_dup (current_panel->cwd), 1); fprintf (stderr, _("Warning: Cannot change to %s.\n"), cwd); g_free (cwd); } diff --git a/src/treestore.c b/src/treestore.c index 426b0c289..483d7fac4 100644 --- a/src/treestore.c +++ b/src/treestore.c @@ -37,11 +37,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "treestore.h" #include "profile.h" @@ -134,7 +135,7 @@ tree_store_get(void) static char * decode(char *buffer) { - char *res = g_strdup(buffer); + char *res = mhl_str_dup(buffer); char *p, *q; for (p = q = res; *p; p++, q++) { @@ -443,7 +444,7 @@ tree_store_add_entry(const char *name) } /* Calculate attributes */ - new->name = g_strdup(name); + new->name = mhl_str_dup(name); len = strlen(new->name); new->sublevel = 0; for (i = 0; i < len; i++) @@ -471,7 +472,7 @@ tree_store_add_entry(const char *name) if (new->sublevel > 1) { /* Let's check if the parent directory is in the tree */ - char *parent = g_strdup(new->name); + char *parent = mhl_str_dup(new->name); int i; for (i = strlen(parent) - 1; i > 1; i--) { @@ -615,7 +616,7 @@ tree_store_mark_checked(const char *subname) if (flag != 0) { /* Doesn't exist -> add it */ current = tree_store_add_entry(name); - ts.add_queue = g_list_prepend(ts.add_queue, g_strdup(name)); + ts.add_queue = g_list_prepend(ts.add_queue, mhl_str_dup(name)); } g_free(name); @@ -660,12 +661,12 @@ tree_store_start_check(const char *path) return NULL; current = tree_store_add_entry(path); - ts.check_name = g_strdup(path); + ts.check_name = mhl_str_dup(path); return current; } - ts.check_name = g_strdup(path); + ts.check_name = mhl_str_dup(path); retval = current; @@ -737,7 +738,7 @@ process_special_dirs(GList ** special_dirs, char *file) "", buffer, 4096, file); s = buffer; while ((token = strtok(s, ",")) != NULL) { - *special_dirs = g_list_prepend(*special_dirs, g_strdup(token)); + *special_dirs = g_list_prepend(*special_dirs, mhl_str_dup(token)); s = NULL; } g_free(buffer); diff --git a/src/user.c b/src/user.c index e47b84235..8f65dc5c9 100644 --- a/src/user.c +++ b/src/user.c @@ -23,6 +23,8 @@ #include #include +#include + #include "global.h" #include "tty.h" #include "color.h" @@ -144,7 +146,7 @@ int check_format_var (const char *p, char **v) value = getenv (var_name); g_free (var_name); if (value){ - *v = g_strdup (value); + *v = mhl_str_dup (value); return q-p; } var_name = g_strndup (dots, q - dots); @@ -179,7 +181,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) char c_lc; if (c == '%') - return g_strdup ("%"); + return mhl_str_dup ("%"); if (edit_one_file != NULL) fname = edit_widget->filename; @@ -188,7 +190,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) panel = current_panel; else { if (get_other_type () != view_listing) - return g_strdup (""); + return mhl_str_dup (""); panel = other_panel; } fname = panel->dir.list[panel->selected].fname; @@ -231,7 +233,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) break; case 'y': /* syntax type */ if (edit_widget && edit_widget->syntax_type) - return g_strdup (edit_widget->syntax_type); + return mhl_str_dup (edit_widget->syntax_type); break; case 'k': /* block file name */ case 'b': /* block file name / strip extension */ { @@ -266,7 +268,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) char *block, *tmp; if (!panel) - return g_strdup (""); + return mhl_str_dup (""); for (i = 0; i < panel->count; i++) if (panel->dir.list[i].f.marked) @@ -286,7 +288,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote) return block; } /* sub case block */ } /* switch */ - result = g_strdup ("% "); + result = mhl_str_dup ("% "); result[1] = c; return result; } @@ -718,7 +720,7 @@ user_menu_cmd (struct WEdit *edit_widget) return; } - menu = g_strdup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU); + menu = mhl_str_dup (edit_widget ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU); if (!exist_file (menu) || !menu_file_own (menu)){ g_free (menu); menu = concat_dir_and_file \ diff --git a/src/util.c b/src/util.c index edc759a2e..a7f06ffb1 100644 --- a/src/util.c +++ b/src/util.c @@ -30,11 +30,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "profile.h" #include "main.h" /* mc_home */ @@ -218,7 +219,7 @@ char * fake_name_quote (const char *s, int quote_percent) { (void) quote_percent; - return g_strdup (s); + return mhl_str_dup (s); } /* @@ -260,7 +261,7 @@ name_trunc (const char *txt, int trunc_len) const char * path_trunc (const char *path, int trunc_len) { const char *ret; - char *secure_path = strip_password (g_strdup (path), 1); + char *secure_path = strip_password (mhl_str_dup (path), 1); ret = name_trunc (secure_path, trunc_len); g_free (secure_path); @@ -579,7 +580,7 @@ convert_pattern (const char *pattern, int match_type, int do_group) *d = 0; return new_pattern; } else - return g_strdup (pattern); + return mhl_str_dup (pattern); } int @@ -636,7 +637,7 @@ get_config_string (const char *file, const char *key, const char *defval) { char buffer[1024]; (void)GetPrivateProfileString (app_text, key, defval, buffer, sizeof(buffer), file); - return g_strdup (buffer); + return mhl_str_dup (buffer); } extern void @@ -1090,7 +1091,7 @@ wipe_password (char *passwd) char * convert_controls (const char *p) { - char *valcopy = g_strdup (p); + char *valcopy = mhl_str_dup (p); char *q; /* Parse the escape special character */ @@ -1319,7 +1320,7 @@ mc_mkstemps (char **pname, const char *prefix, const char *suffix) /* Add prefix first to find the position of XXXXXX */ tmpbase = concat_dir_and_file (mc_tmpdir (), prefix); } else { - tmpbase = g_strdup (prefix); + tmpbase = mhl_str_dup (prefix); } tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, (char *) NULL); diff --git a/src/utilunix.c b/src/utilunix.c index cd3c7cced..ef5dfefb1 100644 --- a/src/utilunix.c +++ b/src/utilunix.c @@ -41,6 +41,8 @@ #endif #include +#include + #include "global.h" #include "execute.h" #include "wtools.h" /* message() */ @@ -72,7 +74,7 @@ static void i_cache_add (int id, int_cache *cache, int size, char *text, int *last) { g_free (cache [*last].string); - cache [*last].string = g_strdup (text); + cache [*last].string = mhl_str_dup (text); cache [*last].index = id; *last = ((*last)+1) % size; } @@ -186,7 +188,7 @@ tilde_expand (const char *directory) char *name; if (*directory != '~') - return g_strdup (directory); + return mhl_str_dup (directory); p = directory + 1; @@ -208,7 +210,7 @@ tilde_expand (const char *directory) /* If we can't figure the user name, leave tilde unexpanded */ if (!passwd) - return g_strdup (directory); + return mhl_str_dup (directory); return g_strconcat (passwd->pw_dir, PATH_SEP_STR, q, (char *) NULL); } diff --git a/src/vfsdummy.h b/src/vfsdummy.h index 06d39c229..4114dc246 100644 --- a/src/vfsdummy.h +++ b/src/vfsdummy.h @@ -3,6 +3,8 @@ #ifndef MC_VFSDUMMY_H #define MC_VFSDYMMY_H +#include + /* Flags of VFS classes */ #define VFSF_LOCAL 1 /* Class is local (not virtual) filesystem */ #define VFSF_NOLINKS 2 /* Hard links not supported */ @@ -54,12 +56,12 @@ return_zero (void) #define vfs_current_is_local() 1 #define vfs_file_is_local(x) 1 -#define vfs_strip_suffix_from_filename(x) g_strdup(x) +#define vfs_strip_suffix_from_filename(x) mhl_str_dup(x) #define vfs_file_class_flags(x) (VFSF_LOCAL) #define vfs_get_class(x) (struct vfs_class *)(NULL) -#define vfs_translate_url(s) g_strdup(s) +#define vfs_translate_url(s) mhl_str_dup(s) #define vfs_release_path(x) #define vfs_add_current_stamps() do { } while (0) #define vfs_timeout_handler() do { } while (0) @@ -68,7 +70,7 @@ return_zero (void) static inline char * vfs_canon (const char *path) { - char *p = g_strdup (path); + char *p = mhl_str_dup (path); canonicalize_pathname(p); return p; } diff --git a/src/view.c b/src/view.c index 1d389a942..79e2f6877 100644 --- a/src/view.c +++ b/src/view.c @@ -39,11 +39,12 @@ #include #include #include - #include #include #include +#include + #include "global.h" #include "tty.h" #include "cmd.h" /* For view_other_cmd */ @@ -664,7 +665,7 @@ static void view_set_datasource_string (WView *view, const char *s) { view->datasource = DS_STRING; - view->ds_string_data = (byte *) g_strdup (s); + view->ds_string_data = (byte *) mhl_str_dup (s); view->ds_string_len = strlen (s); } @@ -1392,8 +1393,8 @@ view_toggle_magic_mode (WView *view) altered_magic_flag = 1; view->magic_mode = !view->magic_mode; - filename = g_strdup (view->filename); - command = g_strdup (view->command); + filename = mhl_str_dup (view->filename); + command = mhl_str_dup (view->command); view_done (view); view_load (view, command, filename, 0); @@ -1499,7 +1500,7 @@ view_load (WView *view, const char *command, const char *file, /* Set up the state */ view_set_datasource_none (view); - view->filename = g_strdup (file); + view->filename = mhl_str_dup (file); view->command = 0; /* Clear the markers */ @@ -1553,7 +1554,7 @@ view_load (WView *view, const char *command, const char *file, } finish: - view->command = g_strdup (command); + view->command = mhl_str_dup (command); view->dpy_start = 0; view->search_start = 0; view->search_length = 0; @@ -2167,7 +2168,7 @@ view_hexedit_save_changes (WView *view) } if (mc_close (fp) == -1) { - error = g_strdup (strerror (errno)); + error = mhl_str_dup (strerror (errno)); message (D_ERROR, _(" Save file "), _(" Error while closing the file: \n %s \n" " Data may have been written or not. "), error); @@ -2177,7 +2178,7 @@ view_hexedit_save_changes (WView *view) return TRUE; save_error: - error = g_strdup (strerror (errno)); + error = mhl_str_dup (strerror (errno)); text = g_strdup_printf (_(" Cannot save file: \n %s "), error); g_free (error); (void) mc_close (fp); @@ -2651,7 +2652,7 @@ regexp_view_search (WView *view, char *pattern, char *string, message (D_ERROR, MSG_ERROR, _(" Invalid regular expression ")); return -1; } - old_pattern = g_strdup (pattern); + old_pattern = mhl_str_dup (pattern); old_type = match_type; } if (regexec (&r, string, 1, pmatch, 0) != 0) @@ -2846,7 +2847,7 @@ view_normal_search_cmd (WView *view) "[Input Line Keys]", quick_widgets, 0 }; - defval = g_strdup (last_search_string != NULL ? last_search_string : ""); + defval = mhl_str_dup (last_search_string != NULL ? last_search_string : ""); convert_to_display (defval); quick_widgets[2].result = &treplace_backwards; diff --git a/src/widget.c b/src/widget.c index 83f31690a..6d93d26c1 100644 --- a/src/widget.c +++ b/src/widget.c @@ -32,9 +32,10 @@ #include #include #include - #include +#include + #include "global.h" #include "tty.h" #include "color.h" @@ -262,7 +263,7 @@ button_new (int y, int x, int action, int flags, const char *text, b->action = action; b->flags = flags; b->selected = 0; - b->text = g_strdup (text); + b->text = mhl_str_dup (text); b->callback = callback; widget_want_hotkey (b->widget, 1); b->hotkey = 0; @@ -282,7 +283,7 @@ void button_set_text (WButton *b, const char *text) { g_free (b->text); - b->text = g_strdup (text); + b->text = mhl_str_dup (text); b->widget.cols = button_len (text, b->flags); button_scan_hotkey(b); dlg_redraw (b->widget.parent); @@ -512,7 +513,7 @@ check_new (int y, int x, int state, const char *text) init_widget (&c->widget, y, x, 1, strlen (text), check_callback, check_event); c->state = state ? C_BOOL : 0; - c->text = g_strdup (text); + c->text = mhl_str_dup (text); c->hotkey = 0; c->hotpos = -1; widget_want_hotkey (c->widget, 1); @@ -605,7 +606,7 @@ label_set_text (WLabel *label, const char *text) g_free (label->text); if (text){ - label->text = g_strdup (text); + label->text = mhl_str_dup (text); if (label->auto_adjust_cols) { newcols = strlen (text); if (newcols > label->widget.cols) @@ -635,7 +636,7 @@ label_new (int y, int x, const char *text) l = g_new (WLabel, 1); init_widget (&l->widget, y, x, 1, width, label_callback, NULL); - l->text = text ? g_strdup (text) : 0; + l->text = text ? mhl_str_dup (text) : 0; l->auto_adjust_cols = 1; l->transparent = 0; widget_want_cursor (l->widget, 0); @@ -876,7 +877,7 @@ history_get (const char *input_name) if (!*this_entry) break; - hist = list_append_unique (hist, g_strdup (this_entry)); + hist = list_append_unique (hist, mhl_str_dup (this_entry)); } g_free (profile); @@ -1039,7 +1040,7 @@ show_hist (GList *history, int widget_x, int widget_y) if (query_dlg->ret_value != B_CANCEL) { listbox_get_current (query_list, &q, NULL); if (q) - r = g_strdup (q); + r = mhl_str_dup (q); } destroy_dlg (query_dlg); return r; @@ -1128,7 +1129,7 @@ push_history (WInput *in, const char *text) return 1; } - t = g_strdup (text); + t = mhl_str_dup (text); if (in->history_name) { p = in->history_name + 3; @@ -1381,7 +1382,7 @@ static void kill_line (WInput *in) { g_free (kill_buffer); - kill_buffer = g_strdup (&in->buffer [in->point]); + kill_buffer = mhl_str_dup (&in->buffer [in->point]); in->buffer [in->point] = 0; } @@ -1390,7 +1391,7 @@ assign_text (WInput *in, const char *text) { free_completions (in); g_free (in->buffer); - in->buffer = g_strdup (text); /* was in->buffer->text */ + in->buffer = mhl_str_dup (text); /* was in->buffer->text */ in->current_max_len = strlen (in->buffer) + 1; in->point = strlen (in->buffer); in->mark = 0; @@ -1671,7 +1672,7 @@ input_new (int y, int x, int color, int len, const char *def_text, in->history_name = 0; if (histname) { if (*histname) { - in->history_name = g_strdup (histname); + in->history_name = mhl_str_dup (histname); in->history = history_get (histname); } } @@ -2235,7 +2236,7 @@ listbox_add_item (WListbox *l, enum append_pos pos, int hotkey, return NULL; entry = g_new (WLEntry, 1); - entry->text = g_strdup (text); + entry->text = mhl_str_dup (text); entry->data = data; entry->hotkey = hotkey; @@ -2387,7 +2388,7 @@ set_label_text (WButtonBar * bb, int index, const char *text) { g_free (bb->labels[index - 1].text); - bb->labels[index - 1].text = g_strdup (text); + bb->labels[index - 1].text = mhl_str_dup (text); } /* Find ButtonBar widget in the dialog */ @@ -2505,7 +2506,7 @@ groupbox_new (int x, int y, int width, int height, const char *title) /* Strip existing spaces, add one space before and after the title */ if (title) { char *t; - t = g_strstrip (g_strdup (title)); + t = g_strstrip (mhl_str_dup (title)); g->title = g_strconcat (" ", t, " ", (char *) NULL); g_free (t); } diff --git a/src/wtools.c b/src/wtools.c index 97e142826..5fa123349 100644 --- a/src/wtools.c +++ b/src/wtools.c @@ -29,6 +29,8 @@ #include #include +#include + #include "global.h" #include "tty.h" #include "color.h" /* dialog_colors */ @@ -406,7 +408,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip) *qw->str_result = tilde_expand (((WInput *) w)->buffer); else - *qw->str_result = g_strdup (((WInput *) w)->buffer); + *qw->str_result = mhl_str_dup (((WInput *) w)->buffer); break; } } @@ -499,7 +501,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help, Quick_input.title = header; Quick_input.help = help; Quick_input.i18n = 1; /* The dialog is already translated. */ - p_text = g_strstrip (g_strdup (text)); + p_text = g_strstrip (mhl_str_dup (text)); quick_widgets[INPUT_INDEX + 1].text = p_text; quick_widgets[INPUT_INDEX].text = def_text; diff --git a/vfs/cpio.c b/vfs/cpio.c index f4c8a7838..0019b4bf1 100644 --- a/vfs/cpio.c +++ b/vfs/cpio.c @@ -19,8 +19,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include + #include +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -161,7 +164,7 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super, return -1; } - super->name = g_strdup (name); + super->name = mhl_str_dup (name); super->u.arch.fd = -1; /* for now */ mc_stat (name, &(super->u.arch.st)); super->u.arch.type = CPIO_UNKNOWN; diff --git a/vfs/direntry.c b/vfs/direntry.c index 852c5cb02..d85c1d833 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -25,8 +25,11 @@ * archive/site is simply "". Beware. */ #include + #include +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -73,7 +76,7 @@ vfs_s_new_entry (struct vfs_class *me, const char *name, struct vfs_s_inode *ino total_entries++; if (name) - entry->name = g_strdup (name); + entry->name = mhl_str_dup (name); entry->ino = inode; entry->ino->ent = entry; @@ -248,7 +251,7 @@ vfs_s_find_entry_tree (struct vfs_class *me, struct vfs_s_inode *root, { size_t pseg; struct vfs_s_entry *ent = NULL; - char * const pathref = g_strdup (a_path); + char * const pathref = mhl_str_dup (a_path); char *path = pathref; canonicalize_pathname (path); @@ -318,7 +321,7 @@ vfs_s_find_entry_linear (struct vfs_class *me, struct vfs_s_inode *root, const char *a_path, int follow, int flags) { struct vfs_s_entry *ent = NULL; - char * const path = g_strdup (a_path); + char * const path = mhl_str_dup (a_path); struct vfs_s_entry *retval = NULL; if (root->super->root != root) @@ -519,8 +522,8 @@ vfs_s_get_path (struct vfs_class *me, const char *inname, { char *buf, *retval; - buf = g_strdup (inname); - retval = g_strdup (vfs_s_get_path_mangle (me, buf, archive, flags)); + buf = mhl_str_dup (inname); + retval = mhl_str_dup (vfs_s_get_path_mangle (me, buf, archive, flags)); g_free (buf); return retval; } @@ -543,7 +546,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino) if (!(MEDATA->flags & VFS_S_REMOTE)) { /* archives */ char *newpath; - char *path = g_strdup (ino->ent->name); + char *path = mhl_str_dup (ino->ent->name); while (1) { ino = ino->ent->dir; if (ino == ino->super->root) @@ -557,7 +560,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino) /* remote systems */ if ((!ino->ent->dir) || (!ino->ent->dir->ent)) - return g_strdup (ino->ent->name); + return mhl_str_dup (ino->ent->name); return g_strconcat (ino->ent->dir->ent->name, PATH_SEP_STR, ino->ent->name, (char *) NULL); @@ -1033,7 +1036,7 @@ vfs_s_getlocalcopy (struct vfs_class *me, const char *path) if (!fh || !fh->ino || !fh->ino->localname) return NULL; - local = g_strdup (fh->ino->localname); + local = mhl_str_dup (fh->ino->localname); vfs_s_close (fh); return local; } diff --git a/vfs/extfs.c b/vfs/extfs.c index 7212aebc3..4641dd4da 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -35,6 +35,9 @@ #include #endif #include + +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -134,7 +137,7 @@ static void extfs_make_dots (struct entry *ent) struct inode *inode = ent->inode, *parent; parent = (parentry != NULL) ? parentry->inode : NULL; - entry->name = g_strdup ("."); + entry->name = mhl_str_dup ("."); entry->inode = inode; entry->dir = ent; inode->local_filename = NULL; @@ -142,7 +145,7 @@ static void extfs_make_dots (struct entry *ent) inode->nlink++; entry->next_in_dir = g_new (struct entry, 1); entry = entry->next_in_dir; - entry->name = g_strdup (".."); + entry->name = mhl_str_dup (".."); inode->last_in_subdir = entry; entry->next_in_dir = NULL; if (parent != NULL) { @@ -166,7 +169,7 @@ static struct entry *extfs_generate_entry (struct archive *archive, parent = (parentry != NULL) ? parentry->inode : NULL; entry = g_new (struct entry, 1); - entry->name = g_strdup (name); + entry->name = mhl_str_dup (name); entry->next_in_dir = NULL; entry->dir = parentry; if (parent != NULL) { @@ -269,7 +272,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc) current_archive = g_new (struct archive, 1); current_archive->fstype = fstype; - current_archive->name = name ? g_strdup (name) : NULL; + current_archive->name = name ? mhl_str_dup (name) : NULL; current_archive->local_name = local_name; if (local_name != NULL) @@ -358,7 +361,7 @@ extfs_read_archive (int fstype, const char *name, struct archive **pparc) return -1; } entry = g_new (struct entry, 1); - entry->name = g_strdup (p); + entry->name = mhl_str_dup (p); entry->next_in_dir = NULL; entry->dir = pent; if (pent->inode->last_in_subdir) { @@ -490,11 +493,11 @@ static char * extfs_get_path (struct vfs_class *me, const char *inname, struct archive **archive, int do_not_open) { - char *buf = g_strdup (inname); + char *buf = mhl_str_dup (inname); char *res = extfs_get_path_mangle (me, buf, archive, do_not_open); char *res2 = NULL; if (res) - res2 = g_strdup (res); + res2 = mhl_str_dup (res); g_free (buf); return res2; } @@ -519,7 +522,7 @@ static char *extfs_get_path_from_entry (struct entry *entry) } if (len == 0) - return g_strdup (""); + return mhl_str_dup (""); localpath = g_malloc (len); *localpath = '\0'; @@ -944,7 +947,7 @@ extfs_internal_stat (struct vfs_class *me, const char *path, struct stat *buf, struct archive *archive; char *q; struct entry *entry; - char *path2 = g_strdup (path); + char *path2 = mhl_str_dup (path); int result = -1; if ((q = extfs_get_path_mangle (me, path2, &archive, 0)) == NULL) @@ -986,7 +989,7 @@ extfs_readlink (struct vfs_class *me, const char *path, char *buf, size_t size) char *q; size_t len; struct entry *entry; - char *mpath = g_strdup (path); + char *mpath = mhl_str_dup (path); int result = -1; if ((q = extfs_get_path_mangle (me, mpath, &archive, 0)) == NULL) @@ -1027,7 +1030,7 @@ static ssize_t extfs_write (void *data, const char *buf, int nbyte) static int extfs_unlink (struct vfs_class *me, const char *file) { struct archive *archive; - char *q, *mpath = g_strdup (file); + char *q, *mpath = mhl_str_dup (file); struct entry *entry; int result = -1; @@ -1056,7 +1059,7 @@ cleanup: static int extfs_mkdir (struct vfs_class *me, const char *path, mode_t mode) { struct archive *archive; - char *q, *mpath = g_strdup(path); + char *q, *mpath = mhl_str_dup(path); struct entry *entry; int result = -1; @@ -1093,7 +1096,7 @@ cleanup: static int extfs_rmdir (struct vfs_class *me, const char *path) { struct archive *archive; - char *q, *mpath = g_strdup(path); + char *q, *mpath = mhl_str_dup(path); struct entry *entry; int result = -1; @@ -1259,7 +1262,7 @@ extfs_getlocalcopy (struct vfs_class *me, const char *path) extfs_close ((void *) fp); return NULL; } - p = g_strdup (fp->entry->inode->local_filename); + p = mhl_str_dup (fp->entry->inode->local_filename); fp->archive->fd_usage++; extfs_close ((void *) fp); return p; @@ -1336,7 +1339,7 @@ static int extfs_init (struct vfs_class *me) if (!(*key)) continue; - extfs_prefixes [extfs_no++] = g_strdup (key); + extfs_prefixes [extfs_no++] = mhl_str_dup (key); } fclose(cfg); g_free (mc_extfsini); diff --git a/vfs/fish.c b/vfs/fish.c index 29b5f67b8..e94cb5ae6 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -36,8 +36,11 @@ /* Define this if your ssh can take -I option */ #include + #include +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -294,7 +297,7 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super) super->name = g_strconcat ("/#sh:", SUP.user, "@", SUP.host, "/", (char *) NULL); #endif - super->name = g_strdup (PATH_SEP_STR); + super->name = mhl_str_dup (PATH_SEP_STR); super->root = vfs_s_new_inode (me, super, @@ -586,7 +589,7 @@ fish_dir_load(struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path) reply_code = fish_decode_reply(buffer + 4, 0); if (reply_code == COMPLETE) { g_free (SUP.cwdir); - SUP.cwdir = g_strdup (remote_path); + SUP.cwdir = mhl_str_dup (remote_path); print_vfs_message (_("%s: done."), me->name); return 0; } else if (reply_code == ERROR) { @@ -880,7 +883,7 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super *super, const char *c #define PREFIX \ char buf[BUF_LARGE]; \ const char *crpath; \ - char *rpath, *mpath = g_strdup (path); \ + char *rpath, *mpath = mhl_str_dup (path); \ struct vfs_s_super *super; \ if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \ g_free (mpath); \ @@ -912,11 +915,11 @@ static int fish_##name (struct vfs_class *me, const char *path1, const char *pat const char *crpath1, *crpath2; \ 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))) { \ + if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = mhl_str_dup(path1), &super1, 0))) { \ g_free (mpath1); \ return -1; \ } \ - if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0))) { \ + if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = mhl_str_dup(path2), &super2, 0))) { \ g_free (mpath1); \ g_free (mpath2); \ return -1; \ diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 7737e93e2..8c48bc7cd 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -69,6 +69,8 @@ What to do with this? #include #include +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -172,7 +174,7 @@ static char * ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const char *remote_path) { if (!SUP.remote_is_amiga) - return g_strdup (remote_path); + return mhl_str_dup (remote_path); else { char *ret, *p; @@ -190,9 +192,9 @@ ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const cha * invalid. */ if (*remote_path == '\0') - return g_strdup ("."); + return mhl_str_dup ("."); - ret = g_strdup (remote_path); + ret = mhl_str_dup (remote_path); /* replace first occurance of ":/" with ":" */ if ((p = strchr (ret, ':')) && *(p + 1) == '/') @@ -233,7 +235,7 @@ ftpfs_split_url(char *path, char **host, char **user, int *port, char **pass) if (use_netrc) ftpfs_netrc_lookup (*host, user, pass); if (!*user) - *user = g_strdup ("anonymous"); + *user = mhl_str_dup ("anonymous"); } /* Look up password in netrc for known user */ @@ -441,13 +443,13 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, SUP.isbinary = TYPE_UNKNOWN; if (SUP.password) /* explicit password */ - op = g_strdup (SUP.password); + op = mhl_str_dup (SUP.password); else if (netrcpass) /* password from netrc */ - op = g_strdup (netrcpass); + op = mhl_str_dup (netrcpass); else if (!strcmp (SUP.user, "anonymous") || !strcmp (SUP.user, "ftp")) { if (!ftpfs_anonymous_passwd) /* default anonymous password */ ftpfs_init_passwd (); - op = g_strdup (ftpfs_anonymous_passwd); + op = mhl_str_dup (ftpfs_anonymous_passwd); anon = 1; } else { /* ask user */ char *p; @@ -458,7 +460,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, g_free (p); if (op == NULL) ERRNOR (EPERM, 0); - SUP.password = g_strdup (op); + SUP.password = mhl_str_dup (op); } if (!anon || MEDATA->logfile) @@ -475,7 +477,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, SUP.host[0] == '!' ? SUP.host + 1 : SUP.host, NULL); } else - name = g_strdup (SUP.user); + name = mhl_str_dup (SUP.user); if (ftpfs_get_reply (me, SUP.sock, reply_string, @@ -571,7 +573,7 @@ ftpfs_load_no_proxy_list (void) *p = '\0'; np = g_new (struct no_proxy_entry, 1); - np->domain = g_strdup (s); + np->domain = mhl_str_dup (s); np->next = NULL; if (no_proxy) current->next = np; @@ -764,7 +766,7 @@ ftpfs_open_archive_int (struct vfs_class *me, struct vfs_s_super *super) SUP.cwdir = ftpfs_get_current_directory (me, super); if (!SUP.cwdir) - SUP.cwdir = g_strdup (PATH_SEP_STR); + SUP.cwdir = mhl_str_dup (PATH_SEP_STR); return 0; } @@ -791,7 +793,7 @@ ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super, SUP.strict = ftpfs_use_unix_list_options ? RFC_AUTODETECT : RFC_STRICT; SUP.isbinary = TYPE_UNKNOWN; SUP.remote_is_amiga = 0; - super->name = g_strdup ("/"); + super->name = mhl_str_dup ("/"); super->root = vfs_s_new_inode (me, super, vfs_s_default_stat (me, S_IFDIR | 0755)); @@ -842,7 +844,7 @@ ftpfs_get_current_directory (struct vfs_class *me, struct vfs_s_super *super) *bufq = 0; } if (*bufp == '/') - return g_strdup (bufp); + return mhl_str_dup (bufp); else { /* If the remote server is an Amiga a leading slash might be missing. MC needs it because it is used @@ -1477,7 +1479,7 @@ static int ftpfs_send_command(struct vfs_class *me, const char *filename, const char *cmd, int flags) { const char *rpath; - char *p, *mpath = g_strdup(filename); + char *p, *mpath = mhl_str_dup(filename); struct vfs_s_super *super; int r; int flush_directory_cache = (flags & OPT_FLUSH); @@ -1519,7 +1521,7 @@ ftpfs_init_passwd(void) * - We don't want to let ftp sites to discriminate by the user, * host or country. */ - ftpfs_anonymous_passwd = g_strdup ("anonymous@"); + ftpfs_anonymous_passwd = mhl_str_dup ("anonymous@"); } static int ftpfs_chmod (struct vfs_class *me, const char *path, int mode) @@ -1581,7 +1583,7 @@ ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, const cha ftpfs_errno = EIO; } else { g_free(SUP.cwdir); - SUP.cwdir = g_strdup (remote_path); + SUP.cwdir = mhl_str_dup (remote_path); SUP.cwd_deferred = 0; } return r; @@ -1878,9 +1880,9 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) for (rupp = rup_cache; rupp != NULL; rupp = rupp->next) { if (!strcmp (host, rupp->host)) { if (rupp->login) - *login = g_strdup (rupp->login); + *login = mhl_str_dup (rupp->login); if (pass && rupp->pass) - *pass = g_strdup (rupp->pass); + *pass = mhl_str_dup (rupp->pass); return 0; } } @@ -1921,7 +1923,7 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) } /* We have login name now */ - *login = g_strdup (buffer); + *login = mhl_str_dup (buffer); break; case NETRC_PASSWORD: @@ -1940,7 +1942,7 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) /* Remember password. pass may be NULL, so use tmp_pass */ if (tmp_pass == NULL) - tmp_pass = g_strdup (buffer); + tmp_pass = mhl_str_dup (buffer); break; case NETRC_ACCOUNT: @@ -1968,14 +1970,14 @@ static int ftpfs_netrc_lookup (const char *host, char **login, char **pass) g_free (netrcname); rupp = g_new (struct rupcache, 1); - rupp->host = g_strdup (host); + rupp->host = mhl_str_dup (host); rupp->login = rupp->pass = 0; if (*login != NULL) { - rupp->login = g_strdup (*login); + rupp->login = mhl_str_dup (*login); } if (tmp_pass != NULL) - rupp->pass = g_strdup (tmp_pass); + rupp->pass = mhl_str_dup (tmp_pass); rupp->next = rup_cache; rup_cache = rupp; diff --git a/vfs/local.c b/vfs/local.c index 9ed245a3e..29ff36b5f 100644 --- a/vfs/local.c +++ b/vfs/local.c @@ -5,6 +5,7 @@ #include #include +#include #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ @@ -271,7 +272,7 @@ local_getlocalcopy (struct vfs_class *me, const char *path) { (void) me; - return g_strdup (path); + return mhl_str_dup (path); } static int diff --git a/vfs/mcfs.c b/vfs/mcfs.c index 9f5ace24d..29c1c6bd5 100644 --- a/vfs/mcfs.c +++ b/vfs/mcfs.c @@ -49,6 +49,8 @@ #endif #endif +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -159,7 +161,7 @@ mcfs_login_server (int my_socket, char *user, int port, } } if (netrcpass != NULL) - pass = g_strdup (netrcpass); + pass = mhl_str_dup (netrcpass); else pass = vfs_get_password (_(" MCFS Password required ")); if (!pass) { @@ -341,8 +343,8 @@ mcfs_open_link (char *host, char *user, int *port, char *netrcpass) bucket = mcfs_get_free_bucket (); mcfs_open_connections++; - bucket->host = g_strdup (host); - bucket->user = g_strdup (user); + bucket->host = mhl_str_dup (host); + bucket->user = mhl_str_dup (user); bucket->home = 0; bucket->port = *port; bucket->sock = sock; @@ -509,13 +511,13 @@ mcfs_gethome (mcfs_connection *mc) char *buffer; if (mc->home) - return g_strdup (mc->home); + return mhl_str_dup (mc->home); else { rpc_send (mc->sock, RPC_INT, MC_GETHOME, RPC_END); if (0 == rpc_get (mc->sock, RPC_STRING, &buffer, RPC_END)) - return g_strdup (PATH_SEP_STR); + return mhl_str_dup (PATH_SEP_STR); mc->home = buffer; - return g_strdup (buffer); + return mhl_str_dup (buffer); } } diff --git a/vfs/sfs.c b/vfs/sfs.c index 077048211..72492e76a 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -34,6 +34,8 @@ #include #include +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -74,7 +76,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache) char *pname; /* name of parent archive */ char *pqname; /* name of parent archive, quoted */ - pname = g_strdup (name); + pname = mhl_str_dup (name); vfs_split (pname, &inpath, &op); if ((w = (*me->which) (me, op)) == -1) vfs_die ("This cannot happen... Hopefully.\n"); @@ -180,7 +182,7 @@ sfs_redirect (struct vfs_class *me, const char *name) if (!sfs_vfmake (me, name, cache)) { cur = g_new (struct cachedfile, 1); - cur->name = g_strdup (name); + cur->name = mhl_str_dup (name); cur->cache = cache; cur->next = head; head = cur; @@ -314,7 +316,7 @@ static char * sfs_getlocalcopy (struct vfs_class *me, const char *path) { path = sfs_redirect (me, path); - return g_strdup (path); + return mhl_str_dup (path); } static int @@ -389,8 +391,8 @@ static int sfs_init (struct vfs_class *me) if ((semi = strchr (c, '\n'))) *semi = 0; - sfs_prefix [sfs_no] = g_strdup (key); - sfs_command [sfs_no] = g_strdup (c); + sfs_prefix [sfs_no] = mhl_str_dup (key); + sfs_command [sfs_no] = mhl_str_dup (c); sfs_flags [sfs_no] = flags; sfs_no++; } diff --git a/vfs/smbfs.c b/vfs/smbfs.c index b07c802e1..2bd71373f 100644 --- a/vfs/smbfs.c +++ b/vfs/smbfs.c @@ -22,9 +22,12 @@ /* Namespace: exports init_smbfs, smbfs_set_debug(), smbfs_set_debugf() */ #include + #include #include +#include + #undef USE_NCURSES /* Don't include *curses.h */ #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ @@ -106,7 +109,7 @@ typedef struct { static GSList *auth_list; /* this function allows you to write: - * char *s = g_strdup("hello, world"); + * char *s = mhl_str_dup("hello, world"); * s = free_after(g_strconcat(s, s, (char *)0), s); */ static inline char * @@ -176,12 +179,12 @@ smbfs_auth_add (const char *host, const char *share, const char *domain, if (!auth) return; - /* Don't check for NULL, g_strdup already does. */ - auth->host = g_strdup (host); - auth->share = g_strdup (share); - auth->domain = g_strdup (domain); - auth->user = g_strdup (user); - auth->password = g_strdup (password); + /* Don't check for NULL, mhl_str_dup already does. */ + auth->host = mhl_str_dup (host); + auth->share = mhl_str_dup (share); + auth->domain = mhl_str_dup (domain); + auth->user = mhl_str_dup (user); + auth->password = mhl_str_dup (password); auth_list = g_slist_prepend (auth_list, auth); } @@ -192,8 +195,8 @@ smbfs_auth_remove (const char *host, const char *share) struct smb_authinfo *auth; GSList *list; - data.host = g_strdup (host); - data.share = g_strdup (share); + data.host = mhl_str_dup (host); + data.share = mhl_str_dup (share); list = g_slist_find_custom (auth_list, &data, smbfs_auth_cmp_host_and_share); @@ -222,9 +225,9 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket, g_free (bucket->domain); g_free (bucket->user); g_free (bucket->password); - bucket->domain = g_strdup (domain); - bucket->user = g_strdup (user); - bucket->password = g_strdup (pass); + bucket->domain = mhl_str_dup (domain); + bucket->user = mhl_str_dup (user); + bucket->password = mhl_str_dup (pass); smbfs_auth_remove (bucket->host, bucket->service); smbfs_auth_add (bucket->host, bucket->service, domain, user, pass); @@ -238,16 +241,16 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket, list = g_slist_find_custom (auth_list, &data, smbfs_auth_cmp_host); if (list) { auth = list->data; - bucket->domain = g_strdup (auth->domain); - bucket->user = g_strdup (auth->user); - bucket->password = g_strdup (auth->password); + bucket->domain = mhl_str_dup (auth->domain); + bucket->user = mhl_str_dup (auth->user); + bucket->password = mhl_str_dup (auth->password); return 1; } if (got_pass) { - bucket->domain = g_strdup (lp_workgroup ()); - bucket->user = g_strdup (got_user ? username : user); - bucket->password = g_strdup (password); + bucket->domain = mhl_str_dup (lp_workgroup ()); + bucket->user = mhl_str_dup (got_user ? username : user); + bucket->password = mhl_str_dup (password); return 1; } @@ -259,9 +262,9 @@ smbfs_bucket_set_authinfo (smbfs_connection *bucket, g_free (bucket->domain); g_free (bucket->user); g_free (bucket->password); - bucket->domain = g_strdup (auth->domain); - bucket->user = g_strdup (auth->user); - bucket->password = g_strdup (auth->password); + bucket->domain = mhl_str_dup (auth->domain); + bucket->user = mhl_str_dup (auth->user); + bucket->password = mhl_str_dup (auth->password); smbfs_auth_remove (bucket->host, bucket->service); auth_list = g_slist_prepend (auth_list, auth); return 1; @@ -455,7 +458,7 @@ smbfs_new_dir_entry (const char *name) static int inode_counter; dir_entry *new_entry; new_entry = g_new0 (dir_entry, 1); - new_entry->text = dos_to_unix (g_strdup (name), 1); + new_entry->text = dos_to_unix (mhl_str_dup (name), 1); if (first_direntry) { current_info->entries = new_entry; @@ -597,9 +600,9 @@ smbfs_reconnect(smbfs_connection *conn, int *retries) DEBUG(3, ("RECONNECT\n")); if (*(conn->host) == 0) - host = g_strdup(conn->cli->desthost); /* server browsing */ + host = mhl_str_dup(conn->cli->desthost); /* server browsing */ else - host = g_strdup(conn->host); + host = mhl_str_dup(conn->host); cli_shutdown(conn->cli); @@ -759,7 +762,7 @@ smbfs_loaddir (opendir_info *smbfs_info) /* do regular directory listing */ if (strncmp (smbfs_info->conn->service, info_dirname + 1, servlen) == 0) { /* strip share name from dir */ - my_dirname = g_strdup (info_dirname + servlen); + my_dirname = mhl_str_dup (info_dirname + servlen); *my_dirname = '/'; my_dirname = free_after(smbfs_convert_path (my_dirname, TRUE), my_dirname); } else @@ -1028,7 +1031,7 @@ smbfs_get_master_browser(char **host) if (!count) return 0; /* just return first master browser */ - *host = g_strdup(inet_ntoa(ip_list[0])); + *host = mhl_str_dup(inet_ntoa(ip_list[0])); return 1; } return 0; @@ -1142,16 +1145,16 @@ smbfs_open_link (char *host, char *path, const char *user, int *port, } current_bucket = bucket; - bucket->user = g_strdup (user); - bucket->service = g_strdup (service); + bucket->user = mhl_str_dup (user); + bucket->service = mhl_str_dup (service); 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); - bucket->host = g_strdup (""); /* blank host means master browser */ + bucket->host = mhl_str_dup (""); /* blank host means master browser */ } else - bucket->host = g_strdup (host); + bucket->host = mhl_str_dup (host); if (!smbfs_bucket_set_authinfo (bucket, 0, /* domain currently not used */ user, this_pass, 1)) @@ -1248,7 +1251,7 @@ smbfs_opendir (struct vfs_class *me, const char *dirname) /* FIXME: where freed? */ smbfs_info = g_new (opendir_info, 1); smbfs_info->server_list = FALSE; - smbfs_info->path = g_strdup(dirname); /* keep original */ + smbfs_info->path = mhl_str_dup(dirname); /* keep original */ smbfs_info->dirname = remote_dir; smbfs_info->conn = sc; smbfs_info->entries = 0; @@ -1356,7 +1359,7 @@ smbfs_get_remote_stat (smbfs_connection * sc, const char *path, struct stat *buf #if 0 /* single_entry is never free()d now. And only my_stat is used */ single_entry = g_new (dir_entry, 1); - single_entry->text = dos_to_unix (g_strdup (finfo->name), 1); + single_entry->text = dos_to_unix (mhl_str_dup (finfo->name), 1); single_entry->next = 0; #endif @@ -1424,7 +1427,7 @@ smbfs_get_stat_info (smbfs_connection * sc, const char *path, struct stat *buf) { char *mdp; char *mydir; - mdp = mydir = g_strdup (current_info->dirname); + mdp = mydir = mhl_str_dup (current_info->dirname); if ((p = strrchr (mydir, '/'))) *p = 0; /* advance util last '/' */ if ((p = strrchr (mydir, '/'))) @@ -1506,7 +1509,7 @@ smbfs_loaddir_by_name (struct vfs_class *me, const char *path) void *info; char *mypath, *p; - mypath = g_strdup(path); + mypath = mhl_str_dup(path); p = strrchr(mypath, '/'); if (p > mypath) diff --git a/vfs/tar.c b/vfs/tar.c index 5a65d55f0..12a4c8f34 100644 --- a/vfs/tar.c +++ b/vfs/tar.c @@ -22,10 +22,14 @@ /* Namespace: init_tarfs */ #include + #include #include #include +#include +#include + #ifdef hpux /* major() and minor() macros (among other things) defined here for hpux */ #include @@ -227,7 +231,7 @@ tar_open_archive_int (struct vfs_class *me, const char *name, ERRNOR (ENOENT, -1); } - archive->name = g_strdup (name); + archive->name = mhl_str_dup (name); mc_stat (name, &(archive->u.arch.st)); archive->u.arch.fd = -1; archive->u.arch.type = TAR_UNKNOWN; diff --git a/vfs/undelfs.c b/vfs/undelfs.c index 010e7d563..1af5cbbab 100644 --- a/vfs/undelfs.c +++ b/vfs/undelfs.c @@ -35,8 +35,8 @@ */ #include -#include +#include #include #include @@ -51,6 +51,8 @@ #include #include +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -140,7 +142,7 @@ undelfs_get_path (const char *dirname, char **fsname, char **file) if (*p == '/'){ char *tmp; - *file = g_strdup (p+1); + *file = mhl_str_dup (p+1); tmp = g_strndup (dirname, p - dirname); *fsname = g_strconcat ("/dev/", tmp, (char *) NULL); g_free (tmp); @@ -148,7 +150,7 @@ undelfs_get_path (const char *dirname, char **fsname, char **file) } p--; } - *file = g_strdup (""); + *file = mhl_str_dup (""); *fsname = g_strconcat ("/dev/", dirname, (char *) NULL); return; } diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c index 7bb5ca2a9..c1f4e1d8d 100644 --- a/vfs/utilvfs.c +++ b/vfs/utilvfs.c @@ -19,8 +19,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include + #include +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -55,7 +58,7 @@ vfs_split_url (const char *path, char **host, char **user, int *port, struct passwd *passwd_info; char *dir, *colon, *inner_colon, *at, *rest; char *retval; - char * const pcopy = g_strdup (path); + char * const pcopy = mhl_str_dup (path); const char *pend = pcopy + strlen (pcopy); if (pass) @@ -70,10 +73,10 @@ vfs_split_url (const char *path, char **host, char **user, int *port, while (*dir != PATH_SEP && *dir) dir++; if (*dir) { - retval = g_strdup (dir); + retval = mhl_str_dup (dir); *dir = 0; } else - retval = g_strdup (PATH_SEP_STR); + retval = mhl_str_dup (PATH_SEP_STR); } /* search for any possible user */ @@ -87,10 +90,10 @@ vfs_split_url (const char *path, char **host, char **user, int *port, *inner_colon = 0; inner_colon++; if (pass) - *pass = g_strdup (inner_colon); + *pass = mhl_str_dup (inner_colon); } if (*pcopy != 0) - *user = g_strdup (pcopy); + *user = mhl_str_dup (pcopy); if (pend == at + 1) rest = at; @@ -102,10 +105,10 @@ vfs_split_url (const char *path, char **host, char **user, int *port, if (!*user && !(flags & URL_ALLOW_ANON)) { passwd_info = getpwuid (geteuid ()); if (passwd_info && passwd_info->pw_name) - *user = g_strdup (passwd_info->pw_name); + *user = mhl_str_dup (passwd_info->pw_name); else { /* This is very unlikely to happen */ - *user = g_strdup ("anonymous"); + *user = mhl_str_dup ("anonymous"); } endpwent (); } @@ -131,7 +134,7 @@ vfs_split_url (const char *path, char **host, char **user, int *port, } } if (host) - *host = g_strdup (rest); + *host = mhl_str_dup (rest); g_free (pcopy); return retval; @@ -743,7 +746,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, s->st_mode |= perms; } - p_copy = g_strdup (p); + p_copy = mhl_str_dup (p); num_cols = vfs_split_text (p_copy); s->st_nlink = atol (columns[0]); @@ -842,7 +845,7 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, column_ptr[idx2] - column_ptr[idx] - 1); } if (linkname) { - t = g_strdup (p + column_ptr[idx2 + 1]); + t = mhl_str_dup (p + column_ptr[idx2 + 1]); *linkname = t; } } else { @@ -851,10 +854,10 @@ vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, */ if (filename) { /* - * filename = g_strdup (columns [idx++]); + * filename = mhl_str_dup (columns [idx++]); */ - t = g_strdup (p + column_ptr[idx]); + t = mhl_str_dup (p + column_ptr[idx]); *filename = t; } if (linkname) diff --git a/vfs/vfs.c b/vfs/vfs.c index 8ea71f77d..1c6bb5679 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Warning: funtions like extfs_lstat() have right to destroy any - * strings you pass to them. This is acutally ok as you g_strdup what + * strings you pass to them. This is acutally ok as you mhl_str_dup what * you are passing to them, anyway; still, beware. */ /* Namespace: exports *many* functions with vfs_ prefix; exports @@ -38,6 +38,8 @@ #include #include /* is_digit() */ +#include + #include "../src/global.h" #include "../src/tty.h" /* enable/disable interrupt key */ #include "../src/wtools.h" /* message() */ @@ -186,7 +188,7 @@ vfs_strip_suffix_from_filename (const char *filename) if (!filename) vfs_die ("vfs_strip_suffix_from_path got NULL: impossible"); - p = g_strdup (filename); + p = mhl_str_dup (filename); if (!(semi = strrchr (p, '#'))) return p; @@ -298,7 +300,7 @@ struct vfs_class * vfs_get_class (const char *pathname) { struct vfs_class *vfs; - char *path = g_strdup (pathname); + char *path = mhl_str_dup (pathname); vfs = _vfs_get_class (path); g_free (path); @@ -564,7 +566,7 @@ int mc_fstat (int handle, struct stat *buf) { /* * Return current directory. If it's local, reread the current directory - * from the OS. You must g_strdup() whatever this function returns. + * from the OS. You must mhl_str_dup() whatever this function returns. */ static const char * _vfs_get_cwd (void) @@ -594,7 +596,7 @@ _vfs_get_cwd (void) static void vfs_setup_wd (void) { - current_dir = g_strdup (PATH_SEP_STR); + current_dir = mhl_str_dup (PATH_SEP_STR); _vfs_get_cwd (); if (strlen (current_dir) > MC_MAXPATHLEN - 2) @@ -668,7 +670,7 @@ vfs_canon (const char *path) * /p1/p2#op/.././././p3#op/p4. Good luck. */ { - char *result = g_strdup (path); + char *result = mhl_str_dup (path); canonicalize_pathname (result); return result; } @@ -929,7 +931,7 @@ vfs_fill_names (fill_names_f func) /* * Returns vfs path corresponding to given url. If passed string is - * not recognized as url, g_strdup(url) is returned. + * not recognized as url, mhl_str_dup(url) is returned. */ static const struct { @@ -953,7 +955,7 @@ vfs_translate_url (const char *url) if (strncmp (url, url_table[i].name, url_table[i].name_len) == 0) return g_strconcat (url_table[i].substitute, url + url_table[i].name_len, (char*) NULL); - return g_strdup (url); + return mhl_str_dup (url); } int vfs_file_is_local (const char *filename)