changeset 1726:a8d8f419b459

[xemacs-hg @ 2003-09-30 15:26:34 by james] Add type information to xfree to avoid alias creation.
author james
date Tue, 30 Sep 2003 15:27:01 +0000
parents 7ff8f4d70aec
children 7c80b06e433f
files src/ChangeLog src/alloc.c src/alloca.c src/buffer.c src/buffer.h src/console-stream.c src/console-tty.c src/device-gtk.c src/device-msw.c src/device-tty.c src/device-x.c src/dialog-msw.c src/dialog-x.c src/dired-msw.c src/dired.c src/doc.c src/dumper.c src/dynarr.c src/editfns.c src/elhash.c src/emacs.c src/emodules.c src/eval.c src/event-Xt.c src/event-gtk.c src/event-msw.c src/event-stream.c src/extents.c src/file-coding.c src/fileio.c src/filelock.c src/frame-gtk.c src/frame-msw.c src/frame-x.c src/frame.c src/gccache-gtk.c src/glyphs-eimage.c src/glyphs-gtk.c src/glyphs-msw.c src/glyphs-x.c src/gui-x.c src/hash.c src/hftctl.c src/imgproc.c src/insdel.c src/intl-win32.c src/keymap.c src/lisp.h src/lstream.c src/mule-coding.c src/nt.c src/ntplay.c src/objects-gtk.c src/objects-msw.c src/objects-tty.c src/objects-x.c src/process.c src/redisplay.c src/regex.c src/scrollbar-gtk.c src/scrollbar-msw.c src/scrollbar-x.c src/select-gtk.c src/select-msw.c src/select-x.c src/specifier.c src/syntax.c src/sysdep.c src/termcap.c src/tests.c src/text.c src/text.h src/toolbar-msw.c src/tparam.c src/ui-gtk.c src/unicode.c src/xemacs.def.in.in src/xgccache.c
diffstat 78 files changed, 395 insertions(+), 306 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/ChangeLog	Tue Sep 30 15:27:01 2003 +0000
@@ -1,3 +1,93 @@
+2003-09-25  Jerry James  <james@xemacs.org>
+
+	* alloc.c (xfree_1): Use this name even when not error checking.
+	* device-tty.c (free_tty_device_struct): Use xfree type parameter,
+	but error-checking version alters the original, not a local copy.
+	* fileio.c (Ffile_name_directory): Don't xfree alloca'd memory;
+	this is in an #if 0, but fix it anyway just in case.
+	* lisp.h: Add a type parameter to the xfree declaration, and
+	remove the alias when ERROR_CHECK_MALLOC is defined.
+	Fix 2 incorrect comments pointing to structure declarations.
+	* tparam.c: Remove unused free macro, and duplicate xmalloc and
+	xrealloc declarations.
+	* ui-gtk.c (CONVERT_RETVAL): Add type parameter to use of xfree,
+	and fix some minor whitespace problems.
+	* xemacs.def.in.in: Unconditionally export xfree_1
+	
+	* alloc.c:
+	* alloca.c:
+	* buffer.c:
+	* buffer.h:
+	* console-stream.c:
+	* console-tty.c:
+	* device-gtk.c:
+	* device-msw.c:
+	* device-x.c:
+	* dialog-msw.c:
+	* dialog-x.c:
+	* dired-msw.c:
+	* dired.c:
+	* doc.c:
+	* dumper.c:
+	* dynarr.c:
+	* editfns.c:
+	* elhash.c:
+	* emacs.c:
+	* emodules.c:
+	* eval.c:
+	* event-Xt.c:
+	* event-gtk.c:
+	* event-msw.c:
+	* event-stream.c:
+	* extents.c:
+	* file-coding.c:
+	* fileio.c:
+	* filelock.c:
+	* frame-gtk.c:
+	* frame-msw.c:
+	* frame-x.c:
+	* frame.c:
+	* gccache-gtk.c:
+	* glyphs-eimage.c:
+	* glyphs-gtk.c:
+	* glyphs-msw.c:
+	* glyphs-x.c:
+	* gui-x.c:
+	* hash.c:
+	* hftctl.c:
+	* imgproc.c:
+	* insdel.c:
+	* intl-win32.c:
+	* keymap.c:
+	* lstream.c:
+	* mule-coding.c:
+	* nt.c:
+	* ntplay.c:
+	* objects-gtk.c:
+	* objects-msw.c:
+	* objects-tty.c:
+	* objects-x.c:
+	* process.c:
+	* redisplay.c:
+	* regex.c:
+	* scrollbar-gtk.c:
+	* scrollbar-msw.c:
+	* scrollbar-x.c:
+	* select-gtk.c:
+	* select-msw.c:
+	* select-x.c:
+	* specifier.c:
+	* syntax.c:
+	* sysdep.c:
+	* termcap.c:
+	* tests.c:
+	* text.c:
+	* text.h:
+	* toolbar-msw.c:
+	* unicode.c:
+	* xgccache.c:
+	Add type parameter to uses of xfree.
+
 2003-09-27  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* search.c (trivial_regexp_p): Regexps containing "\{" are
--- a/src/alloc.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/alloc.c	Tue Sep 30 15:27:01 2003 +0000
@@ -252,7 +252,7 @@
     {
       void *tmp = breathing_space;
       breathing_space = 0;
-      xfree (tmp);
+      xfree (tmp, void *);
     }
 }
 
@@ -383,11 +383,7 @@
 }
 
 void
-#ifdef ERROR_CHECK_MALLOC
 xfree_1 (void *block)
-#else
-xfree (void *block)
-#endif
 {
 #ifdef ERROR_CHECK_MALLOC
   /* Unbelievably, calling free() on 0xDEADBEEF doesn't cause an
@@ -2265,7 +2261,7 @@
 		      XSTRING_LENGTH (s) + 1 - pos);
 	    }
 	  XSET_STRING_DATA (s, new_data);
-	  xfree (old_data);
+	  xfree (old_data, Ibyte *);
 	}
     }
   else /* old string is small */
@@ -3598,7 +3594,7 @@
           *prev = next;
 	  tick_lcrecord_stats (h, 1);
 	  /* used to call finalizer right here. */
-	  xfree (header);
+	  xfree (header, struct lcrecord_header *);
 	  header = next;
 	}
     }
@@ -3722,7 +3718,7 @@
 	  SFTB_current = SFTB_current->prev;				     \
 	  {								     \
 	    *SFTB_prev = SFTB_current;					     \
-	    xfree (SFTB_victim_block);					     \
+	    xfree (SFTB_victim_block, struct typename##_block *);	     \
 	    /* Restore free list to what it was before victim was swept */   \
 	    typename##_free_list = SFTB_old_free_list;			     \
 	    num_free -= SFTB_limit;					     \
@@ -3816,7 +3812,7 @@
 {
 #define UNMARK_compiled_function(ptr) UNMARK_RECORD_HEADER (&((ptr)->lheader))
 #define ADDITIONAL_FREE_compiled_function(ptr) \
-  if (ptr->args_in_array) xfree (ptr->args)
+  if (ptr->args_in_array) xfree (ptr->args, Lisp_Object *)
 
   SWEEP_FIXED_TYPE_BLOCK (compiled_function, Lisp_Compiled_Function);
 }
@@ -4154,7 +4150,7 @@
     for (victim = to_sb->next; victim; )
       {
 	struct string_chars_block *next = victim->next;
-	xfree (victim);
+	xfree (victim, struct string_chars_block *);
 	victim = next;
       }
 
@@ -4211,7 +4207,7 @@
 #define ADDITIONAL_FREE_string(ptr) do {	\
     Bytecount size = ptr->size_;		\
     if (BIG_STRING_SIZE_P (size))		\
-      xfree (ptr->data_);			\
+      xfree (ptr->data_, Ibyte *);		\
   } while (0)
 
   SWEEP_FIXED_TYPE_BLOCK_1 (string, Lisp_String, u.lheader);
--- a/src/alloca.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/alloca.c	Tue Sep 30 15:27:01 2003 +0000
@@ -152,7 +152,7 @@
 	  register header *np = hp->h.next;
 
 #ifdef emacs
-	  xfree (hp);		/* Collect garbage.  */
+	  xfree (hp, header *);	/* Collect garbage.  */
 #else
 	  free (hp);		/* Collect garbage.  */
 #endif
--- a/src/buffer.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/buffer.c	Tue Sep 30 15:27:01 2003 +0000
@@ -2868,7 +2868,7 @@
 #ifdef WIN32_NATIVE
   {
     Ibyte *newinit = mswindows_canonicalize_filename (initial_directory);
-    xfree (initial_directory);
+    xfree (initial_directory, Ibyte *);
     initial_directory = newinit;
   }
 
@@ -2886,7 +2886,7 @@
     XECOPY_TCHAR (p, '\0');
   
     qxeSetCurrentDirectory (modname);
-    xfree (modname);
+    xfree (modname, Extbyte *);
   }
 #endif
 }
--- a/src/buffer.h	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/buffer.h	Tue Sep 30 15:27:01 2003 +0000
@@ -1167,7 +1167,7 @@
 #define BUFFER_REALLOC(data,size)\
 	((Ibyte *) xrealloc (data, (size) * sizeof(Ibyte)))
 /* Avoid excess parentheses, or syntax errors may rear their heads. */
-#define BUFFER_FREE(data) xfree (data)
+#define BUFFER_FREE(data) xfree (data, Ibyte *)
 #define R_ALLOC_DECLARE(var,data)
 
 #endif /* !REL_ALLOC */
--- a/src/console-stream.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/console-stream.c	Tue Sep 30 15:27:01 2003 +0000
@@ -123,7 +123,7 @@
       if (stream_con->in != stdin)
 	retry_fclose (stream_con->in);
 
-      xfree (stream_con);
+      xfree (stream_con, struct stream_console *);
       CONSOLE_STREAM_DATA (con) = NULL;
     }
 }
--- a/src/console-tty.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/console-tty.c	Tue Sep 30 15:27:01 2003 +0000
@@ -196,10 +196,10 @@
     {
       if (tty_con->term_entry_buffer) /* allocated in term_init () */
 	{
-	  xfree (tty_con->term_entry_buffer);
+	  xfree (tty_con->term_entry_buffer, char *);
 	  tty_con->term_entry_buffer = NULL;
 	}
-      xfree (tty_con);
+      xfree (tty_con, struct tty_console *);
       CONSOLE_TTY_DATA (con) = NULL;
     }
 }
