updated: [9b9cab5] manually merged 234_remove_g_string



The following commit has been merged in the master branch:
commit 9b9cab58749217101ab16504a77efb301812cfbf
Merge: 8b38cf44daee3b0f92591baa97f36d722be99280 f235b1976ee6dd7aa2be7e75c870784c424e3de3
Author: Enrico Weigelt, metux IT service <weigelt metux de>
Date:   Mon Feb 2 22:39:12 2009 +0100

    manually merged 234_remove_g_string

diff --combined ChangeLog
index 174e3aa,abbe625..832520c
--- a/ChangeLog
+++ b/ChangeLog
@@@ -1,33 -1,14 +1,34 @@@
 -2009-01-31 Enrico Weigelt, metux ITS <weigelt metux de>
 +2009-02-01 Enrico Weigelt, metux ITS <weigelt metux de>
  
 +	* src/util.c: fixed name_trunc() on NULL or empty parameters
 +	* src/achown.c: fixed unitialized var in init_chown_advanced()
 +	  (patch from andrew_b)
 +	* replaced gboolean by bool (from mhl/types.h)
 +
 +2009-01-31 Enrico Weigelt, metux ITS <weigelt metux de>, Patrick Winnertz <winnie debian org>, Slava Zanko <slavazanko gmail com>, Sergei Trofimovich  <slyfox inbox ru>
 +
 +	* edit/editcmd.c, mhl/escape.h, mhl/string.h, mhl/types.h, src/Makefile.am,
 +	* src/boxes.c, src/command.c, src/complete.c, src/complete.h, src/file.c,
 +	* src/find.c, src/main.c, src/panelize.c, src/util.c, src/utilunix.c,
 +	* src/widget.c, src/widget.h, src/wtools.c, vfs/fish.c:
 +	  fixed shell escaping issues in commandline completion engine
  	* replaced buggy concat_dir_and_file() by mhl_str_dir_plus_file() (in mhl/string.h)
 +	* replaced g_snprintf() by snprintf()
+ 	* replaced GString stuff by static buffers
  
  2009-01-30 Enrico Weigelt, metux ITS <weigelt metux de>
  
  	* src/Makefile.am, edit/Makefile.am vfs/Makefile.am: fixed #208
  	  (out-of-tree builds)
 +	* syntax/Syntax, syntax/Makefile.am, syntax/vhdl.syntax: added VHDL syntax (#193)
 +	* replaced calls to g_strdup() by mhl_str_dup()
 +
 +2009-01-30 Enrico Weigelt, metux ITS <weigelt metux de>
 +
 +	* replaced calls to g_free() by mhl_mem_free()
  
  2009-01-29 Mikhail S. Pobolovets <styx mp gmail com>
 +
  	* lib/mc.ext.in: update for OpenOffice and StarOffice viewer.
  	  odt2txt is now used
  
@@@ -37,10 -18,8 +38,10 @@@
  	  This solves "strange" rename cases, when copying/moving is performed into
  	  deleted directory.
  
 -2009-01-27 Enrico Weigelt, metux IT service <weigelt metux de>
 +2009-01-27 Enrico Weigelt, metux ITS <weigelt metux de>
  
 +	* mhl/escape.h, src/complete.c, vfs/fish.c: introduced new type 
 +	  SHELL_ESCAPED_STR for more type safety
  	* mhl/escape.h, mhl/string.h: fixed comments to use /* ... */
  
  2009-01-27 Sergei Trofimovich  <slyfox inbox ru>
@@@ -68,7 -47,7 +69,7 @@@
  	* src/cmd.c src/option.c src/setup.c src/main.h: Automatic new directory(Mkdir, F7)
  	  name filling. Can be configured (on|off) in 'Configure options'
  
 -2009-01-25 Enrico Weigelt <weigelt metux de>
 +2009-01-25 Enrico Weigelt, metux ITS <weigelt metux de>
  
  	* edit/editcmd.c, src/cmd.c, src/ext.c, src/history.h:
  	* src/hotlist.c, src/panelize.c, src/tree.c, src/user.c: 
@@@ -77,11 -56,9 +78,11 @@@
  	  translated strings. This breaks now once every history file
  	  but afterwards this will be stable
  
 -2009-01-24 Enrico Weigelt <weigelt metux de>
 +2009-01-24 Enrico Weigelt, metux ITS <weigelt metux de>
  
  	* src/cmd.c: fixed bug #35 (do_view_cmd is now calling repaint_screen())
 +	* syntax/Syntax, syntax/nemerle.syntax: Added syntax rules 
 +	  for Nemerle source files
  
  2009-01-24 Patrick Winnertz <winnie debian org>
  
@@@ -89,6 -66,11 +90,6 @@@
  	  - prevent . to match a newline (\n)
  	  - match from start of line and not from cursor position
  
 -2009-01-24  Enrico Weigelt, metux IT service <weigelt metux de>
 -
 -	* syntax/Syntax, syntax/nemerle.syntax: Added syntax rules 
 -	  for Nemerle source files
 -
  2009-01-19 Patrick Winnertz <winnie debian org>
  
  	* edit/edit.h: Add two more ints
@@@ -103,7 -85,7 +104,7 @@@
  	* src/main.c: Removed unused function do_mc_filename_rename
  	* src/util.c: Removed unused struct whentm
  
 -2009-01-16 Enrico Weigelt, metux IT service <weigelt metux de>
 +2009-01-16 Enrico Weigelt, metux ITS <weigelt metux de>
  
  	* src/subshell: setting subshell pty to close-on-exec 
  	  (taken from mandriva patches)
@@@ -141,6 -123,9 +142,6 @@@
  	* syntax/Makefile.am syntax/Syntax syntax/haskell.syntax:
  	added syntax definition for Haskell (taken from rhclub-tree)
  	* syntax: added ebuild Syntax defition (taken from rhclub-tree)
 -
 -2009-01-10  Enrico Weigelt, metux ITS <weigelt metux de>
 -
  	* edit/editcmd.c:
  	* src/achown.c src/background.c src/boxes.c src/chmod.c:
  	* src/chown.c src/cmd.c src/command.c src/dir.c src/execute.c:
diff --combined edit/edit.c
index 82cca0d,1f8d851..36284df
--- a/edit/edit.c
+++ b/edit/edit.c
@@@ -22,7 -22,6 +22,7 @@@
  */
  
  #include <config.h>
 +
  #include <stdio.h>
  #include <stdarg.h>
  #include <sys/types.h>
@@@ -33,7 -32,6 +33,7 @@@
  #include <sys/stat.h>
  #include <stdlib.h>
  
 +#include <mhl/memory.h>
  #include <mhl/string.h>
  
  #include "../src/global.h"
@@@ -153,10 -151,9 +153,9 @@@ edit_load_file_fast (WEdit *edit, cons
      buf2 = edit->curs2 >> S_EDIT_BUF_SIZE;
  
      if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) {
- 	GString *errmsg = g_string_new(NULL);
- 	g_string_sprintf(errmsg, _(" Cannot open %s for reading "), filename);
- 	edit_error_dialog (_("Error"), get_sys_error (errmsg->str));
- 	g_string_free (errmsg, TRUE);
+ 	char errmsg[8192];
+ 	snprintf(errmsg, sizeof(errmsg), _(" Cannot open %s for reading "), filename);
+ 	edit_error_dialog (_("Error"), get_sys_error (errmsg));
  	return 1;
      }
  
@@@ -219,7 -216,7 +218,7 @@@ edit_get_filter (const char *filename
      l = strlen (quoted_name);
      p = g_malloc (strlen (all_filters[i].read) + l + 2);
      sprintf (p, all_filters[i].read, quoted_name);
 -    g_free (quoted_name);
 +    mhl_mem_free (quoted_name);
      return p;
  }
  
@@@ -235,7 -232,7 +234,7 @@@ edit_get_write_filter (const char *writ
      l = strlen (writename);
      p = g_malloc (strlen (all_filters[i].write) + l + 2);
      sprintf (p, all_filters[i].write, writename);
 -    g_free (writename);
 +    mhl_mem_free (writename);
      return p;
  }
  
@@@ -275,22 -272,20 +274,20 @@@ edit_insert_file (WEdit *edit, const ch
  	    edit_insert_stream (edit, f);
  	    edit_cursor_move (edit, current - edit->curs1);
  	    if (pclose (f) > 0) {
- 	        GString *errmsg = g_string_new (NULL);
- 		g_string_sprintf (errmsg, _(" Error reading from pipe: %s "), p);
- 		edit_error_dialog (_("Error"), errmsg->str);
- 		g_string_free (errmsg, TRUE);
+ 		char errmsg[8192];
+ 		snprintf(errmsg, sizeof(errmsg), _(" Error reading from pipe: %s "), p);
+ 		edit_error_dialog (_("Error"), errmsg);
 -		g_free (p);
 +		mhl_mem_free (p);
  		return 0;
  	    }
  	} else {
- 	    GString *errmsg = g_string_new (NULL);
- 	    g_string_sprintf (errmsg, _(" Cannot open pipe for reading: %s "), p);
- 	    edit_error_dialog (_("Error"), errmsg->str);
- 	    g_string_free (errmsg, TRUE);
+ 	    char errmsg[8192];
+ 	    snprintf(errmsg, sizeof(errmsg), _(" Cannot open pipe for reading: %s "), p);
+ 	    edit_error_dialog (_("Error"), errmsg);
 -	    g_free (p);
 +	    mhl_mem_free (p);
  	    return 0;
  	}
 -	g_free (p);
 +	mhl_mem_free (p);
      } else {
  	int i, file, blocklen;
  	long current = edit->curs1;
@@@ -303,7 -298,7 +300,7 @@@
  		edit_insert (edit, buf[i]);
  	}
  	edit_cursor_move (edit, current - edit->curs1);
 -	g_free (buf);
 +	mhl_mem_free (buf);
  	mc_close (file);
  	if (blocklen)
  	    return 0;