--- a/src/device-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/device-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -245,7 +245,7 @@
 	for (ctr = 1; new_rc_files[ctr]; ctr++)
 	  free(new_rc_files[ctr]);
 
-	xfree (new_rc_files);
+	xfree (new_rc_files, gchar **);
       }
   }
 
@@ -350,7 +350,7 @@
 static void
 free_gtk_device_struct (struct device *d)
 {
-  xfree (d->device_data);
+  xfree (d->device_data, void *);
 }
 
 static void
--- a/src/device-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/device-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -278,7 +278,7 @@
 #endif
 
   DeleteDC (DEVICE_MSWINDOWS_HCDC (d));
-  xfree (d->device_data);
+  xfree (d->device_data, void *);
 }
 
 void
@@ -545,7 +545,7 @@
 	  DEVICE_MSPRINTER_DEVMODE (d) = Qnil;
 	}
 
-      xfree (d->device_data);
+      xfree (d->device_data, void *);
     }
 }
 
--- a/src/device-tty.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/device-tty.c	Tue Sep 30 15:27:01 2003 +0000
@@ -100,9 +100,8 @@
 static void
 free_tty_device_struct (struct device *d)
 {
-  struct tty_device *td = (struct tty_device *) d->device_data;
-  if (td)
-    xfree (td);
+  if (d->device_data)
+    xfree (d->device_data, void *);
 }
 
 static void
--- a/src/device-x.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/device-x.c	Tue Sep 30 15:27:01 2003 +0000
@@ -878,7 +878,7 @@
 static void
 free_x_device_struct (struct device *d)
 {
-  xfree (d->device_data);
+  xfree (d->device_data, void *);
 }
 
 static void
--- a/src/dialog-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/dialog-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -442,7 +442,7 @@
       else if (pd.unknown_fname != 0)
 	{
 	  ret = tstr_to_local_file_format (pd.unknown_fname);
-	  xfree (pd.unknown_fname);
+	  xfree (pd.unknown_fname, Extbyte *);
 	}
       else while (1)
 	signal_quit ();
--- a/src/dialog-x.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/dialog-x.c	Tue Sep 30 15:27:01 2003 +0000
@@ -207,7 +207,7 @@
 	  {
 	    allow_text_p = 0;	 /* only allow text field at the front */
 	    if (wv->value)
-	      xfree (wv->value);
+	      xfree (wv->value, char *);
 	    wv->value = wv->name;	/* what a mess... */
 	    wv->name = xstrdup (button_names [n]);
 
--- a/src/dired-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/dired-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -583,7 +583,7 @@
   for (i = 0; i < Dynarr_length (files); ++i)
     {
       Win32_file *file = Dynarr_atp (files, i);
-      xfree (file->cFileName);
+      xfree (file->cFileName, Ibyte *);
     }
   Dynarr_free (files);
 
--- a/src/dired.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/dired.c	Tue Sep 30 15:27:01 2003 +0000
@@ -577,8 +577,8 @@
 {
   int i;
   for (i = 0; i < cache->length; i++)
-    xfree (cache->user_names[i].ptr);
-  xfree (cache->user_names);
+    xfree (cache->user_names[i].ptr, Ibyte *);
+  xfree (cache->user_names, struct user_name *);
   xzero (*cache);
 }
 
--- a/src/doc.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/doc.c	Tue Sep 30 15:27:01 2003 +0000
@@ -170,7 +170,7 @@
     }
   UNGCPRO;
   if (buffer != buf) /* We must have allocated buffer above */
-    xfree (buffer);
+    xfree (buffer, Ibyte *);
   return return_me;
 }
 
@@ -995,7 +995,7 @@
     tem = make_string (buf, bufp - buf);
   else
     tem = string;
-  xfree (buf);
+  xfree (buf, Ibyte *);
   UNGCPRO;
   return tem;
 }
--- a/src/dumper.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/dumper.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1458,7 +1458,7 @@
 static void
 pdump_file_free (void)
 {
-  xfree (pdump_start);
+  xfree (pdump_start, char *);
 }
 
 #ifdef HAVE_MMAP
--- a/src/dynarr.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/dynarr.c	Tue Sep 30 15:27:01 2003 +0000
@@ -223,9 +223,9 @@
   Dynarr *dy = (Dynarr *) d;
 
   if (dy->base && !DUMPEDP (dy->base))
-    xfree (dy->base);
+    xfree (dy->base, void *);
   if(!DUMPEDP (dy))
-    xfree (dy);
+    xfree (dy, Dynarr *);
 }
 
 #ifdef MEMORY_USAGE_STATS
--- a/src/editfns.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/editfns.c	Tue Sep 30 15:27:01 2003 +0000
@@ -827,7 +827,7 @@
 uncache_home_directory (void)
 {
   if (cached_home_directory)
-    xfree (cached_home_directory);
+    xfree (cached_home_directory, Ibyte *);
   cached_home_directory = NULL;
 }
 
@@ -1430,7 +1430,7 @@
 
   set_time_zone_rule (tzstring);
   if (environbuf)
-    xfree (environbuf);
+    xfree (environbuf, Extbyte **);
   environbuf = environ;
 
   return Qnil;
--- a/src/elhash.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/elhash.c	Tue Sep 30 15:27:01 2003 +0000
@@ -418,7 +418,7 @@
 #endif
 
   if (!DUMPEDP (hentries))
-    xfree (hentries);
+    xfree (hentries, htentry *);
 }
 
 static void
@@ -1033,7 +1033,7 @@
 
   memcpy (ht->hentries, new_entries, ht->size * sizeof (htentry));
 
-  xfree (new_entries);
+  xfree (new_entries, htentry *);
 }
 
 static void
@@ -1297,7 +1297,7 @@
 maphash_unwind (Lisp_Object unwind_obj)
 {
   void *ptr = (void *) get_opaque_ptr (unwind_obj);
-  xfree (ptr);
+  xfree (ptr, void *);
   free_opaque_ptr (unwind_obj);
   return Qnil;
 }
--- a/src/emacs.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/emacs.c	Tue Sep 30 15:27:01 2003 +0000
@@ -522,7 +522,7 @@
 	      full_exe_path = mswindows_get_module_file_name ();
 	      assert (full_exe_path);
 	      fullpath = build_tstr_string (full_exe_path);
-	      xfree (full_exe_path);
+	      xfree (full_exe_path, Extbyte *);
 	      result = Fcons (fullpath, result);
 	    }
 	  else
@@ -570,10 +570,10 @@
 
   while (argv[elt])
     {
-      xfree (argv[elt]);
+      xfree (argv[elt], Extbyte *);
       elt++;
     }
-  xfree (argv);
+  xfree (argv, Extbyte **);
 }
 
 static void
@@ -2599,9 +2599,9 @@
     }
 
   memcpy (argv, new_argv, sizeof (char *) * argc);
-  xfree (new_argv);
-  xfree (options);
-  xfree (priority);
+  xfree (new_argv, char **);
+  xfree (options, int *);
+  xfree (priority, int *);
 }
 
 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /*
--- a/src/emodules.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/emodules.c	Tue Sep 30 15:27:01 2003 +0000
@@ -248,10 +248,10 @@
 {
   if (dll_close (modules[mod].dlhandle) == 0)
     {
-      xfree (modules[mod].soname);
-      xfree (modules[mod].modname);
-      xfree (modules[mod].modver);
-      xfree (modules[mod].modtitle);
+      xfree (modules[mod].soname, CIbyte *);
+      xfree (modules[mod].modname, CIbyte *);
+      xfree (modules[mod].modver, CIbyte *);
+      xfree (modules[mod].modtitle, CIbyte *);
       modules[mod].dlhandle = 0;
       modules[mod].used = 0;
     }
--- a/src/eval.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/eval.c	Tue Sep 30 15:27:01 2003 +0000
@@ -5950,7 +5950,7 @@
 static Lisp_Object
 free_pointer (Lisp_Object opaque)
 {
-  xfree (get_opaque_ptr (opaque));
+  xfree (get_opaque_ptr (opaque), void *);
   free_opaque_ptr (opaque);
   return Qnil;
 }
--- a/src/event-Xt.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/event-Xt.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1406,7 +1406,7 @@
 		      l_item = make_string ((Ibyte *)hurl, strlen (hurl));
 		      l_dndlist = Fcons (l_item, l_dndlist);
 		      data += len + 1;
-		      xfree (hurl);
+		      xfree (hurl, char *);
 		    }
 		  l_type = Qdragdrop_URL;
 		}
@@ -1443,7 +1443,7 @@
 						   strlen (hurl)) );
 		  l_type = Qdragdrop_URL;
 
-		  xfree (hurl);
+		  xfree (hurl, char *);
 		}
 		break;
 	      case DndURL:
@@ -2348,7 +2348,7 @@
 	}
     }
   XtRemoveInput (closure->id);
-  xfree (closure);
+  xfree (closure, struct what_is_ready_closure *);
   filedesc_to_what_closure[fd] = 0;
 }
 
--- a/src/event-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/event-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -779,7 +779,7 @@
 	}
     }
   gdk_input_remove (closure->id);
-  xfree (closure);
+  xfree (closure, struct what_is_ready_closure *);
   filedesc_to_what_closure[fd] = 0;
 }
 
@@ -1020,7 +1020,7 @@
       l_dndlist = list1 (make_string ((Ibyte *)hurl, strlen (hurl)));
       l_type = Qdragdrop_URL;
 
-      xfree (hurl);
+      xfree (hurl, char *);
     }
   else if (data->type == preferred_targets[TARGET_NETSCAPE])
     {
--- a/src/event-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/event-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -824,7 +824,7 @@
 
   if (str->buffer)
     {
-      xfree (str->buffer);
+      xfree (str->buffer, void *);
       str->buffer = 0;
     }
 
@@ -2109,7 +2109,7 @@
 	       they don't allow relative paths at all!  this is way bogus. */
 	    cmd = urlify_filename (cmd);
 	    l_dndlist = build_intstring (cmd);
-	    xfree (cmd);
+	    xfree (cmd, Ibyte *);
 	  }
 	  GCPRO2 (emacs_event, l_dndlist);
 
@@ -2738,7 +2738,7 @@
 				((LCID) GetKeyboardLayout (0) & 0xFFFF),
 				NULL));
 		    ch = itext_ichar (intchar);
-		    xfree (intchar);
+		    xfree (intchar, Ibyte *);
 		  }
 
 #ifdef DEBUG_XEMACS
@@ -2884,7 +2884,7 @@
 
 				XSET_EVENT_KEY_ALT_KEYCHARS
 				  (lastev, i, itext_ichar (intchar));
-				xfree (intchar);
+				xfree (intchar, Ibyte *);
 			      }
 			  }
 		      }
@@ -3405,7 +3405,8 @@
 		   * recursion here. */
 		  if (FRAME_MSWINDOWS_TARGET_RECT (frame))
 		    {
-		      xfree (FRAME_MSWINDOWS_TARGET_RECT (frame));
+		      xfree (FRAME_MSWINDOWS_TARGET_RECT (frame),
+			     XEMACS_RECT_WH *);
 		      FRAME_MSWINDOWS_TARGET_RECT (frame) = 0;
 		    }
 		}
@@ -3864,7 +3865,7 @@
 	    {
 	      fname = urlify_filename (fname);
 	      l_item = build_intstring (fname);
-	      xfree (fname);
+	      xfree (fname, Ibyte *);
 	      l_dndlist = Fcons (l_item, l_dndlist);
 	    }
 	  }
--- a/src/event-stream.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/event-stream.c	Tue Sep 30 15:27:01 2003 +0000
@@ -401,7 +401,7 @@
       struct command_builder *b = (struct command_builder *) header;
       if (b->echo_buf)
 	{
-	  xfree (b->echo_buf);
+	  xfree (b->echo_buf, Ibyte *);
 	  b->echo_buf = 0;
 	}
     }
@@ -494,7 +494,7 @@
 {
   if (builder->echo_buf)
     {
-      xfree (builder->echo_buf);
+      xfree (builder->echo_buf, Ibyte *);
       builder->echo_buf = NULL;
     }
   free_managed_lcrecord (Vcommand_builder_free_list,
--- a/src/extents.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/extents.c	Tue Sep 30 15:27:01 2003 +0000
@@ -739,7 +739,7 @@
 free_gap_array (Gap_Array *ga)
 {
   gap_array_delete_all_markers (ga);
-  xfree (ga);
+  xfree (ga, Gap_Array *);
 }
 
 
@@ -948,7 +948,7 @@
 {
   free_gap_array (el->start);
   free_gap_array (el->end);
-  xfree (el);
+  xfree (el, Extent_List *);
 }
 
 
@@ -1664,7 +1664,7 @@
 free_soe (struct stack_of_extents *soe)
 {
   free_extent_list (soe->extents);
-  xfree (soe);
+  xfree (soe, struct stack_of_extents *);
 }
 
 /* ------------------------------- */
@@ -2776,7 +2776,7 @@
   Dynarr_free (ef->extents);
   Dynarr_free (ef->begin_glyphs);
   Dynarr_free (ef->end_glyphs);
-  xfree (ef);
+  xfree (ef, struct extent_fragment *);
 }
 
 static int
--- a/src/file-coding.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/file-coding.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1144,7 +1144,7 @@
 							  (name_or_existing))),
 			      ++coding_system_tick);
       name_or_existing = intern_int (newname);
-      xfree (newname);
+      xfree (newname, Ibyte *);
       
       if (UNBOUNDP (description))
 	{
@@ -1153,12 +1153,12 @@
 	      (NULL, "For Internal Use (%s)",
 	       XSTRING_DATA (Fsymbol_name (name_or_existing)));
 	  description = build_intstring (newname);
-	  xfree (newname);
+	  xfree (newname, Ibyte *);
 	}
 
       newname = emacs_sprintf_malloc (NULL, "Int%d", coding_system_tick);
       defmnem = build_intstring (newname);
-      xfree (newname);
+      xfree (newname, Ibyte *);
     }
   else
     CHECK_SYMBOL (name_or_existing);
@@ -1262,7 +1262,7 @@
 	     ++coding_system_tick);
 	Lisp_Object newnamesym = intern_int (newname);
 	Lisp_Object copied = Fcopy_coding_system (csobj, newnamesym);
-	xfree (newname);
+	xfree (newname, Ibyte *);
 	
 	XCODING_SYSTEM_CANONICAL (csobj) =
 	  make_internal_coding_system
@@ -2251,7 +2251,7 @@
   MAYBE_XCODESYSMETH (str->codesys, finalize_coding_stream, (str));
   if (str->data)
     {
-      xfree (str->data);
+      xfree (str->data, void *);
       str->data = 0;
     }
   str->finalized = 1;
@@ -2310,7 +2310,7 @@
   
   if (str->data)
     {
-      xfree (str->data);
+      xfree (str->data, void *);
       str->data = 0;
     }
   if (XCODING_SYSTEM_METHODS (str->codesys)->coding_data_size)
@@ -2814,7 +2814,7 @@
 	  for (i = 0; i < data->lstream_count; i++)
 	    Lstream_delete (XLSTREAM ((data->lstreams)[i]));
 	}
-      xfree (data->lstreams);
+      xfree (data->lstreams, Lisp_Object *);
     }
 }
 
@@ -2828,7 +2828,7 @@
 chain_finalize (Lisp_Object c)
 {
   if (XCODING_SYSTEM_CHAIN_CHAIN (c))
-    xfree (XCODING_SYSTEM_CHAIN_CHAIN (c));
+    xfree (XCODING_SYSTEM_CHAIN_CHAIN (c), Lisp_Object *);
 }
 
 static int
@@ -3442,7 +3442,7 @@
 	  (st);
     }
 
-  xfree (st);
+  xfree (st, struct detection_state *);
 }
 
 static int
--- a/src/fileio.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/fileio.c	Tue Sep 30 15:27:01 2003 +0000
@@ -392,7 +392,7 @@
 	  p = beg + qxestrlen (beg);
 	}
       if (wd)
-	xfree (wd);
+	xfree (wd, Ibyte *);
     }
 
 #if 0 /* No! This screws up efs, which calls file-name-directory on URL's
@@ -401,14 +401,11 @@
   {
     Bytecount len = p - beg;
     Ibyte *newbeg = alloca_ibytes (len + 1);
-    Lisp_Object return_me;
 
     qxestrncpy (newbeg, beg, len);
     newbeg[len] = '\0';
     newbeg = mswindows_canonicalize_filename (newbeg);
-    return_me = build_intstring (newbeg);
-    xfree (newbeg);
-    return return_me;
+    return build_intstring (newbeg);
   }
 #endif
 #endif /* not WIN32_NATIVE */
@@ -930,7 +927,7 @@
 		      XSTRING_DATA (name)[1] = ':';
 		    }
 		}
-	      xfree (newnm);
+	      xfree (newnm, Ibyte *);
 	      RETURN_UNGCPRO (name);
 	    }
 #endif /* WIN32_FILENAMES */
@@ -1042,7 +1039,7 @@
 	  if (newcwd)
 	    {
 	      IBYTE_STRING_TO_ALLOCA (newcwd, newdir);
-	      xfree (newcwd);
+	      xfree (newcwd, Ibyte *);
 	    }
 	  else
 	    newdir = NULL;
@@ -1128,7 +1125,7 @@
 	      if (newcwd)
 		{
 		  IBYTE_STRING_TO_ALLOCA (newcwd, newdir);
-		  xfree (newcwd);
+		  xfree (newcwd, Ibyte *);
 		}
 	      else
 #endif
@@ -1304,7 +1301,7 @@
   {
     Ibyte *newtarget = mswindows_canonicalize_filename (target);
     Lisp_Object result = build_intstring (newtarget);
-    xfree (newtarget);
+    xfree (newtarget, Ibyte *);
 
     RETURN_UNGCPRO (result);
   }
@@ -2436,16 +2433,16 @@
 			      buf, bufsize);
       if (valsize < bufsize) break;
       /* Buffer was not long enough */
-      xfree (buf);
+      xfree (buf, Ibyte *);
       bufsize *= 2;
     }
   if (valsize == -1)
     {
-      xfree (buf);
+      xfree (buf, Ibyte *);
       return Qnil;
     }
   val = make_string (buf, valsize);
-  xfree (buf);
+  xfree (buf, Ibyte *);
   return val;
 #else /* not HAVE_READLINK */
   return Qnil;
--- a/src/filelock.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/filelock.c	Tue Sep 30 15:27:01 2003 +0000
@@ -88,7 +88,10 @@
 #define LOCK_PID_MAX (4 * sizeof (pid_t))
 
 /* Free the two dynamically-allocated pieces in PTR.  */
-#define FREE_LOCK_INFO(i) do { xfree ((i).user); xfree ((i).host); } while (0)
+#define FREE_LOCK_INFO(i) do {			\
+    xfree ((i).user, Ibyte *);			\
+    xfree ((i).host, Ibyte *);			\
+  } while (0)
 
 /* Write the name of the lock file for FN into LFNAME.  Length will be
    that of FN plus two more for the leading `.#' plus one for the null.  */
@@ -180,7 +183,7 @@
   /* If nonexistent lock file, all is well; otherwise, got strange error. */
   if (len == -1)
     {
-      xfree (lfinfo);
+      xfree (lfinfo, Ibyte *);
       return errno == ENOENT ? 0 : -1;
     }
 
@@ -200,7 +203,7 @@
   at = qxestrchr (lfinfo, '@');
   dot = qxestrrchr (lfinfo, '.');
   if (!at || !dot) {
-    xfree (lfinfo);
+    xfree (lfinfo, Ibyte *);
     return -1;
   }
   len = at - lfinfo;
@@ -218,7 +221,7 @@
   owner->host[len] = 0;
 
   /* We're done looking at the link info.  */
-  xfree (lfinfo);
+  xfree (lfinfo, Ibyte *);
 
   /* On current host?  */
   if (STRINGP (Fsystem_name ())
--- a/src/frame-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/frame-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1304,8 +1304,8 @@
     gtk_widget_destroy (w);
 
     if (FRAME_GTK_GEOM_FREE_ME_PLEASE (f))
-	xfree (FRAME_GTK_GEOM_FREE_ME_PLEASE (f));
-    xfree (f->frame_data);
+	xfree (FRAME_GTK_GEOM_FREE_ME_PLEASE (f), char *);
+    xfree (f->frame_data, void *);
     f->frame_data = 0;
 }
 