@@@ -316,7 -311,8 +313,8 @@@ static in
  check_file_access (WEdit *edit, const char *filename, struct stat *st)
  {
      int file;
-     GString *errmsg = (GString *) 0;
+     char errmsg[8192];
+     errmsg[0] = 0;
  
      /* Try opening an existing file */
      file = mc_open (filename, O_NONBLOCK | O_RDONLY | O_BINARY, 0666);
@@@ -331,8 -327,7 +329,7 @@@
  		     O_NONBLOCK | O_RDONLY | O_BINARY | O_CREAT | O_EXCL,
  		     0666);
  	if (file < 0) {
- 	    g_string_sprintf (errmsg = g_string_new (NULL),
- 		_(" Cannot open %s for reading "), filename);
+ 	    snprintf (errmsg, sizeof(errmsg), _(" Cannot open %s for reading "), filename);
  	    goto cleanup;
  	} else {
  	    /* New file, delete it if it's not modified or saved */
@@@ -342,15 -337,13 +339,13 @@@
  
      /* Check what we have opened */
      if (mc_fstat (file, st) < 0) {
- 	g_string_sprintf (errmsg = g_string_new (NULL),
- 	    _(" Cannot get size/permissions for %s "), filename);
+ 	snprintf (errmsg, sizeof(errmsg), _(" Cannot get size/permissions for %s "), filename);
  	goto cleanup;
      }
  
      /* We want to open regular files only */
      if (!S_ISREG (st->st_mode)) {
- 	g_string_sprintf (errmsg = g_string_new (NULL),
- 	    _(" %s is not a regular file "), filename);
+ 	snprintf (errmsg, sizeof(errmsg), _(" %s is not a regular file "), filename);
  	goto cleanup;
      }
  
@@@ -363,16 -356,14 +358,14 @@@
      }
  
      if (st->st_size >= SIZE_LIMIT) {
-         g_string_sprintf (errmsg = g_string_new (NULL),
- 	    _(" File %s is too large "), filename);
+ 	snprintf (errmsg, sizeof(errmsg), _(" File %s is too large "), filename);
  	goto cleanup;
      }
  
  cleanup:
      (void) mc_close (file);