--- a/src/frame-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/frame-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -328,7 +328,7 @@
 #endif
       ReleaseDC (FRAME_MSWINDOWS_HANDLE (f), FRAME_MSWINDOWS_DC (f));
       DestroyWindow (FRAME_MSWINDOWS_HANDLE (f));
-      xfree (f->frame_data);
+      xfree (f->frame_data, void *);
     }
   f->frame_data = 0;
 }
@@ -978,7 +978,7 @@
 	EndPage (hdc);
       if (FRAME_MSPRINTER_JOB_STARTED (f))
 	EndDoc (hdc);
-      xfree (f->frame_data);
+      xfree (f->frame_data, void *);
     }
 
   f->frame_data = 0;
--- a/src/frame-x.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/frame-x.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1006,7 +1006,7 @@
     }
 
   /* free the data string */
-  xfree (clientData);
+  xfree (clientData, XtPointer);
 
   CurrentDragWidget = NULL;
 }
@@ -1164,7 +1164,7 @@
 	      if (!STRINGP (XCAR (item)))
 		{
 		  numItems=0;
-		  xfree(Ctext);
+		  xfree(Ctext, char *);
 		  Ctext=NULL;
 		  break;
 		}
@@ -1242,7 +1242,7 @@
 	  l_data = Fcons (make_string ((Ibyte* )hurl,
 				       strlen (hurl)),
 			  l_data);
-	  xfree (hurl);
+	  xfree (hurl, char *);
 	}
     }
   else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER)
@@ -1339,7 +1339,7 @@
 	    {
 	      if (!STRINGP (XCAR (run)))
 		{
-		  xfree (dnd_data);
+		  xfree (dnd_data, char *);
 		  return Qnil;
 		}
 	      len = XSTRING_LENGTH (XCAR (run)) + 1;
@@ -1403,7 +1403,7 @@
 
       DndSetData(dnd_typ, (unsigned char *)dnd_data, dnd_len);
       if (dnd_dealloc)
-	xfree (dnd_data);
+	xfree (dnd_data, char *);
 
       /* the next thing blocks everything... */
       if (DndHandleDragging(wid, &x_event))
@@ -2677,13 +2677,13 @@
 
   if (FRAME_X_GEOM_FREE_ME_PLEASE (f))
     {
-      xfree (FRAME_X_GEOM_FREE_ME_PLEASE (f));
+      xfree (FRAME_X_GEOM_FREE_ME_PLEASE (f), char *);
       FRAME_X_GEOM_FREE_ME_PLEASE (f) = 0;
     }
 
   if (f->frame_data)
     {
-      xfree (f->frame_data);
+      xfree (f->frame_data, void *);
       f->frame_data = 0;
     }
 }
--- a/src/frame.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/frame.c	Tue Sep 30 15:27:01 2003 +0000
@@ -3472,7 +3472,7 @@
       if (!EQ (icon_format, title_format) || !title)
 	{
 	  if (title)
-	    xfree (title);
+	    xfree (title, Ibyte *);
 
 	  title = generate_title_string (w, icon_format,
 					 DEFAULT_INDEX, CURRENT_DISP);
@@ -3481,7 +3481,7 @@
     }
 
   if (title)
-    xfree (title);
+    xfree (title, Ibyte *);
 }
 
 
--- a/src/gccache-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/gccache-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -145,13 +145,13 @@
     {
       gdk_gc_destroy(rest->gc);
       next = rest->next;
-      xfree (rest);
+      xfree (rest, struct gc_cache_cell *);
       rest = next;
     }
 #ifdef GCCACHE_HASH
   free_hash_table (cache->table);
 #endif
-  xfree (cache);
+  xfree (cache, struct gc_cache *);
 }
 
 GdkGC *
--- a/src/glyphs-eimage.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/glyphs-eimage.c	Tue Sep 30 15:27:01 2003 +0000
@@ -158,7 +158,8 @@
   if (data->instream)
     retry_fclose (data->instream);
 
-  if (data->eimage) xfree (data->eimage);
+  if (data->eimage)
+    xfree (data->eimage, UChar_Binary *);
 
   return Qnil;
 }
@@ -553,7 +554,7 @@
       GifFree(data->giffile);
     }
   if (data->eimage)
-    xfree (data->eimage);
+    xfree (data->eimage, UChar_Binary *);
 
   return Qnil;
 }
@@ -842,7 +843,8 @@
   if (data->instream)
     retry_fclose (data->instream);
 
-  if (data->eimage) xfree(data->eimage);
+  if (data->eimage)
+    xfree(data->eimage, UChar_Binary *);
 
   return Qnil;
 }
@@ -1023,7 +1025,7 @@
     }
 #endif
 
-    xfree (row_pointers);
+    xfree (row_pointers, UChar_Binary **);
   }
 
   /* now instantiate */
@@ -1083,7 +1085,7 @@
       TIFFClose(data->tiff);
     }
   if (data->eimage)
-    xfree (data->eimage);
+    xfree (data->eimage, UChar_Binary *);
 
   return Qnil;
 }
--- a/src/glyphs-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/glyphs-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -260,7 +260,7 @@
 #endif
 	    }
 	}
-      xfree(qtable);
+      xfree(qtable, quant_table *);
     } else {
       unsigned long rshift,gshift,bshift,rbits,gbits,bbits,junk;
       junk = vis->red_mask;
@@ -414,7 +414,7 @@
 		    gdk_pixmap_unref (IMAGE_INSTANCE_GTK_PIXMAP_SLICE (p,i));
 		    IMAGE_INSTANCE_GTK_PIXMAP_SLICE (p, i) = 0;
 		  }
-	      xfree (IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p));
+	      xfree (IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p), GdkPixmap **);
 	      IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p) = 0;
 	    }
 
@@ -442,11 +442,11 @@
       && IMAGE_INSTANCE_TYPE (p) != IMAGE_SUBWINDOW
       && IMAGE_INSTANCE_GTK_PIXELS (p))
     {
-      xfree (IMAGE_INSTANCE_GTK_PIXELS (p));
+      xfree (IMAGE_INSTANCE_GTK_PIXELS (p), unsigned long *);
       IMAGE_INSTANCE_GTK_PIXELS (p) = 0;
     }
 
-  xfree (p->data);
+  xfree (p->data, void *);
   p->data = 0;
 }
 
@@ -838,7 +838,8 @@
 					      &pixtbl, &npixels);
       if (!gdk_image)
 	{
-	  if (pixtbl) xfree (pixtbl);
+	  if (pixtbl)
+	    xfree (pixtbl, unsigned long *);
 	  signal_image_error("EImage to GdkImage conversion failed", instantiator);
 	}
 
@@ -1292,7 +1293,8 @@
   }
   qxe_unlink (XSTRING_DATA (tempfile));
 
-  if (color_symbols) xfree (color_symbols);
+  if (color_symbols)
+    xfree (color_symbols, struct color_symbol *);
 
   if (!pixmap)
     signal_image_error ("Error reading pixmap", data);
--- a/src/glyphs-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/glyphs-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -202,7 +202,7 @@
 
       if (!bmp_data)
 	{
-	  xfree (bmp_info);
+	  xfree (bmp_info, BITMAPINFO *);
 	  return NULL;
 	}
 
@@ -233,7 +233,7 @@
 					     sizeof(RGBQUAD) * ncolors);
       if (!bmp_info)
 	{
-	  xfree (qtable);
+	  xfree (qtable, quant_table *);
 	  return NULL;
 	}
 
@@ -251,8 +251,8 @@
 
       if (!*bmp_data)
 	{
-	  xfree (qtable);
-	  xfree (bmp_info);
+	  xfree (qtable, quant_table *);
+	  xfree (bmp_info, BITMAPINFO *);
 	  return NULL;
 	}
 
@@ -279,7 +279,7 @@
 	      *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl);
 	    }
 	}
-      xfree (qtable);
+      xfree (qtable, quant_table *);
     }
   /* fix up the standard stuff */
   bmp_info->bmiHeader.biWidth = width;
@@ -472,8 +472,8 @@
 	image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice,
 				     instantiator);
 
-      xfree (bmp_info);
-      xfree (bmp_data);
+      xfree (bmp_info, BITMAPINFO *);
+      xfree (bmp_data, UChar_Binary *);
     }
 }
 
@@ -538,7 +538,7 @@
 				 (void **)&and_bits,
 				 0,0)))
     {
-      xfree (bmp_info);
+      xfree (bmp_info, BITMAPINFO *);
       return;
     }
 
@@ -565,7 +565,7 @@
 		 bmp_info,
 		 DIB_RGB_COLORS) <= 0)
     {
-      xfree (bmp_info);
+      xfree (bmp_info, BITMAPINFO *);
       return;
     }
 
@@ -597,8 +597,8 @@
 	     bmp_info,
 	     DIB_RGB_COLORS);
 
-  xfree (bmp_info);
-  xfree (dibits);
+  xfree (bmp_info, BITMAPINFO *);
+  xfree (dibits, UChar_Binary *);
 
   SelectObject(hcdc, old);
 
@@ -849,7 +849,7 @@
   colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
   if (!colortbl)
     {
-      xfree (*data);
+      xfree (*data, UChar_Binary *);
       XpmFreeXpmImage (&xpmimage);
       XpmFreeXpmInfo (&xpminfo);
       return 0;
@@ -905,8 +905,8 @@
 	}
 
     label_no_color:
-      xfree (*data);
-      xfree (colortbl);
+      xfree (*data, UChar_Binary *);
+      xfree (colortbl, COLORREF *);
       XpmFreeXpmImage (&xpmimage);
       XpmFreeXpmInfo (&xpminfo);
       return 0;
@@ -932,7 +932,7 @@
 
   XpmFreeXpmImage (&xpmimage);
   XpmFreeXpmInfo (&xpminfo);
-  xfree (colortbl);
+  xfree (colortbl, COLORREF *);
   return TRUE;
 }
 
@@ -982,9 +982,9 @@
     {
       while (nsymbols--)
 	{
-	  xfree (color_symbols[nsymbols].name);
+	  xfree (color_symbols[nsymbols].name, Ibyte *);
 	}
-      xfree(color_symbols);
+      xfree(color_symbols, struct color_symbol *);
     }
 
   /* build a bitmap from the eimage */
@@ -994,15 +994,15 @@
       signal_image_error ("XPM to EImage conversion failed",
 			  image_instance);
     }
-  xfree (eimage);
+  xfree (eimage, UChar_Binary *);
 
   /* Now create the pixmap and set up the image instance */
   init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
 				     bmp_data, bmp_bits, 1, instantiator,
 				     x_hot, y_hot, transp);
 
-  xfree (bmp_info);
-  xfree (bmp_data);
+  xfree (bmp_info, BITMAPINFO *);
+  xfree (bmp_data, UChar_Binary *);
 }
 #endif /* HAVE_XPM */
 
@@ -1353,7 +1353,7 @@
 
   if (!new_data)
     {
-      xfree (bmp_info);
+      xfree (bmp_info, BITMAPINFO *);
       return NULL;
     }
 
@@ -1404,17 +1404,17 @@
 			     &bmp_buf,
 			     0,0);
 
-  xfree (bmp_info);
+  xfree (bmp_info, BITMAPINFO *);
 
   if (!bitmap || !bmp_buf)
     {
-      xfree (new_data);
+      xfree (new_data, UChar_Binary *);
       return NULL;
     }
 
   /* copy in the actual bitmap */
   memcpy (bmp_buf, new_data, height * new_width);
-  xfree (new_data);
+  xfree (new_data, UChar_Binary *);
 
   return bitmap;
 }
@@ -1776,7 +1776,7 @@
 		    DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i));
 		  IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i) = 0;
 		}
-	      xfree (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p));
+	      xfree (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p), HBITMAP *);
 	      IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p) = 0;
 	    }
 	  if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
@@ -1790,7 +1790,7 @@
 
   if (p->data)
     {
-      xfree (p->data);
+      xfree (p->data, void *);
       p->data = 0;
     }
 }
--- a/src/glyphs-x.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/glyphs-x.c	Tue Sep 30 15:27:01 2003 +0000
@@ -272,7 +272,7 @@
 #endif
 	    }
 	}
-      xfree(qtable);
+      xfree (qtable, quant_table *);
     } else {
       unsigned long rshift,gshift,bshift,rbits,gbits,bbits,junk;
       junk = vis->red_mask;
@@ -438,7 +438,7 @@
 		    XFreePixmap (dpy, IMAGE_INSTANCE_X_PIXMAP_SLICE (p,i));
 		    IMAGE_INSTANCE_X_PIXMAP_SLICE (p, i) = 0;
 		  }
-	      xfree (IMAGE_INSTANCE_X_PIXMAP_SLICES (p));
+	      xfree (IMAGE_INSTANCE_X_PIXMAP_SLICES (p), Pixmap *);
 	      IMAGE_INSTANCE_X_PIXMAP_SLICES (p) = 0;
 	    }
 
@@ -466,11 +466,11 @@
       && IMAGE_INSTANCE_TYPE (p) != IMAGE_SUBWINDOW
       && IMAGE_INSTANCE_X_PIXELS (p))
     {
-      xfree (IMAGE_INSTANCE_X_PIXELS (p));
+      xfree (IMAGE_INSTANCE_X_PIXELS (p), unsigned long *);
       IMAGE_INSTANCE_X_PIXELS (p) = 0;
     }
 
-  xfree (p->data);
+  xfree (p->data, void *);
   p->data = 0;
 }
 
@@ -862,7 +862,8 @@
 					 &pixtbl, &npixels);
       if (!ximage)
 	{
-	  if (pixtbl) xfree (pixtbl);
+	  if (pixtbl)
+	    xfree (pixtbl, unsigned long *);
 	  signal_image_error("EImage to XImage conversion failed", instantiator);
 	}
 
@@ -878,7 +879,7 @@
 	{
 	  if (ximage->data)
 	    {
-	      xfree (ximage->data);
+	      xfree (ximage->data, char *);
 	      ximage->data = 0;
 	    }
 	  XDestroyImage (ximage);
@@ -1301,8 +1302,8 @@
       int i;
 
       for (i = 0; i < (int) xpmattrs.numsymbols; i++)
-	xfree (color_symbols[i].name);
-      xfree (color_symbols);
+	xfree (color_symbols[i].name, char *);
+      xfree (color_symbols, XpmColorSymbol *);
       xpmattrs.colorsymbols = 0; /* in case XpmFreeAttr is too smart... */
       xpmattrs.numsymbols = 0;
     }
--- a/src/gui-x.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/gui-x.c	Tue Sep 30 15:27:01 2003 +0000
@@ -198,9 +198,9 @@
 free_popup_widget_value_tree (widget_value *wv)
 {
   if (! wv) return;
-  if (wv->key) xfree (wv->key);
-  if (wv->value) xfree (wv->value);
-  if (wv->name) xfree (wv->name);
+  if (wv->key) xfree (wv->key, char *);
+  if (wv->value) xfree (wv->value, char *);
+  if (wv->name) xfree (wv->name, char *);
 
   wv->name = wv->value = wv->key = (char *) 0xDEADBEEF; /* -559038737 base 10*/
 
--- a/src/hash.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/hash.c	Tue Sep 30 15:27:01 2003 +0000
@@ -163,8 +163,8 @@
 void
 free_hash_table (struct hash_table *hash_table)
 {
-  xfree (hash_table->harray);
-  xfree (hash_table);
+  xfree (hash_table->harray, hentry *);
+  xfree (hash_table, struct hash_table *);
 }
 
 struct hash_table*
@@ -207,7 +207,7 @@
     rehash (old_harray, hash_table, old_size);
   }
 
-  xfree (old_harray);
+  xfree (old_harray, hentry *);
 }
 
 void
--- a/src/hftctl.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/hftctl.c	Tue Sep 30 15:27:01 2003 +0000
@@ -338,6 +338,6 @@
   /* write request to terminal   */
   if (write(fd,p.c,size) == -1) return (-1);
   if (p.req != &req)		/* free if allocated           */
-    xfree (p.c);
+    xfree (p.c, char *);
   return (0);
 }
--- a/src/imgproc.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/imgproc.c	Tue Sep 30 15:27:01 2003 +0000
@@ -536,7 +536,7 @@
   qt->num_active_colors = i;
 
   /* We're done with the boxes now */
-  xfree (box_list);
+  xfree (box_list, Colorbox *);
   qt->freeboxes = qt->usedboxes = NULL;
 
   /*
@@ -550,13 +550,14 @@
 
   /* 5c: done with ColorCells */
   for (i = 0; i < C_LEN*C_LEN*C_LEN; i++)
-    if (qt->ColorCells[i]) xfree (qt->ColorCells[i]);
-  xfree (qt->ColorCells);
+    if (qt->ColorCells[i])
+      xfree (qt->ColorCells[i], C_cell *);
+  xfree (qt->ColorCells, C_cell **);
   
   if (res)
     {
-      /* we failed in memory allocation, so clean up an leave */
-      xfree(qt);
+      /* we failed in memory allocation, so clean up and leave */
+      xfree(qt, quant_table *);
       return NULL;
     }
   
--- a/src/insdel.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/insdel.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1824,9 +1824,9 @@
   if (!b->base_buffer)
     {
       BUFFER_FREE (b->text->beg);
-      xfree (b->text->changes);
+      xfree (b->text->changes, struct buffer_text_change_data *);
     }
-  xfree (b->changes);
+  xfree (b->changes, struct each_buffer_change_data *);
 
 #ifdef REGION_CACHE_NEEDS_WORK
   if (b->newline_cache)
--- a/src/intl-win32.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/intl-win32.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1964,7 +1964,7 @@
   TO_INTERNAL_FORMAT (DATA, (unidata, size), MALLOC, (intdata, size),
 		      Qmswindows_unicode);
 
-  xfree (unidata);
+  xfree (unidata, Extbyte *);
 
   if (size_out)
     *size_out = size;
--- a/src/keymap.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/keymap.c	Tue Sep 30 15:27:01 2003 +0000
@@ -3808,7 +3808,7 @@
     result = Fnreverse (result);
 
   if (c.keys_so_far_malloced)
-    xfree (c.keys_so_far);
+    xfree (c.keys_so_far, Lisp_Key_Data *);
   return result;
 }
 
--- a/src/lisp.h	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/lisp.h	Tue Sep 30 15:27:01 2003 +0000
@@ -1223,16 +1223,15 @@
     }								\
 } while (0)
 
+MODULE_API void xfree_1 (void *);
 #ifdef ERROR_CHECK_MALLOC
-MODULE_API void xfree_1 (void *);
-#define xfree(lvalue) do			\
+#define xfree(lvalue,type) do			\
 {						\
-  void **xfree_ptr = (void **) &(lvalue);	\
-  xfree_1 (*xfree_ptr);				\
-  *xfree_ptr = (void *) 0xDEADBEEF;		\
+  xfree_1 (lvalue);				\
+  lvalue = (type) 0xDEADBEEF;			\
 } while (0)
 #else
-MODULE_API void xfree (void *);
+#define xfree(lvalue,type) xfree_1 (lvalue)
 #endif /* ERROR_CHECK_MALLOC */
 
 /* ------------------------ dynamic arrays ------------------- */
@@ -1435,14 +1434,14 @@
 typedef unsigned int USID;
 typedef int face_index;
 typedef int glyph_index;
-typedef struct lstream Lstream; /* lstream-impl.h */
+typedef struct lstream Lstream; /* lstream.h */
 typedef struct extent *EXTENT; /* extents-impl.h */
 typedef struct Lisp_Event Lisp_Event; /* "events.h" */
 typedef struct Lisp_Face Lisp_Face;   /* "faces-impl.h" */
 typedef struct Lisp_Process Lisp_Process; /* "procimpl.h" */
 typedef struct Lisp_Color_Instance Lisp_Color_Instance; /* objects-impl.h */
 typedef struct Lisp_Font_Instance Lisp_Font_Instance; /* objects-impl.h */
-typedef struct Lisp_Image_Instance Lisp_Image_Instance; /* glyphs-impl.h */
+typedef struct Lisp_Image_Instance Lisp_Image_Instance; /* glyphs.h */
 typedef struct Lisp_Gui_Item Lisp_Gui_Item;
 
 /* ------------------------------- */
--- a/src/lstream.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/lstream.c	Tue Sep 30 15:27:01 2003 +0000
@@ -842,17 +842,17 @@
      is called more than once on the same object */
   if (lstr->out_buffer)
     {
-      xfree (lstr->out_buffer);
+      xfree (lstr->out_buffer, unsigned char *);
       lstr->out_buffer = 0;
     }
   if (lstr->in_buffer)
     {
-      xfree (lstr->in_buffer);
+      xfree (lstr->in_buffer, unsigned char *);
       lstr->in_buffer = 0;
     }
   if (lstr->unget_buffer)
     {
-      xfree (lstr->unget_buffer);
+      xfree (lstr->unget_buffer, unsigned char *);
       lstr->unget_buffer = 0;
     }
 