-     if (errmsg) {
- 	edit_error_dialog (_("Error"), errmsg->str);
- 	g_string_free (errmsg, TRUE);
+     if (errmsg[0]) {
+ 	edit_error_dialog (_("Error"), errmsg);
  	return 1;
      }
      return 0;
@@@ -450,7 -441,7 +443,7 @@@ edit_load_position (WEdit *edit
  
      filename = vfs_canon (edit->filename);
      load_file_position (filename, &line, &column);
 -    g_free (filename);
 +    mhl_mem_free (filename);
  
      edit_move_to_line (edit, line - 1);
      edit->prev_col = column;
@@@ -469,7 -460,7 +462,7 @@@ edit_save_position (WEdit *edit
  
      filename = vfs_canon (edit->filename);
      save_file_position (filename, edit->curs_line + 1, edit->curs_col);
 -    g_free (filename);
 +    mhl_mem_free (filename);
  }
  
  /* Clean the WEdit stricture except the widget part */
@@@ -543,7 -534,7 +536,7 @@@ edit_init (WEdit *edit, int lines, int 
      if (edit_load_file (edit)) {
  	/* edit_load_file already gives an error message */
  	if (to_free)
 -	    g_free (edit);
 +	    mhl_mem_free (edit);
  	return 0;
      }
      edit->loading_done = 1;
@@@ -594,13 -585,13 +587,13 @@@ edit_clean (WEdit *edit
      edit_free_syntax_rules (edit);
      book_mark_flush (edit, -1);
      for (; j <= MAXBUFF; j++) {
 -	g_free (edit->buffers1[j]);
 -	g_free (edit->buffers2[j]);
 +	mhl_mem_free (edit->buffers1[j]);
 +	mhl_mem_free (edit->buffers2[j]);
      }
  
 -    g_free (edit->undo_stack);
 -    g_free (edit->filename);
 -    g_free (edit->dir);
 +    mhl_mem_free (edit->undo_stack);
 +    mhl_mem_free (edit->filename);
 +    mhl_mem_free (edit->dir);
  
      edit_purge_widget (edit);
  
@@@ -640,12 -631,12 +633,12 @@@ edit_reload (WEdit *edit, const char *f
      e = g_malloc0 (sizeof (WEdit));
      e->widget = edit->widget;
      if (!edit_init (e, lines, columns, filename, 0)) {
 -	g_free (e);
 +	mhl_mem_free (e);
  	return 0;
      }
      edit_clean (edit);
      memcpy (edit, e, sizeof (WEdit));
 -    g_free (e);
 +    mhl_mem_free (e);
      return 1;
  }
  
@@@ -931,7 -922,7 +924,7 @@@ int edit_delete (WEdit * edit
      p = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1];
  
      if (!(edit->curs2 & M_EDIT_BUF_SIZE)) {
 -	g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
 +	mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
  	edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = NULL;
      }
      edit->last_byte--;
@@@ -968,7 -959,7 +961,7 @@@ edit_backspace (WEdit * edit
  
      p = *(edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE] + ((edit->curs1 - 1) & M_EDIT_BUF_SIZE));
      if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) {
 -	g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
 +	mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
  	edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL;
      }
      edit->last_byte--;
@@@ -1053,7 -1044,7 +1046,7 @@@ edit_move_backward_lots (WEdit *edit, l
  	    edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] =
  		g_malloc (EDIT_BUF_SIZE);
      } else {
 -	g_free (p);
 +	mhl_mem_free (p);
      }
  
      s = edit->curs1 & M_EDIT_BUF_SIZE;
@@@ -1091,7 -1082,7 +1084,7 @@@
  		edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] =
  		    g_malloc (EDIT_BUF_SIZE);
  	} else {
 -	    g_free (p);
 +	    mhl_mem_free (p);
  	}
      }
      return edit_get_byte (edit, edit->curs1);
@@@ -1127,7 -1118,7 +1120,7 @@@ void edit_cursor_move (WEdit * edit, lo
  	    edit->curs2++;
  	    c = edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 - 1) & M_EDIT_BUF_SIZE];
  	    if (!((edit->curs1 - 1) & M_EDIT_BUF_SIZE)) {
 -		g_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
 +		mhl_mem_free (edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE]);
  		edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = NULL;
  	    }
  	    edit->curs1--;
@@@ -1151,7 -1142,7 +1144,7 @@@
  	    edit->curs1++;
  	    c = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1];
  	    if (!(edit->curs2 & M_EDIT_BUF_SIZE)) {
 -		g_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
 +		mhl_mem_free (edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE]);
  		edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = 0;
  	    }
  	    edit->curs2--;
@@@ -2701,5 -2692,5 +2694,5 @@@ user_menu (WEdit * edit
      edit->force |= REDRAW_COMPLETELY;
  
  cleanup:
 -    g_free (block_file);
 +    mhl_mem_free (block_file);
  }
diff --combined edit/editcmd.c
index 2f246e7,ec9a931..518dc54
--- a/edit/editcmd.c
+++ b/edit/editcmd.c
@@@ -37,7 -37,6 +37,7 @@@
  #include <sys/stat.h>
  #include <stdlib.h>
  
 +#include <mhl/memory.h>
  #include <mhl/string.h>
  
  #include "../src/global.h"
@@@ -167,7 -166,7 +167,7 @@@ catstrs (const char *first,...
      len++;
  
      i = (i + 1) % 16;
 -    g_free (stacked[i]);
 +    mhl_mem_free (stacked[i]);
  
      stacked[i] = g_malloc (len);
      va_end (ap);
@@@ -186,7 -185,7 +186,7 @@@ void freestrs(void
      size_t i;
  
      for (i = 0; i < sizeof(stacked) / sizeof(stacked[0]); i++) {
 -	g_free (stacked[i]);
 +	mhl_mem_free (stacked[i]);
  	stacked[i] = NULL;
      }
  }
@@@ -238,7 -237,7 +238,7 @@@ edit_save_file (WEdit *edit, const cha
      if (*filename != PATH_SEP && edit->dir) {
  	savename = mhl_str_dir_plus_file (edit->dir, filename);
  	filename = catstrs (savename, (char *) NULL);
 -	g_free (savename);
 +	mhl_mem_free (savename);
      }
  
      this_save_mode = option_save_mode;
@@@ -298,14 -297,14 +298,14 @@@
  	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 = mhl_str_dir_plus_file (savedir, "cooledit");
 -	g_free (savedir);
 +	mhl_mem_free (savedir);
  	fd = mc_mkstemps (&savename, saveprefix, NULL);
 -	g_free (saveprefix);
 +	mhl_mem_free (saveprefix);
  	if (!savename)
  	    return 0;
  	/* FIXME:
@@@ -315,7 -314,7 +315,7 @@@
  	 */
  	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);
@@@ -341,7 -340,7 +341,7 @@@
  		edit_error_dialog (_("Error"),
  				   catstrs (_(" Error writing to pipe: "),
  					    p, " ", (char *) NULL));
 -		g_free (p);
 +		mhl_mem_free (p);
  		goto error_save;
  	    }
  #endif