@@ -1540,7 +1540,7 @@
   struct resizing_buffer_stream *str = RESIZING_BUFFER_STREAM_DATA (stream);
   if (str->buf)
     {
-      xfree (str->buf);
+      xfree (str->buf, unsigned char *);
       str->buf = 0;
     }
   return 0;
--- a/src/mule-coding.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/mule-coding.c	Tue Sep 30 15:27:01 2003 +0000
@@ -2972,7 +2972,7 @@
 {
   struct iso2022_detector *data = DETECTION_STATE_DATA (st, iso2022);
   if (data->iso)
-    xfree (data->iso);
+    xfree (data->iso, struct iso2022_coding_stream *);
 }
 
 
--- a/src/nt.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/nt.c	Tue Sep 30 15:27:01 2003 +0000
@@ -338,16 +338,16 @@
 	      *p++ = '\\';
 	      eicat_ch (o, '\\');
 	    }
-	  xfree (component);
+	  xfree (component, Ibyte *);
 	}
       else
 	{
-	  xfree (full);
+	  xfree (full, Ibyte *);
 	  return 0;
 	}
     }
 
-  xfree (full);
+  xfree (full, Ibyte *);
   return eicpyout_malloc (o, 0);
 }
 
@@ -394,7 +394,8 @@
 			      &cbData) == ERROR_SUCCESS)
 	return (lpvalue);
 
-      if (lpvalue) xfree (lpvalue);
+      if (lpvalue)
+	xfree (lpvalue, LPBYTE);
 	
       RegCloseKey (hrootkey);
     } 
@@ -411,7 +412,8 @@
 			      &cbData) == ERROR_SUCCESS)
 	return (lpvalue);
 	
-      if (lpvalue) xfree (lpvalue);
+      if (lpvalue)
+	xfree (lpvalue, LPBYTE);
 	
       RegCloseKey (hrootkey);
     } 
@@ -494,7 +496,7 @@
 		eputenv (env_vars[i], (CIbyte *) envval);
 	      }
 
-	    xfree (lpval);
+	    xfree (lpval, LPBYTE);
 	  }
       }
   }
@@ -703,8 +705,8 @@
 	}
       else
 	{
-	  xfree (info->name);
-	  xfree (info->type);
+	  xfree (info->name, Ibyte *);
+	  xfree (info->type, Ibyte *);
 	}
 
       TSTR_TO_C_STRING_MALLOC (name, info->name);
@@ -826,7 +828,7 @@
     return NULL;
 
   if (dir_pathname)
-    xfree (dir_pathname);
+    xfree (dir_pathname, Ibyte *);
   dir_pathname = qxestrdup (filename);
 
   return dirp;
@@ -848,7 +850,7 @@
       retval = close_unc_volume (wnet_enum_handle);
       wnet_enum_handle = INVALID_HANDLE_VALUE;
     }
-  xfree (dirp);
+  xfree (dirp, DIR *);
 
   return retval;
 }
@@ -905,7 +907,7 @@
 
     eicpy_rawz (found, val);
     if (need_to_free)
-      xfree (val);
+      xfree (val, Ibyte *);
 
     if (!NILP (Vmswindows_downcase_file_names))
       eilwr (found);
@@ -1750,7 +1752,7 @@
   else
     cwdext = _getdcwd (drivelet, NULL, 0);
   TSTR_TO_C_STRING_MALLOC (cwdext, cwd);
-  xfree (cwdext);
+  xfree (cwdext, Extbyte *);
   return cwd;
 }
 
@@ -2041,8 +2043,8 @@
 
   canon = mswindows_canonicalize_filename (longname);
   ret = build_intstring (canon);
-  xfree (canon);
-  xfree (longname);
+  xfree (canon, Ibyte *);
+  xfree (longname, Ibyte *);
   return ret;
 }
 
--- a/src/ntplay.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/ntplay.c	Tue Sep 30 15:27:01 2003 +0000
@@ -68,7 +68,7 @@
       if (retry_read (ofd, data, size) != size)
 	{
 	  retry_close (ofd);
-	  xfree (data);
+	  xfree (data, UChar_Binary *);
 	  return;
 	}
       retry_close (ofd);
@@ -90,7 +90,7 @@
   if (sound_data)
     {
       qxePlaySound (NULL, NULL, flags);
-      xfree (sound_data);
+      xfree (sound_data, UChar_Binary *);
       sound_data = 0;
     }
 
--- a/src/objects-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/objects-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -159,7 +159,7 @@
 	    }
 	    gdk_color_free (COLOR_INSTANCE_GTK_COLOR (c));
 	}
-      xfree (c->data);
+      xfree (c->data, void *);
       c->data = 0;
     }
 }
@@ -322,7 +322,7 @@
 	{
 	    gdk_font_unref (FONT_INSTANCE_GTK_FONT (f));
 	}
-      xfree (f->data);
+      xfree (f->data, void *);
       f->data = 0;
     }
 }
--- a/src/objects-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/objects-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1374,7 +1374,7 @@
 {
   if (c->data)
     {
-      xfree (c->data);
+      xfree (c->data, void *);
       c->data = 0;
     }
 }
@@ -1900,7 +1900,7 @@
 	    DeleteObject (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i));
 	}
 
-      xfree (f->data);
+      xfree (f->data, void *);
       f->data = 0;
    }
 }
--- a/src/objects-tty.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/objects-tty.c	Tue Sep 30 15:27:01 2003 +0000
@@ -200,7 +200,7 @@
 tty_finalize_color_instance (Lisp_Color_Instance *c)
 {
   if (c->data)
-    xfree (c->data);
+    xfree (c->data, void *);
 }
 
 static int
@@ -287,7 +287,7 @@
 tty_finalize_font_instance (Lisp_Font_Instance *f)
 {
   if (f->data)
-    xfree (f->data);
+    xfree (f->data, void *);
 }
 
 static Lisp_Object
--- a/src/objects-x.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/objects-x.c	Tue Sep 30 15:27:01 2003 +0000
@@ -304,7 +304,7 @@
 			   &COLOR_INSTANCE_X_COLOR (c).pixel, 1, 0);
 	    }
 	}
-      xfree (c->data);
+      xfree (c->data, void *);
       c->data = 0;
     }
 }
@@ -474,7 +474,7 @@
 
 	  XFreeFont (dpy, FONT_INSTANCE_X_FONT (f));
 	}
-      xfree (f->data);
+      xfree (f->data, void *);
       f->data = 0;
     }
 }
--- a/src/process.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/process.c	Tue Sep 30 15:27:01 2003 +0000
@@ -201,7 +201,7 @@
     {
       MAYBE_PROCMETH (finalize_process_data, (p, for_disksave));
       if (!for_disksave)
-	xfree (p->process_data);
+	xfree (p->process_data, void *);
     }
 }
 
--- a/src/redisplay.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/redisplay.c	Tue Sep 30 15:27:01 2003 +0000
@@ -1675,7 +1675,7 @@
 	  break;
 	case PROP_STRING:
 	  if (pb->data.p_string.str)
-	    xfree (pb->data.p_string.str);
+	    xfree (pb->data.p_string.str, Ibyte *);
 	  /* #### bogus bogus -- this doesn't do anything!
 	     Should probably call add_ibyte_string_runes(),
 	     once that function is fixed. */
--- a/src/regex.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/regex.c	Tue Sep 30 15:27:01 2003 +0000
@@ -266,7 +266,7 @@
 #define ALLOCA alloca
 #define xmalloc malloc
 #define xrealloc realloc
-#define xfree free
+#define xfree(x,type) free (x)
 #endif
 
 #ifdef emacs
@@ -349,8 +349,9 @@
    memmove (destination, source, osize),				\
    destination)
 
-/* No need to do anything to free, after alloca.  */
-#define REGEX_FREE(arg) ((void)0) /* Do nothing!  But inhibit gcc warning.  */
+/* No need to do anything to free, after alloca.
+   Do nothing!  But inhibit gcc warning.  */
+#define REGEX_FREE(arg,type) ((void)0)
 
 #endif /* REGEX_MALLOC */
 
@@ -370,7 +371,7 @@
 
 #define REGEX_ALLOCATE_STACK xmalloc
 #define REGEX_REALLOCATE_STACK(source, osize, nsize) xrealloc (source, nsize)
-#define REGEX_FREE_STACK xfree
+#define REGEX_FREE_STACK(arg) xfree (arg, fail_stack_elt_t *)
 
 #else /* not REGEX_MALLOC */
 
@@ -2101,11 +2102,11 @@
    examined nor set.  */
 
 /* Return, freeing storage we allocated.  */
-#define FREE_STACK_RETURN(value)		\
-do						\
-{						\
-  xfree (compile_stack.stack);			\
-  return value;					\
+#define FREE_STACK_RETURN(value)			\
+do							\
+{							\
+  xfree (compile_stack.stack, compile_stack_elt_t *);	\
+  return value;						\
 } while (0)
 
 static reg_errcode_t
@@ -3409,7 +3410,7 @@
   if (syntax & RE_NO_POSIX_BACKTRACKING)
     BUF_PUSH (succeed);
 
-  xfree (compile_stack.stack);
+  xfree (compile_stack.stack, compile_stack_elt_t *);
 
   /* We have succeeded; set the length of the buffer.  */
   bufp->used = buf_end - bufp->buffer;
@@ -4674,20 +4675,20 @@
 
 /* Free everything we malloc.  */
 #ifdef MATCH_MAY_ALLOCATE
-#define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL
+#define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL
 #define FREE_VARIABLES()						\
   do {									\
     UNBIND_REGEX_MALLOC_CHECK ();					\
     REGEX_FREE_STACK (fail_stack.stack);				\
-    FREE_VAR (regstart);						\
-    FREE_VAR (regend);							\
-    FREE_VAR (old_regstart);						\
-    FREE_VAR (old_regend);						\
-    FREE_VAR (best_regstart);						\
-    FREE_VAR (best_regend);						\
-    FREE_VAR (reg_info);						\
-    FREE_VAR (reg_dummy);						\
-    FREE_VAR (reg_info_dummy);						\
+    FREE_VAR (regstart, re_char **);					\
+    FREE_VAR (regend, re_char **);					\
+    FREE_VAR (old_regstart, re_char **);				\
+    FREE_VAR (old_regend, re_char **);					\
+    FREE_VAR (best_regstart, re_char **);				\
+    FREE_VAR (best_regend, re_char **);					\
+    FREE_VAR (reg_info, register_info_type *);				\
+    FREE_VAR (reg_dummy, re_char **);					\
+    FREE_VAR (reg_info_dummy, register_info_type *);			\
   } while (0)
 #else /* not MATCH_MAY_ALLOCATE */
 #define FREE_VARIABLES()			\
@@ -6949,8 +6950,8 @@
         }
 
       /* If we needed the temporary register info, free the space now.  */