@@@ -351,10 -350,10 +351,10 @@@
  					      (_
  					       (" Cannot open pipe for writing: "),
  					       p, " ", (char *) NULL)));
 -	    g_free (p);
 +	    mhl_mem_free (p);
  	    goto error_save;
  	}
 -	g_free (p);
 +	mhl_mem_free (p);
      } else {
  	long buf;
  	buf = 0;
@@@ -415,14 -414,14 +415,14 @@@
      if (this_save_mode != EDIT_QUICK_SAVE)
  	if (mc_rename (savename, filename) == -1)
  	    goto error_save;
 -    g_free (savename);
 +    mhl_mem_free (savename);
      return 1;
    error_save:
  /*  FIXME: Is this safe ?
   *  if (this_save_mode != EDIT_QUICK_SAVE)
   *	mc_unlink (savename);
   */
 -    g_free (savename);
 +    mhl_mem_free (savename);
      return 0;
  }
  
@@@ -493,7 -492,7 +493,7 @@@ void menu_save_mode_cmd (void
  	return;
      option_save_mode = save_mode_new;
  
 -    g_free (option_backup_ext);
 +    mhl_mem_free (option_backup_ext);
      option_backup_ext = str_result;
      str_result = NULL;
  }
@@@ -501,13 -500,13 +501,13 @@@
  void
  edit_set_filename (WEdit *edit, const char *f)
  {
 -    g_free (edit->filename);
 +    mhl_mem_free (edit->filename);
      if (!f)
  	f = "";
 -    edit->filename = g_strdup (f);
 +    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
@@@ -530,7 -529,7 +530,7 @@@ edit_save_as_cmd (WEdit *edit
  
      if (exp) {
  	if (!*exp) {
 -	    g_free (exp);
 +	    mhl_mem_free (exp);
  	    edit->force |= REDRAW_COMPLETELY;
  	    return 0;
  	} else {
@@@ -547,7 -546,7 +547,7 @@@
  			 _(" A file already exists with this name. "),
  			 _("&Overwrite"), _("&Cancel"))) {
  			edit->force |= REDRAW_COMPLETELY;
 -			g_free (exp);
 +			mhl_mem_free (exp);
  			return 0;
  		    }
  		}
@@@ -573,7 -572,7 +573,7 @@@
  		}
  
  		edit_set_filename (edit, exp);
 -		g_free (exp);
 +		mhl_mem_free (exp);
  		edit->modified = 0;
  		edit->delete_file = 0;
  		if (different_filename)
@@@ -589,7 -588,7 +589,7 @@@
  		/* Failed, so maintain modify (not save) lock */
  		if (save_lock)
  		    edit_unlock_file (exp);
 -		g_free (exp);
 +		mhl_mem_free (exp);
  		edit->force |= REDRAW_COMPLETELY;
  		return 0;
  	    }
@@@ -627,7 -626,7 +627,7 @@@ edit_raw_key_query (const char *heading
  		    NULL, heading,
  		    DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
      add_widget (raw_dlg,
 -		input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0));
 +		input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0, INPUT_COMPLETE_DEFAULT));
      add_widget (raw_dlg, label_new (3 - cancel, 2, query));
      if (cancel)
  	add_widget (raw_dlg,
@@@ -878,16 -877,16 +878,16 @@@ static in
  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);
 +	mhl_mem_free (prev_filename);
  	return 1;
      }
  
      if (prev_locked)
  	edit_unlock_file (prev_filename);
 -    g_free (prev_filename);
 +    mhl_mem_free (prev_filename);
      return 0;
  }
  
@@@ -913,7 -912,7 +913,7 @@@ edit_load_cmd (WEdit *edit
      if (exp) {
  	if (*exp)
  	    edit_load_file_from_filename (edit, exp);
 -	g_free (exp);
 +	mhl_mem_free (exp);
      }
      edit->force |= REDRAW_COMPLETELY;
      return 0;
@@@ -1014,7 -1013,7 +1014,7 @@@ edit_block_copy_cmd (WEdit *edit
  	    edit_insert_ahead (edit, copy_buf[size]);
      }
  
 -    g_free (copy_buf);
 +    mhl_mem_free (copy_buf);
      edit_scroll_screen_over_cursor (edit);
  
      if (column_highlighting) {
@@@ -1115,7 -1114,7 +1115,7 @@@ edit_block_move_cmd (WEdit *edit
  			  edit->curs1 + end_mark - start_mark, 0, 0);
      }
      edit_scroll_screen_over_cursor (edit);
 -    g_free (copy_buf);
 +    mhl_mem_free (copy_buf);
      edit->force |= REDRAW_PAGE;
  }
  
@@@ -1236,14 -1235,16 +1236,16 @@@ edit_replace_prompt (WEdit * edit, cha
  	 0, 0, 0, 0, 0},
  	 NULL_QuickWidget};
  
-     GString *label_text = g_string_new (_(" Replace with: "));
-     if (*replace_text) {
-         size_t label_len;
- 	label_len = label_text->len;
-         g_string_append (label_text, replace_text);
-         convert_to_display (label_text->str + label_len);
+     const char* label_nls = _(" Replace with: ");
+     char label_text[8192];
+     if (*replace_text)
+     {
+ 	size_t label_len = strlen(label_nls);
+ 	snprintf(label_text, sizeof(label_text), "%s%s", label_nls, replace_text);
+ 	convert_to_display((&label_text)+label_len);
      }
-     quick_widgets[5].text = label_text->str;
+ 
+     quick_widgets[5].text = label_text;
  
      {
  	int retval;
@@@ -1262,7 -1263,6 +1264,6 @@@
  
  	Quick_input.ypos = ypos;
  	retval = quick_dialog (&Quick_input);
- 	g_string_free (label_text, TRUE);
  	return retval;
      }
  }
@@@ -1451,7 -1451,7 +1452,7 @@@ string_regexp_search (char *pattern, ch
  	|| old_type != match_type || old_icase != icase) {
  	if (old_pattern) {
  	    regfree (&r);
 -	    g_free (old_pattern);
 +	    mhl_mem_free (old_pattern);
  	    old_pattern = 0;
  	}
  	if (regcomp (&r, pattern, REG_EXTENDED | (icase ? REG_ICASE : 0) |
@@@ -1459,7 -1459,7 +1460,7 @@@
  	    *found_len = 0;
  	    return -3;
  	}
 -	old_pattern = g_strdup (pattern);
 +	old_pattern = mhl_str_dup (pattern);
  	old_type = match_type;
  	old_icase = icase;
      }
@@@ -1827,9 -1827,9 +1828,9 @@@ edit_replace_cmd (WEdit *edit, int agai
      int argord[NUM_REPL_ARGS];
  
      if (!edit) {
 -	g_free (saved1), saved1 = NULL;
 -	g_free (saved2), saved2 = NULL;
 -	g_free (saved3), saved3 = NULL;
 +	mhl_mem_free (saved1), saved1 = NULL;
 +	mhl_mem_free (saved2), saved2 = NULL;
 +	mhl_mem_free (saved3), saved3 = NULL;
  	return;
      }
  
@@@ -1841,13 -1841,13 +1842,13 @@@
  	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);
@@@ -1857,9 -1857,9 +1858,9 @@@
  	edit_replace_dialog (edit, disp1, disp2, disp3, &input1, &input2,
  			     &input3);
  
 -	g_free (disp1);
 -	g_free (disp2);
 -	g_free (disp3);
 +	mhl_mem_free (disp1);
 +	mhl_mem_free (disp2);
 +	mhl_mem_free (disp3);
  
  	convert_from_input (input1);
  	convert_from_input (input2);
@@@ -1871,9 -1871,10 +1872,9 @@@
  	    goto cleanup;
  	}
  
 -	g_free (saved1), saved1 = g_strdup (input1);
 -	g_free (saved2), saved2 = g_strdup (input2);
 -	g_free (saved3), saved3 = g_strdup (input3);
 -
 +	mhl_mem_free (saved1), saved1 = mhl_str_dup (input1);
 +	mhl_mem_free (saved2), saved2 = mhl_str_dup (input2);
 +	mhl_mem_free (saved3), saved3 = mhl_str_dup (input3);
      }
  
      {
@@@ -2064,9 -2065,9 +2065,9 @@@
      edit->force = REDRAW_COMPLETELY;
      edit_scroll_screen_over_cursor (edit);
    cleanup:
 -    g_free (input1);
 -    g_free (input2);
 -    g_free (input3);
 +    mhl_mem_free (input1);
 +    mhl_mem_free (input2);
 +    mhl_mem_free (input3);
  }
  
  