-      xfree (regs.start);
-      xfree (regs.end);
+      xfree (regs.start, regoff_t *);
+      xfree (regs.end, regoff_t *);
     }
 
   /* We want zero return to mean success, unlike `re_search'.  */
@@ -7002,19 +7003,19 @@
 regfree (regex_t *preg)
 {
   if (preg->buffer != NULL)
-    xfree (preg->buffer);
+    xfree (preg->buffer, unsigned char *);
   preg->buffer = NULL;
 
   preg->allocated = 0;
   preg->used = 0;
 
   if (preg->fastmap != NULL)
-    xfree (preg->fastmap);
+    xfree (preg->fastmap, char *);
   preg->fastmap = NULL;
   preg->fastmap_accurate = 0;
 
   if (preg->translate != NULL)
-    xfree (preg->translate);
+    xfree (preg->translate, RE_TRANSLATE_TYPE);
   preg->translate = NULL;
 }
 
--- a/src/scrollbar-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/scrollbar-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -63,7 +63,7 @@
     }
 
   if (instance->scrollbar_data)
-    xfree (instance->scrollbar_data);
+    xfree (instance->scrollbar_data, void *);
 }
 
 /* A device method. */
--- a/src/scrollbar-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/scrollbar-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -100,7 +100,7 @@
   assert (!NILP (ptr));
   DestroyWindow (SCROLLBAR_MSW_HANDLE (sb));
   if (sb->scrollbar_data)
-    xfree (sb->scrollbar_data);
+    xfree (sb->scrollbar_data, void *);
 }
 
 static void
--- a/src/scrollbar-x.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/scrollbar-x.c	Tue Sep 30 15:27:01 2003 +0000
@@ -73,7 +73,7 @@
 x_free_scrollbar_instance (struct scrollbar_instance *instance)
 {
   if (SCROLLBAR_X_NAME (instance))
-    xfree (SCROLLBAR_X_NAME (instance));
+    xfree (SCROLLBAR_X_NAME (instance), char *);
 
   if (SCROLLBAR_X_WIDGET (instance))
     {
@@ -84,7 +84,7 @@
     }
 
   if (instance->scrollbar_data)
-    xfree (instance->scrollbar_data);
+    xfree (instance->scrollbar_data, void *);
 }
 
 /* A device method. */
--- a/src/select-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/select-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -212,14 +212,15 @@
     successful_p = Qt;
     /* Tell x_selection_request_lisp_error() it's cool. */
     cl->successful = TRUE;
-    xfree (data);
+    xfree (data, UChar_Binary *);
   }
 
   unbind_to (count);
 
  DONE_LABEL:
 
-  if (cl) xfree (cl);
+  if (cl)
+    xfree (cl, struct _selection_closure *);
 
   UNGCPRO;
 
--- a/src/select-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/select-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -324,7 +324,7 @@
     {
       CloseClipboard ();
 
-      xfree (src);
+      xfree (src, void *);
       return Qnil;
     }
 
@@ -335,12 +335,12 @@
       GlobalFree (hValue);
       CloseClipboard ();
 
-      xfree (src);
+      xfree (src, void *);
       return Qnil;
     }
 
   memcpy (dst, src, size);
-  xfree (src);
+  xfree (src, void *);
 
   GlobalUnlock (hValue);
 
--- a/src/select-x.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/select-x.c	Tue Sep 30 15:27:01 2003 +0000
@@ -642,7 +642,7 @@
     successful_p = Qt;
     /* Tell x_selection_request_lisp_error() it's cool. */
     event->type = 0;
-    xfree (data);
+    xfree (data, UChar_Binary *);
   }
 
   unbind_to (count);
@@ -771,7 +771,7 @@
 	    prev->next = rest->next;
 	  else
 	    for_whom_the_bell_tolls = rest->next;
-	  xfree (rest);
+	  xfree (rest, struct prop_location *);
 	  return;
 	}
       prev = rest;
@@ -806,13 +806,13 @@
 		      XSTRING_DATA
 		      (XSYMBOL (x_atom_to_symbol
 				(get_device_from_display (event->display),
-				 event->atom))->name);
+				 event->atom))->name));
 #endif
 	  if (prev)
 	    prev->next = rest->next;
 	  else
 	    for_whom_the_bell_tolls = rest->next;
-	  xfree (rest);
+	  xfree (rest, struct prop_location *);
 	  return;
 	}
       prev = rest;
@@ -1074,7 +1074,8 @@
 	  stderr_out ("  read INCR done\n");
 #endif
 	  unexpect_property_change (prop_id);
-	  if (tmp_data) xfree (tmp_data);
+	  if (tmp_data)
+	    xfree (tmp_data, UChar_Binary *);
 	  break;
 	}
 #if 0
@@ -1091,7 +1092,7 @@
 	}
       memcpy ((*data_ret) + offset, tmp_data, tmp_size_bytes);
       offset += tmp_size_bytes;
-      xfree (tmp_data);
+      xfree (tmp_data, UChar_Binary *);
     }
 }
 
@@ -1140,7 +1141,7 @@
       Bytecount min_size_bytes =
 	/* careful here. */
 	(Bytecount) (* ((unsigned int *) data));
-      xfree (data);
+      xfree (data, UChar_Binary *);
       receive_incremental_selection (display, window, property, target_type,
 				     min_size_bytes, &data, &bytes,
 				     &actual_type, &actual_format,
@@ -1152,7 +1153,7 @@
   val = selection_data_to_lisp_data (d, data, bytes,
 				     actual_type, actual_format);
 
-  xfree (data);
+  xfree (data, UChar_Binary *);
   return val;
 }
 
@@ -1284,7 +1285,7 @@
 			  memchr (data, 0x1b, bytes) ?
 			  Qctext : Qbinary)
 	 : Qnil);
-  xfree (data);
+  xfree (data, UChar_Binary *);
   return ret;
 }
 
--- a/src/specifier.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/specifier.c	Tue Sep 30 15:27:01 2003 +0000
@@ -302,7 +302,7 @@
   /* don't be snafued by the disksave finalization. */
   if (!for_disksave && !GHOST_SPECIFIER_P(sp) && sp->caching)
     {
-      xfree (sp->caching);
+      xfree (sp->caching, struct specifier_caching *);
       sp->caching = 0;
     }
 }
--- a/src/syntax.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/syntax.c	Tue Sep 30 15:27:01 2003 +0000
@@ -385,7 +385,7 @@
 void
 uninit_buffer_syntax_cache (struct buffer *buf)
 {
-  xfree (buf->syntax_cache);
+  xfree (buf->syntax_cache, struct syntax_cache *);
   buf->syntax_cache = 0;
 }
 
--- a/src/sysdep.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/sysdep.c	Tue Sep 30 15:27:01 2003 +0000
@@ -3003,7 +3003,7 @@
 	{
 	  Ibyte *retin;
 	  TSTR_TO_C_STRING_MALLOC (ret, retin);
-	  xfree (cwd);
+	  xfree (cwd, Extbyte *);
 	  return retin;
 	}
 #else
@@ -3012,7 +3012,7 @@
 	{
 	  Ibyte *retin;
 	  EXTERNAL_TO_C_STRING_MALLOC (ret, retin, Qfile_name);
-	  xfree (cwd);
+	  xfree (cwd, Extbyte *);
 	  return retin;
 	}
 #endif /* WIN32_NATIVE */
@@ -3024,7 +3024,7 @@
 	}
       else
 	{
-	  xfree (cwd);
+	  xfree (cwd, Extbyte *);
 	  return NULL;
 	}
     }
@@ -3253,15 +3253,15 @@
     return NULL;
 
   if (cached_pwd.pw_name)
-    xfree (cached_pwd.pw_name);
+    xfree (cached_pwd.pw_name, char *);
   if (cached_pwd.pw_passwd)
-    xfree (cached_pwd.pw_passwd);
+    xfree (cached_pwd.pw_passwd, char *);
   if (cached_pwd.pw_gecos)
-    xfree (cached_pwd.pw_gecos);
+    xfree (cached_pwd.pw_gecos, char *);
   if (cached_pwd.pw_dir)
-    xfree (cached_pwd.pw_dir);
+    xfree (cached_pwd.pw_dir, char *);
   if (cached_pwd.pw_shell)
-    xfree (cached_pwd.pw_shell);
+    xfree (cached_pwd.pw_shell, char *);
 
   cached_pwd = *pwd;
   if (cached_pwd.pw_name)
@@ -3329,7 +3329,7 @@
   if (!str) /* can happen on MS Windows */
     return (Ibyte *) "Sun Jan 01 00:00:00 1970";
   if (ctime_static)
-    xfree (ctime_static);
+    xfree (ctime_static, Ibyte *);
   EXTERNAL_TO_C_STRING_MALLOC (str, ctime_static, Qnative);
   return ctime_static;
 }
@@ -3890,9 +3890,9 @@
      in one block.  Why in the world are we freeing this ourselves
      anyway?  */
 #if ! (defined (sun) && defined (USG5_4))
-  xfree ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */
+  xfree (dirp->dd_buf, char *); /* directory block defined in <dirent.h> */
 #endif
-  xfree ((char *) dirp);
+  xfree (dirp, DIR *);
   return (rtnval);
 }
 #endif /* BROKEN_CLOSEDIR or not HAVE_CLOSEDIR */
@@ -3929,7 +3929,7 @@
 closedir (DIR *dirp)		/* stream from opendir */
 {
   retry_close (dirp->dd_fd);
-  xfree (dirp);
+  xfree (dirp, DIR *);
 }
 
 