@@@ -2078,7 -2079,7 +2079,7 @@@ void edit_search_cmd (WEdit * edit, in
      char *exp = "";
  
      if (!edit) {
 -	g_free (old);
 +	mhl_mem_free (old);
  	old = NULL;
  	return;
      }
@@@ -2087,7 -2088,7 +2088,7 @@@
      if (again) {		/*ctrl-hotkey for search again. */
  	if (!old)
  	    return;
 -	exp = g_strdup (old);
 +	exp = mhl_str_dup (old);
      } else {
  
  #ifdef HAVE_CHARSET
@@@ -2108,8 -2109,8 +2109,8 @@@
      if (exp) {
  	if (*exp) {
  	    int len = 0;
 -	    g_free (old);
 -	    old = g_strdup (exp);
 +	    mhl_mem_free (old);
 +	    old = mhl_str_dup (exp);
  
  	    if (search_create_bookmark) {
  		int found = 0, books = 0;
@@@ -2165,7 -2166,7 +2166,7 @@@
  		}
  	    }
  	}
 -	g_free (exp);
 +	mhl_mem_free (exp);
      }
      edit->force |= REDRAW_COMPLETELY;
      edit_scroll_screen_over_cursor (edit);
@@@ -2204,7 -2205,7 +2205,7 @@@ edit_ok_to_exit (WEdit *edit
  
  #define TEMP_BUF_LEN 1024
  
 -/* Return a null terminated length of text. Result must be g_free'd */
 +/* Return a null terminated length of text. Result must be mhl_mem_free'd */
  static unsigned char *
  edit_get_block (WEdit *edit, long start, long finish, int *l)
  {
@@@ -2257,7 -2258,7 +2258,7 @@@ edit_save_block (WEdit * edit, const ch
  	    p += r;
  	    len -= r;
  	}
 -	g_free (block);
 +	mhl_mem_free (block);
      } else {
  	unsigned char *buf;
  	int i = start, end;
@@@ -2270,7 -2271,7 +2271,7 @@@
  	    len -= mc_write (file, (char *) buf, end - start);
  	    start = end;
  	}
 -	g_free (buf);
 +	mhl_mem_free (buf);
      }
      mc_close (file);
      if (len)
@@@ -2337,20 -2338,20 +2338,20 @@@ edit_goto_cmd (WEdit *edit
      char *error;
      char s[32];
  
 -    g_snprintf (s, sizeof (s), "%ld", line);
 +    snprintf (s, sizeof (s), "%ld", line);
      f = input_dialog (_(" Goto line "), _(" Enter line: "), MC_HISTORY_EDIT_GOTO_LINE,
  		      line ? s : "");
      if (!f)
  	return;
  
      if (!*f) {
 -	g_free (f);
 +	mhl_mem_free (f);
  	return;
      }
  
      l = strtol (f, &error, 0);
      if (*error) {
 -	g_free (f);
 +	mhl_mem_free (f);
  	return;
      }
  
@@@ -2360,7 -2361,7 +2361,7 @@@
      edit_move_display (edit, l - edit->num_widget_lines / 2 - 1);
      edit_move_to_line (edit, l - 1);
      edit->force |= REDRAW_COMPLETELY;
 -    g_free (f);
 +    mhl_mem_free (f);
  }
  
  
@@@ -2379,15 -2380,15 +2380,15 @@@ edit_save_block_cmd (WEdit *edit
      edit_push_action (edit, KEY_PRESS + edit->start_display);
      if (exp) {
  	if (!*exp) {
 -	    g_free (exp);
 +	    mhl_mem_free (exp);
  	    return 0;
  	} else {
  	    if (edit_save_block (edit, exp, start_mark, end_mark)) {
 -		g_free (exp);
 +		mhl_mem_free (exp);
  		edit->force |= REDRAW_COMPLETELY;
  		return 1;
  	    } else {
 -		g_free (exp);
 +		mhl_mem_free (exp);
  		edit_error_dialog (_(" Save Block "),
  				   get_sys_error (_
  						  (" Cannot save file. ")));
@@@ -2409,15 -2410,15 +2410,15 @@@ edit_insert_file_cmd (WEdit *edit
      edit_push_action (edit, KEY_PRESS + edit->start_display);
      if (exp) {
  	if (!*exp) {
 -	    g_free (exp);
 +	    mhl_mem_free (exp);
  	    return 0;
  	} else {
  	    if (edit_insert_file (edit, exp)) {
 -		g_free (exp);
 +		mhl_mem_free (exp);
  		edit->force |= REDRAW_COMPLETELY;
  		return 1;
  	    } else {
 -		g_free (exp);
 +		mhl_mem_free (exp);
  		edit_error_dialog (_(" Insert File "),
  				   get_sys_error (_
  						  (" Cannot insert file. ")));
@@@ -2448,7 -2449,7 +2449,7 @@@ int edit_sort_cmd (WEdit * edit
  
      if (!exp)
  	return 1;
 -    g_free (old);
 +    mhl_mem_free (old);
      old = exp;
  
      e = system (catstrs (" sort ", exp, " ", home_dir, PATH_SEP_STR BLOCK_FILE, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL));
@@@ -2492,7 -2493,7 +2493,7 @@@ edit_ext_cmd (WEdit *edit
  	return 1;
  
      e = system (catstrs (exp, " > ", home_dir, PATH_SEP_STR TEMP_FILE, (char *) NULL));
 -    g_free (exp);
 +    mhl_mem_free (exp);
  
      if (e) {
  	edit_error_dialog (_("External command"),
@@@ -2588,7 -2589,7 +2589,7 @@@ edit_block_process_cmd (WEdit *edit, co
  	system (catstrs (" ", home_dir, PATH_SEP_STR EDIT_DIR, shell_cmd, " ",
  			 quoted_name, (char *) NULL));
      }
 -    g_free (quoted_name);
 +    mhl_mem_free (quoted_name);
      close_error_pipe (D_NORMAL, NULL);
  
      edit_refresh_cmd (edit);
@@@ -2629,13 -2630,13 +2630,13 @@@ static void pipe_mail (WEdit *edit, cha
      subject = name_quote (subject, 0);
      cc = name_quote (cc, 0);
      s = g_strconcat ("mail -s ", subject, *cc ? " -c " : "" , cc, " ",  to, (char *) NULL);
 -    g_free (to);
 -    g_free (subject);
 -    g_free (cc);
 +    mhl_mem_free (to);
 +    mhl_mem_free (subject);
 +    mhl_mem_free (cc);
  
      if (s) {
  	p = popen (s, "w");
 -	g_free (s);
 +	mhl_mem_free (s);
      }
  
      if (p) {
@@@ -2694,9 -2695,9 +2695,9 @@@ void edit_mail_dialog (WEdit * edit
      Quick_input.widgets = quick_widgets;
  
      if (quick_dialog (&Quick_input) != B_CANCEL) {
 -	g_free (mail_cc_last);
 -	g_free (mail_subject_last);
 -	g_free (mail_to_last);
 +	mhl_mem_free (mail_cc_last);
 +	mhl_mem_free (mail_subject_last);
 +	mhl_mem_free (mail_to_last);
  	mail_cc_last = tmail_cc;
  	mail_subject_last = tmail_subject;
  	mail_to_last = tmail_to;
@@@ -2938,10 -2939,10 +2939,10 @@@ edit_complete_word_cmd (WEdit *edit
  	}
      }
  
 -    g_free (match_expr);
 +    mhl_mem_free (match_expr);
      /* release memory before return */
      for (i = 0; i < num_compl; i++)
 -	g_free (compl[i].text);
 +	mhl_mem_free (compl[i].text);
  
      /* restore search parameters */
      edit_set_search_parameters (old_rs, old_rb, old_rr, old_rw, old_rc);
diff --combined edit/syntax.c
index 479f3c5,4aa62f8..5de3aaf
--- a/edit/syntax.c
+++ b/edit/syntax.c
@@@ -32,7 -32,6 +32,7 @@@
  #include <sys/stat.h>
  #include <stdlib.h>
  
 +#include <mhl/memory.h>
  #include <mhl/string.h>
  
  #include "../src/global.h"
@@@ -104,6 -103,8 +104,6 @@@ int option_syntax_highlighting = 1
  int option_auto_syntax = 1;
  char *option_syntax_type = NULL;
  
 -#define syntax_g_free(x) do {g_free(x); (x)=0;} while (0)
 -
  static gint
  mc_defines_destroy (gpointer key, gpointer value, gpointer data)
  {
@@@ -111,10 -112,10 +111,10 @@@
  
      (void) data;
  
 -    g_free (key);
 +    mhl_mem_free (key);
      while (*values)
 -	g_free (*values++);
 -    g_free (value);
 +	mhl_mem_free (*values++);
 +    mhl_mem_free (value);
  
      return FALSE;
  }
@@@ -471,7 -472,7 +471,7 @@@ static struct syntax_rule edit_get_rul
  		break;
  	    }
  	    s = edit->syntax_marker->next;
 -	    syntax_g_free (edit->syntax_marker);
 +	    MHL_PTR_FREE (edit->syntax_marker);
  	    edit->syntax_marker = s;
  	}
      }
@@@ -505,10 -506,14 +505,14 @@@ void edit_get_syntax_color (WEdit * edi
   */
  static int read_one_line (char **line, FILE * f)
  {
-     GString *p = g_string_new ("");
-     int c, r = 0;
+     char buffer[8192];
+     int index = 0, c, r = 0;
+     buffer[0] = 0;
  
      for (;;) {
+ 	if (index >= (sizeof(buffer)-1))
+ 	    break;
+ 
  	c = fgetc (f);
  	if (c == EOF) {
  	    if (ferror (f)) {
@@@ -530,13 -535,11 +534,11 @@@
  	if (c == '\n')
  	    break;
  
- 	g_string_append_c (p, c);
+ 	buffer[index] = c;
+ 	index++;
      }
      if (r != 0) {
- 	*line = p->str;
- 	g_string_free (p, FALSE);
-     } else {
- 	g_string_free (p, TRUE);
+ 	*line = mhl_str_dup(buffer);
      }
      return r;
  }
@@@ -666,19 -669,19 +668,19 @@@ static FILE *open_include_file (const c
  {
      FILE *f;
  
 -    syntax_g_free (error_file_name);
 -    error_file_name = g_strdup (filename);
 +    MHL_PTR_FREE (error_file_name);
 +    error_file_name = mhl_str_dup (filename);
      if (*filename == PATH_SEP)
  	return fopen (filename, "r");
  
 -    g_free (error_file_name);
 +    mhl_mem_free (error_file_name);
      error_file_name = g_strconcat (home_dir, PATH_SEP_STR EDIT_DIR PATH_SEP_STR,
  				   filename, (char *) NULL);
      f = fopen (error_file_name, "r");
      if (f)
  	return f;
  
 -    g_free (error_file_name);
 +    mhl_mem_free (error_file_name);
      error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR,
  				   filename, (char *) NULL);
      return fopen (error_file_name, "r");
@@@ -725,8 -728,8 +727,8 @@@ edit_read_syntax_rules (WEdit *edit, FI
  		f = g;
  		g = 0;
  		line = save_line + 1;
 -		syntax_g_free (error_file_name);
 -		syntax_g_free (l);
 +		MHL_PTR_FREE (error_file_name);
 +		MHL_PTR_FREE (l);
  		if (!read_one_line (&l, f))
  		    break;
  	    } else {
@@@ -745,7 -748,7 +747,7 @@@
  	    g = f;
  	    f = open_include_file (args[1]);
  	    if (!f) {
 -		syntax_g_free (error_file_name);
 +		MHL_PTR_FREE (error_file_name);
  		result = line;
  		break;
  	    }
@@@ -773,8 -776,8 +775,8 @@@
  		}
  		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 -790,14 +789,14 @@@
  		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 -805,14 +804,14 @@@
  		    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 -829,7 +828,7 @@@
  	    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 -855,14 +854,14 @@@
  	    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 -873,7 +872,7 @@@
  	    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,22 -913,22 +912,22 @@@
  	    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 */
  	    break_a;
  	}
  	free_args (args);
 -	syntax_g_free (l);
 +	MHL_PTR_FREE (l);
      }
      free_args (args);
 -    syntax_g_free (l);
 +    MHL_PTR_FREE (l);
  
      /* Terminate context array.  */
      if (num_contexts > 0) {
@@@ -934,7 -937,7 +936,7 @@@
      }
  
      if (!edit->rules[0])
 -	syntax_g_free (edit->rules);
 +	MHL_PTR_FREE (edit->rules);
  
      if (result)
  	return result;
@@@ -955,10 -958,10 +957,10 @@@
  	    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);
 +	mhl_mem_free (first_chars);
      }
  
      return result;
@@@ -976,34 -979,34 +978,34 @@@ void edit_free_syntax_rules (WEdit * ed
  	return;
  
      edit_get_rule (edit, -1);
 -    syntax_g_free (edit->syntax_type);
 +    MHL_PTR_FREE (edit->syntax_type);
      edit->syntax_type = 0;
  
      for (i = 0; edit->rules[i]; i++) {
  	if (edit->rules[i]->keyword) {
  	    for (j = 0; edit->rules[i]->keyword[j]; j++) {
 -		syntax_g_free (edit->rules[i]->keyword[j]->keyword);
 -		syntax_g_free (edit->rules[i]->keyword[j]->whole_word_chars_left);
 -		syntax_g_free (edit->rules[i]->keyword[j]->whole_word_chars_right);
 -		syntax_g_free (edit->rules[i]->keyword[j]);
 +		MHL_PTR_FREE (edit->rules[i]->keyword[j]->keyword);
 +		MHL_PTR_FREE (edit->rules[i]->keyword[j]->whole_word_chars_left);
 +		MHL_PTR_FREE (edit->rules[i]->keyword[j]->whole_word_chars_right);
 +		MHL_PTR_FREE (edit->rules[i]->keyword[j]);
  	    }
  	}
 -	syntax_g_free (edit->rules[i]->left);
 -	syntax_g_free (edit->rules[i]->right);
 -	syntax_g_free (edit->rules[i]->whole_word_chars_left);
 -	syntax_g_free (edit->rules[i]->whole_word_chars_right);
 -	syntax_g_free (edit->rules[i]->keyword);
 -	syntax_g_free (edit->rules[i]->keyword_first_chars);
 -	syntax_g_free (edit->rules[i]);
 +	MHL_PTR_FREE (edit->rules[i]->left);
 +	MHL_PTR_FREE (edit->rules[i]->right);
 +	MHL_PTR_FREE (edit->rules[i]->whole_word_chars_left);
 +	MHL_PTR_FREE (edit->rules[i]->whole_word_chars_right);
 +	MHL_PTR_FREE (edit->rules[i]->keyword);
 +	MHL_PTR_FREE (edit->rules[i]->keyword_first_chars);
 +	MHL_PTR_FREE (edit->rules[i]);
      }
  
      while (edit->syntax_marker) {
  	struct _syntax_marker *s = edit->syntax_marker->next;
 -	syntax_g_free (edit->syntax_marker);
 +	MHL_PTR_FREE (edit->syntax_marker);
  	edit->syntax_marker = s;
      }
  
 -    syntax_g_free (edit->rules);
 +    MHL_PTR_FREE (edit->rules);
  }
  
  /* returns -1 on file error, line number on error in file syntax */
@@@ -1028,7 -1031,7 +1030,7 @@@ edit_read_syntax_file (WEdit * edit, ch
      if (!f){
  	lib_file = mhl_str_dir_plus_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
  	f = fopen (lib_file, "r");
 -	g_free (lib_file);
 +	mhl_mem_free (lib_file);
  	if (!f)
  	    return -1;
      }
@@@ -1036,7 -1039,7 +1038,7 @@@
      args[0] = 0;
      for (;;) {
  	line++;
 -	syntax_g_free (l);
 +	MHL_PTR_FREE (l);
  	if (!read_one_line (&l, f))
  	    break;
  	(void)get_args (l, args, 1023);	/* Final NULL */
@@@ -1076,7 -1079,7 +1078,7 @@@
  		else
  		    abort ();
  	    }
 -	    (*pnames)[count++] = g_strdup (args[2]);
 +	    (*pnames)[count++] = mhl_str_dup (args[2]);
  	    (*pnames)[count] = NULL;
  	} else if (type) {
  
@@@ -1117,8 -1120,9 +1119,8 @@@
  		    else
  			result = line_error;
  		} else {
 -		    syntax_g_free (edit->syntax_type);
 -		    edit->syntax_type = g_strdup (syntax_type);
 -
 +		    MHL_PTR_FREE (edit->syntax_type);
 +		    edit->syntax_type = mhl_str_dup (syntax_type);
  /* if there are no rules then turn off syntax highlighting for speed */
  		    if (!g && !edit->rules[1])
  			if (!edit->rules[0]->keyword[1] && !edit->rules[0]->spelling) {
@@@ -1135,7 -1139,7 +1137,7 @@@
  	    }
  	}
      }
 -    syntax_g_free (l);
 +    MHL_PTR_FREE (l);
      fclose (f);
      return result;
  }
@@@ -1200,9 -1204,9 +1202,9 @@@ edit_load_syntax (WEdit *edit, char ***
  	message (D_ERROR, _(" Load syntax file "),
  		 _(" Error in file %s on line %d "),
  		 error_file_name ? error_file_name : f, r);
 -	syntax_g_free (error_file_name);
 +	MHL_PTR_FREE (error_file_name);
      } else {
  	/* succeeded */
      }
 -    g_free (f);
 +    mhl_mem_free (f);
  }
diff --combined src/utilunix.c
index 5dfa18e,cd3c7cc..4cf70dc
--- a/src/utilunix.c
+++ b/src/utilunix.c
@@@ -41,10 -41,6 +41,10 @@@
  #endif
  #include <unistd.h>
  
 +#include <mhl/types.h>
 +#include <mhl/memory.h>
 +#include <mhl/string.h>
 +
  #include "global.h"
  #include "execute.h"
  #include "wtools.h"		/* message() */
@@@ -75,8 -71,8 +75,8 @@@ static char *i_cache_match (int id, int
  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);
 +    mhl_mem_free (cache [*last].string);
 +    cache [*last].string = mhl_str_dup (text);
      cache [*last].index = id;
      *last = ((*last)+1) % size;
  }
@@@ -97,7 -93,7 +97,7 @@@ char *get_owner (int uid
  	return pwd->pw_name;
      }
      else {
 -	g_snprintf (ibuf, sizeof (ibuf), "%d", uid);
 +	snprintf (ibuf, sizeof (ibuf), "%d", uid);
  	return ibuf;
      }
  }
@@@ -117,7 -113,7 +117,7 @@@ char *get_group (int gid
  	i_cache_add (gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, &gid_last);
  	return grp->gr_name;
      } else {
 -	g_snprintf (gbuf, sizeof (gbuf), "%d", gid);
 +	snprintf (gbuf, sizeof (gbuf), "%d", gid);
  	return gbuf;
      }
  }
@@@ -190,7 -186,7 +190,7 @@@ tilde_expand (const char *directory
      char *name;
  
      if (*directory != '~')
 -	return g_strdup (directory);
 +	return mhl_str_dup (directory);
  
      p = directory + 1;
  
@@@ -206,13 -202,13 +206,13 @@@
  	    name = g_strndup (p, q - p);
  	    passwd = getpwnam (name);
  	    q++;
 -	    g_free (name);
 +	    mhl_mem_free (name);
  	}
      }
  
      /* 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);
  }
@@@ -258,10 -254,10 +258,10 @@@ mc_tmpdir (void
      pwd = getpwuid (getuid ());
  
      if (pwd)
 -	g_snprintf (buffer, sizeof (buffer), "%s/mc-%s", sys_tmp,
 +	snprintf (buffer, sizeof (buffer), "%s/mc-%s", sys_tmp,
  		pwd->pw_name);
      else
 -	g_snprintf (buffer, sizeof (buffer), "%s/mc-%lu", sys_tmp,
 +	snprintf (buffer, sizeof (buffer), "%s/mc-%lu", sys_tmp,
  		(unsigned long) getuid ());
  
      canonicalize_pathname (buffer);
@@@ -296,7 -292,7 +296,7 @@@
  	/* Test if sys_tmp is suitable for temporary files */
  	fallback_prefix = g_strdup_printf ("%s/mctest", sys_tmp);
  	test_fd = mc_mkstemps (&test_fn, fallback_prefix, NULL);
 -	g_free (fallback_prefix);
 +	mhl_mem_free (fallback_prefix);
  	if (test_fd != -1) {
  	    close (test_fd);
  	    test_fd = open (test_fn, O_RDONLY);
@@@ -310,11 -306,11 +310,11 @@@
  	if (fallback_ok) {
  	    fprintf (stderr, _("Temporary files will be created in %s\n"),
  		     sys_tmp);
 -	    g_snprintf (buffer, sizeof (buffer), "%s", sys_tmp);
 +	    snprintf (buffer, sizeof (buffer), "%s", sys_tmp);
  	    error = NULL;
  	} else {
  	    fprintf (stderr, _("Temporary files will not be created\n"));
 -	    g_snprintf (buffer, sizeof (buffer), "%s", "/dev/null/");
 +	    snprintf (buffer, sizeof (buffer), "%s", "/dev/null/");
  	}
  
  	fprintf (stderr, "%s\n", _("Press any key to continue..."));
@@@ -430,7 -426,7 +430,7 @@@ canonicalize_pathname (char *path
  	if (p[0] == PATH_SEP && p[1] == PATH_SEP) {
  	    s = p + 1;
  	    while (*(++s) == PATH_SEP);
 -	    strcpy (p + 1, s);
 +	    mhl_strmove (p + 1, s);
  	}
  	p++;
      }
@@@ -439,7 -435,7 +439,7 @@@
      p = lpath;
      while (*p) {
  	if (p[0] == PATH_SEP && p[1] == '.' && p[2] == PATH_SEP)
 -	    strcpy (p, p + 2);
 +	    mhl_strmove (p, p + 2);
  	else
  	    p++;
      }
@@@ -455,7 -451,7 +455,7 @@@
  	    lpath[1] = 0;
  	    return;
  	} else {
 -	    strcpy (lpath, lpath + 2);
 +	    mhl_strmove (lpath, lpath + 2);
  	}
      }
  
@@@ -501,10 -497,10 +501,10 @@@
  	if (p[3] != 0) {
  	    if (s == lpath && *s == PATH_SEP) {
  		/* "/../foo" -> "/foo" */
 -		strcpy (s + 1, p + 4);
 +		mhl_strmove (s + 1, p + 4);
  	    } else {
  		/* "token/../foo" -> "foo" */
 -		strcpy (s, p + 4);
 +		mhl_strmove (s, p + 4);
  	    }
  	    p = (s > lpath) ? s - 1 : s;
  	    continue;
@@@ -590,7 -586,7 +590,7 @@@ putenv (char *string
  		       size * sizeof (char *));
  	new_environ[size] = (char *) string;
  	new_environ[size + 1] = NULL;
--	g_free ((void *) last_environ);
++	mhl_mem_free ((void *) last_environ);
  	last_environ = new_environ;
  	__environ = new_environ;
      }
@@@ -723,7 -719,7 +723,7 @@@ mc_realpath (const char *path, char res
  /* Return the index of the permissions triplet */
  int
  get_user_permissions (struct stat *st) {
 -    static gboolean initialized = FALSE;
 +    static bool initialized = FALSE;
      static gid_t *groups;
      static int ngroups;
      static uid_t uid;

-- 
Midnight Commander Development


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]