--- a/src/termcap.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/termcap.c	Tue Sep 30 15:27:01 2003 +0000
@@ -411,7 +411,7 @@
 
       /* Free old `term' if appropriate.  */
       if (term != name)
-	xfree (term);
+	xfree (term, const char *);
 
       /* If BP is malloc'd by us, make sure it is big enough.  */
       if (malloc_size)
@@ -441,7 +441,7 @@
     }
 
   retry_close (fd);
-  xfree (buf.beg);
+  xfree (buf.beg, char *);
 
   if (malloc_size)
     {
@@ -651,7 +651,7 @@
 	  printf ("\\%0o", *y);
 	else
 	  putchar (*y);
-      xfree (x);
+      xfree (x, char *);
     }
   else
     printf ("none");
--- a/src/tests.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/tests.c	Tue Sep 30 15:27:01 2003 +0000
@@ -131,7 +131,7 @@
 		      MALLOC, (ptr, len),
 		      intern ("iso-8859-2"));
   DFC_CHECK_DATA (ptr, len, ext_latin);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   TO_EXTERNAL_FORMAT (DATA, (int_latin2, sizeof (int_latin2) - 1),
 		      LISP_OPAQUE, opaque,
@@ -149,7 +149,7 @@
 		      MALLOC, (ptr, len),
 		      intern ("iso-8859-2"));
   DFC_CHECK_DATA (ptr, len, int_latin2);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin) - 1),
 		      LISP_STRING, string,
@@ -233,21 +233,21 @@
 		      MALLOC, (ptr, len),
 		      Qbinary);
   DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   ptr = NULL, len = rand();
   TO_EXTERNAL_FORMAT (DATA, (int_latin2, sizeof (int_latin2)),
 		      MALLOC, (ptr, len),
 		      Qbinary);
   DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, ext_tilde, int_latin2);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   ptr = NULL, len = rand();
   TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1) - 1),
 		      MALLOC, (ptr, len),
 		      intern ("iso-8859-1"));
   DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1) - 1),
 		      LISP_OPAQUE, opaque,
@@ -284,14 +284,14 @@
 		      MALLOC, (ptr, len),
 		      intern ("iso-8859-1"));
   DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, int_latin1, ext_latin);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   ptr = NULL, len = rand();
   TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin)),
 		      MALLOC, (ptr, len),
 		      Qnil);
   DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, int_latin1, ext_latin);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin) - 1),
 		      LISP_STRING, string,
@@ -317,7 +317,7 @@
 		      MALLOC, (ptr, len),
 		      Qbinary);
   DFC_CHECK_DATA_COND_EOL_NUL (ptr, len, ext_unix, int_foo);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   ptr = NULL, len = rand();
   TO_EXTERNAL_FORMAT (DATA, (int_foo, sizeof (int_foo) - 1),
@@ -343,7 +343,7 @@
 		      MALLOC, (ptr, len),
 		      intern ("no-conversion-mac"));
   DFC_CHECK_DATA_COND_EOL (ptr, len, ext_mac, int_foo);
-  xfree (ptr);
+  xfree (ptr, void *);
 
   ptr = NULL, len = rand();
   TO_EXTERNAL_FORMAT (DATA, (int_foo, sizeof (int_foo) - 1),
--- a/src/text.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/text.c	Tue Sep 30 15:27:01 2003 +0000
@@ -3344,7 +3344,7 @@
   vals = Dynarr_atp (active_dfc_e2c, i);
   assert (alloca_data);
   memcpy (alloca_data, vals->dst, vals->dst_size + 2);
-  xfree (vals->dst);
+  xfree (vals->dst, void *);
   Dynarr_delete (active_dfc_e2c, i);
   return alloca_data;
 }
--- a/src/text.h	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/text.h	Tue Sep 30 15:27:01 2003 +0000
@@ -2082,9 +2082,9 @@
   if ((ei)->mallocp_)				\
     {						\
       if ((ei)->data_)				\
-	xfree ((ei)->data_);			\
+	xfree ((ei)->data_, Ibyte *);		\
       if ((ei)->extdata_)			\
-	xfree ((ei)->extdata_);			\
+	xfree ((ei)->extdata_, Extbyte *);	\
       eiinit_malloc (ei);			\
     }						\
   else						\
@@ -2109,7 +2109,7 @@
 	eifind_large_enough_buffer (0, (ei)->bytelen_ + 1);		\
       ei13newdata = (Ibyte *) ALLOCA ((ei)->max_size_allocated_);	\
       memcpy (ei13newdata, (ei)->data_, (ei)->bytelen_ + 1);		\
-      xfree ((ei)->data_);						\
+      xfree ((ei)->data_, Ibyte *);					\
       (ei)->data_ = ei13newdata;					\
     }									\
 									\
@@ -2121,7 +2121,7 @@
       /* Double null-terminate in case of Unicode data */		\
       ei13newdata[(ei)->extlen_] = '\0';				\
       ei13newdata[(ei)->extlen_ + 1] = '\0';				\
-      xfree ((ei)->extdata_);						\
+      xfree ((ei)->extdata_, Extbyte *);				\
       (ei)->extdata_ = ei13newdata;					\
     }									\
 } while (0)
@@ -2323,7 +2323,7 @@
     {									\
       if ((ei)->extdata_)						\
 	{								\
-	  xfree ((ei)->extdata_);					\
+	  xfree ((ei)->extdata_, Extbyte *);				\
 	  (ei)->extdata_ = 0;						\
 	}								\
       TO_EXTERNAL_FORMAT (DATA, ((ei)->data_, (ei)->bytelen_),		\
--- a/src/toolbar-msw.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/toolbar-msw.c	Tue Sep 30 15:27:01 2003 +0000
@@ -294,7 +294,7 @@
 			  if (! (bitmap = mswindows_create_resized_bitmap 
 				 (p, f, bmwidth, bmheight)))
 			    {
-			      xfree (button_tbl);
+			      xfree (button_tbl, TBBUTTON *);
 			      if (ilist) ImageList_Destroy (ilist);
 			      gui_error ("Couldn't resize pixmap", instance);
 			    }
@@ -317,7 +317,7 @@
 					 ? ILC_MASK  : 0) | ILC_COLOR24, 
 					nbuttons, nbuttons * 2 )))
 			{
-			  xfree (button_tbl);
+			  xfree (button_tbl, TBBUTTON *);
 			  gui_error ("Couldn't create image list", instance);
 			}
 
@@ -332,7 +332,7 @@
 			    mask ? mask 
 			    : IMAGE_INSTANCE_MSWINDOWS_MASK (p))) < 0)
 			{
-			  xfree (button_tbl);
+			  xfree (button_tbl, TBBUTTON *);
 			  if (ilist)
 			    ImageList_Destroy (ilist);
 			  gui_error 
@@ -394,7 +394,7 @@
 			      NULL, 
 			      NULL))==NULL)
 	{
-	  xfree (button_tbl);
+	  xfree (button_tbl, TBBUTTON *);
 	  ImageList_Destroy (ilist);
 	  gui_error ("couldn't create toolbar", Qunbound);
 	}
@@ -467,7 +467,8 @@
          happen otherwise. */
       mswindows_move_toolbar (f, pos);
 
-      if (button_tbl) xfree (button_tbl);
+      if (button_tbl)
+	xfree (button_tbl, TBBUTTON *);
 
       SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1);
     }
--- a/src/tparam.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/tparam.c	Tue Sep 30 15:27:01 2003 +0000
@@ -26,12 +26,8 @@
 
 #undef realloc
 #undef malloc
-#undef free
 #define realloc xrealloc
 #define malloc xmalloc
-#define free xfree
-extern void *xmalloc (Bytecount size);
-extern void *xrealloc (void *, Bytecount size);
 
 /* Assuming STRING is the value of a termcap string entry
    containing `%' constructs to expand parameters,
--- a/src/ui-gtk.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/ui-gtk.c	Tue Sep 30 15:27:01 2003 +0000
@@ -347,7 +347,7 @@
   do {							\
     void *v = GTK_VALUE_POINTER(a);			\
     switch (GTK_FUNDAMENTAL_TYPE (a.type))		\
-    {							\
+      {							\
 	CONVERT_SINGLE_TYPE(a,CHAR,gchar);		\
 	CONVERT_SINGLE_TYPE(a,UCHAR,guchar);		\
 	CONVERT_SINGLE_TYPE(a,BOOL,gboolean);		\
@@ -363,11 +363,11 @@
 	CONVERT_SINGLE_TYPE(a,BOXED,void *);		\
 	CONVERT_SINGLE_TYPE(a,POINTER,void *);		\
 	CONVERT_SINGLE_TYPE(a,OBJECT,GtkObject *);	\
-	default:					\
-	GTK_VALUE_POINTER (a) = * (void **) v;	\
+      default:						\
+	GTK_VALUE_POINTER (a) = * (void **) v;		\
 	break;						\
-    }							\
-    if (freep) xfree(v);				\
+      }							\
+    if (freep) xfree(v, void *);			\
   } while (0)
 
 static gpointer __allocate_object_storage (GtkType t)
--- a/src/unicode.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/unicode.c	Tue Sep 30 15:27:01 2003 +0000
@@ -427,7 +427,7 @@
       }
     }
 
-  xfree (table);
+  xfree (table, void *);
 }
 
 static void
@@ -445,7 +445,7 @@
 	}
     }
 
-  xfree (table);
+  xfree (table, void *);
 }
 
 void
--- a/src/xemacs.def.in.in	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/xemacs.def.in.in	Tue Sep 30 15:27:01 2003 +0000
@@ -134,11 +134,7 @@
 write_string
 wrong_type_argument		/* CONCHECK_xxx */
 xemacs_c_alloca			/* ALLOCA */
-#ifdef ERROR_CHECK_MALLOC
 xfree_1				/* xfree */
-#else
-xfree
-#endif
 xmalloc
 xmalloc_and_zero
 xrealloc
--- a/src/xgccache.c	Mon Sep 29 21:53:04 2003 +0000
+++ b/src/xgccache.c	Tue Sep 30 15:27:01 2003 +0000
@@ -143,13 +143,13 @@
     {
       XFreeGC (cache->dpy, rest->gc);
       next = rest->next;
-      xfree (rest);
+      xfree (rest, struct gc_cache_cell *);
       rest = next;
     }
 #ifdef GCCACHE_HASH
   free_hash_table (cache->table);
 #endif
-  xfree (cache);
+  xfree (cache, struct gc_cache *);
 }
 
 GC