Hello,

this patch introduces the use of XNEW, XOBNEW, GGC_NEW and the
other type-safe memory allocation macros recently added to
libiberty.

Rather than replacing all occurrences of malloc(), I've only
fixed the places where I was getting warnings for missing
casts.

I also noticed a place in c-typeck.c where we're doing this:

 if (spelling_base == 0)
   spelling_base = xmalloc (spelling_size * sizeof (struct spelling));
 else
   spelling_base = xrealloc (spelling_base,
			     spelling_size * sizeof (struct spelling));

I was under the impression that any implementation of realloc() could
deal with a NULL pointer for its first argument.  Supposing it was
done like that for a reason, so I've just converted it to use XNEWVEC
and XRESIZEVEC.

Bootstrapped on i386-pc-linux-gnu with all languages enabled.
Tested (two weeks ago) on powerpc-apple-darwin with no new
regressions. Committed as pre-approved.


2004-07-25  Bernardo Innocenti  <bernie@develer.com>

	* bitmap.c: Use type-safe memory allocation macros from libiberty.
	* c-common.c: Likewise.
	* c-decl.c: Likewise.
	* c-lang.c: Likewise.
	* c-lex.c: Likewise.
	* c-opts.c: Likewise.
	* c-parse.in: Likewise.
	* c-typeck.c: Likewise.
	* genconditions.c: Likewise.
	* gengtype-lex.l: Likewise.
	* gengtype-yacc.y: Likewise.
	* gengtype.c: Likewise.
	* genmodes.c: Likewise.
	* gensupport.c: Likewise.
	* read-rtl.c: Likewise.
	* read-rtl.c (read_constants): Use INSERT instead of TRUE in call to
	htab_find_slot().

Index: gcc/bitmap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bitmap.c,v
retrieving revision 1.49
diff -u -p -r1.49 bitmap.c
--- gcc/bitmap.c	13 May 2004 06:39:26 -0000	1.49
+++ gcc/bitmap.c	25 Jul 2004 19:56:15 -0000
@@ -131,7 +131,7 @@ bitmap_element_allocate (bitmap head)
 					  obstack_chunk_free);
 	    }
 
-	  element = obstack_alloc (&bitmap_obstack, sizeof (bitmap_element));
+	  element = XOBNEW (&bitmap_obstack, bitmap_element);
 	}
     }
   else
@@ -142,7 +142,7 @@ bitmap_element_allocate (bitmap head)
           bitmap_ggc_free = element->next;
 	}
       else
-	element = ggc_alloc (sizeof (bitmap_element));
+	element = GGC_NEW (bitmap_element);
     }
 
   memset (element->bits, 0, sizeof (element->bits));
@@ -716,7 +716,7 @@ bitmap
 bitmap_initialize (bitmap head, int using_obstack)
 {
   if (head == NULL && ! using_obstack)
-    head = ggc_alloc (sizeof (*head));
+    head = GGC_NEW (struct bitmap_head_def);
 
   head->first = head->current = 0;
   head->using_obstack = using_obstack;
Index: gcc/c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.539
diff -u -p -r1.539 c-common.c
--- gcc/c-common.c	25 Jul 2004 19:09:34 -0000	1.539
+++ gcc/c-common.c	25 Jul 2004 19:56:24 -0000
@@ -1051,7 +1051,7 @@ static struct tlist *
 new_tlist (struct tlist *next, tree t, tree writer)
 {
   struct tlist *l;
-  l = obstack_alloc (&tlist_obstack, sizeof *l);
+  l = XOBNEW (&tlist_obstack, struct tlist);
   l->next = next;
   l->expr = t;
   l->writer = writer;
@@ -1322,7 +1322,7 @@ verify_tree (tree x, struct tlist **pbef
 
 	if (! t)
 	  {
-	    t = obstack_alloc (&tlist_obstack, sizeof *t);
+	    t = XOBNEW (&tlist_obstack, struct tlist_cache);
 	    t->next = save_expr_cache;
 	    t->expr = x;
 	    save_expr_cache = t;
Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.543
diff -u -p -r1.543 c-decl.c
--- gcc/c-decl.c	25 Jul 2004 19:32:47 -0000	1.543
+++ gcc/c-decl.c	25 Jul 2004 19:56:36 -0000
@@ -428,7 +428,7 @@ bind (tree name, tree decl, struct c_sco
       binding_freelist = b->prev;
     }
   else
-    b = ggc_alloc (sizeof (struct c_binding));
+    b = GGC_NEW (struct c_binding);
 
   b->shadowed = 0;
   b->decl = decl;
@@ -603,7 +603,7 @@ push_scope (void)
 	  scope_freelist = scope->outer;
 	}
       else
-	scope = ggc_alloc_cleared (sizeof (struct c_scope));
+	scope = GGC_CNEW (struct c_scope);
 
       scope->keep          = keep_next_level_flag;
       scope->outer         = current_scope;
@@ -1858,7 +1858,7 @@ pushdecl (tree x)
 
   /* Functions need the lang_decl data.  */
   if (TREE_CODE (x) == FUNCTION_DECL && ! DECL_LANG_SPECIFIC (x))
-    DECL_LANG_SPECIFIC (x) = ggc_alloc_cleared (sizeof (struct lang_decl));
+    DECL_LANG_SPECIFIC (x) = GGC_CNEW (struct lang_decl);
 
   /* Must set DECL_CONTEXT for everything not at file scope or
      DECL_FILE_SCOPE_P won't work.  Local externs don't count
@@ -4495,7 +4495,7 @@ grokdeclarator (tree declarator, tree de
 	decl = build_decl_attribute_variant (decl, decl_attr);
 
 	DECL_LANG_SPECIFIC (decl)
-	  = ggc_alloc_cleared (sizeof (struct lang_decl));
+	  = GGC_CNEW (struct lang_decl);
 
 	if (pedantic && type_quals && ! DECL_IN_SYSTEM_HEADER (decl))
 	  pedwarn ("ISO C forbids qualified function types");
@@ -5324,8 +5324,9 @@ finish_struct (tree t, tree fieldlist, t
           ensure that this lives as long as the rest of the struct decl.
           All decls in an inline function need to be saved.  */
 
-        space = ggc_alloc_cleared (sizeof (struct lang_type));
-        space2 = ggc_alloc (sizeof (struct sorted_fields_type) + len * sizeof (tree));
+        space = GGC_CNEW (struct lang_type);
+        space2 = GGC_NEWVAR (struct sorted_fields_type,
+			     sizeof (struct sorted_fields_type) + len * sizeof (tree));
 
         len = 0;
 	space->s = space2;
@@ -5548,7 +5549,7 @@ finish_enum (tree enumtype, tree values,
 
   /* Record the min/max values so that we can warn about bit-field
      enumerations that are too small for the values.  */
-  lt = ggc_alloc_cleared (sizeof (struct lang_type));
+  lt = GGC_CNEW (struct lang_type);
   lt->enum_min = minnode;
   lt->enum_max = maxnode;
   TYPE_LANG_SPECIFIC (enumtype) = lt;
@@ -6451,7 +6452,7 @@ void
 c_push_function_context (struct function *f)
 {
   struct language_function *p;
-  p = ggc_alloc (sizeof (struct language_function));
+  p = GGC_NEW (struct language_function);
   f->language = p;
 
   p->base.x_stmt_tree = c_stmt_tree;
@@ -6505,7 +6506,7 @@ c_dup_lang_specific_decl (tree decl)
   if (!DECL_LANG_SPECIFIC (decl))
     return;
 
-  ld = ggc_alloc (sizeof (struct lang_decl));
+  ld = GGC_NEW (struct lang_decl);
   memcpy (ld, DECL_LANG_SPECIFIC (decl), sizeof (struct lang_decl));
   DECL_LANG_SPECIFIC (decl) = ld;
 }
@@ -6631,7 +6632,7 @@ static void
 c_write_global_declarations_1 (tree globals)
 {
   size_t len = list_length (globals);
-  tree *vec = xmalloc (sizeof (tree) * len);
+  tree *vec = XNEWVEC (tree, len);
   size_t i;
   tree decl;
 
Index: gcc/c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.226
diff -u -p -r1.226 c-lex.c
--- gcc/c-lex.c	25 Jul 2004 19:32:47 -0000	1.226
+++ gcc/c-lex.c	25 Jul 2004 19:56:37 -0000
@@ -122,7 +122,7 @@ get_fileinfo (const char *name)
   if (n)
     return (struct c_fileinfo *) n->value;
 
-  fi = xmalloc (sizeof (struct c_fileinfo));
+  fi = XNEW (struct c_fileinfo);
   fi->time = 0;
   fi->interface_only = 0;
   fi->interface_unknown = 1;
Index: gcc/c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.51
diff -u -p -r1.51 c-objc-common.c
--- gcc/c-objc-common.c	8 Jul 2004 19:50:17 -0000	1.51
+++ gcc/c-objc-common.c	25 Jul 2004 19:56:37 -0000
@@ -285,11 +285,11 @@ void
 c_initialize_diagnostics (diagnostic_context *context)
 {
   pretty_printer *base = context->printer;
-  c_pretty_printer *pp = xmalloc (sizeof (c_pretty_printer));
+  c_pretty_printer *pp = XNEW (c_pretty_printer);
   memcpy (pp_base (pp), base, sizeof (pretty_printer));
   pp_c_pretty_printer_init (pp);
   context->printer = (pretty_printer *) pp;
 
-  /* It is safe to free this object because it was previously malloc()'d.  */
-  free (base);
+  /* It is safe to free this object because it was previously XNEW()'d.  */
+  XDELETE (base);
 }
Index: gcc/c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.121
diff -u -p -r1.121 c-opts.c
--- gcc/c-opts.c	25 Jul 2004 00:12:57 -0000	1.121
+++ gcc/c-opts.c	25 Jul 2004 19:56:39 -0000
@@ -226,7 +226,7 @@ c_common_init_options (unsigned int argc
   flag_exceptions = c_dialect_cxx ();
   warn_pointer_arith = c_dialect_cxx ();
 
-  deferred_opts = xmalloc (argc * sizeof (struct deferred_opt));
+  deferred_opts = XNEWVEC (struct deferred_opt, argc);
 
   result = lang_flags[c_language];
 
@@ -913,7 +913,7 @@ c_common_post_options (const char **pfil
   /* Canonicalize the input and output filenames.  */
   if (in_fnames == NULL)
     {
-      in_fnames = xmalloc (sizeof (in_fnames[0]));
+      in_fnames = XNEWVEC (const char *, 1);
       in_fnames[0] = "";
     }
   else if (strcmp (in_fnames[0], "-") == 0)
@@ -1256,7 +1256,7 @@ add_prefixed_path (const char *suffix, s
   prefix     = iprefix ? iprefix : cpp_GCC_INCLUDE_DIR;
   prefix_len = iprefix ? strlen (iprefix) : cpp_GCC_INCLUDE_DIR_len;
 
-  path = xmalloc (prefix_len + suffix_len + 1);
+  path = (char *) xmalloc (prefix_len + suffix_len + 1);
   memcpy (path, prefix, prefix_len);
   memcpy (path + prefix_len, suffix, suffix_len);
   path[prefix_len + suffix_len] = '\0';
Index: gcc/c-parse.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.224
diff -u -p -r1.224 c-parse.in
--- gcc/c-parse.in	21 Jul 2004 23:46:14 -0000	1.224
+++ gcc/c-parse.in	25 Jul 2004 19:56:45 -0000
@@ -3451,7 +3451,7 @@ init_reswords (void)
   if (!c_dialect_objc ())
      mask |= D_OBJC;
 
-  ridpointers = ggc_calloc ((int) RID_MAX, sizeof (tree));
+  ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
   for (i = 0; i < N_reswords; i++)
     {
       /* If a keyword is disabled, do not enter it into the table
Index: gcc/c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.350
diff -u -p -r1.350 c-typeck.c
--- gcc/c-typeck.c	25 Jul 2004 17:57:22 -0000	1.350
+++ gcc/c-typeck.c	25 Jul 2004 19:56:59 -0000
@@ -3756,10 +3756,10 @@ static int spelling_size;		/* Size of th
     {									\
       spelling_size += 10;						\
       if (spelling_base == 0)						\
-	spelling_base = xmalloc (spelling_size * sizeof (struct spelling)); \
+	spelling_base = XNEWVEC (struct spelling, spelling_size);	\
       else								\
-        spelling_base = xrealloc (spelling_base,		\
-				  spelling_size * sizeof (struct spelling)); \
+        spelling_base = XRESIZEVEC (struct spelling, spelling_base,	\
+				    spelling_size);			\
       RESTORE_SPELLING_DEPTH (depth);					\
     }									\
 									\
@@ -4309,7 +4309,7 @@ void
 start_init (tree decl, tree asmspec_tree, int top_level)
 {
   const char *locus;
-  struct initializer_stack *p = xmalloc (sizeof (struct initializer_stack));
+  struct initializer_stack *p = XNEW (struct initializer_stack);
   const char *asmspec = 0;
 
   if (asmspec_tree)
@@ -4411,7 +4411,7 @@ finish_init (void)
 void
 really_start_incremental_init (tree type)
 {
-  struct constructor_stack *p = xmalloc (sizeof (struct constructor_stack));
+  struct constructor_stack *p = XNEW (struct constructor_stack);
 
   if (type == 0)
     type = TREE_TYPE (constructor_decl);
@@ -4548,7 +4548,7 @@ push_init_level (int implicit)
 	value = find_init_member (constructor_index);
     }
 
-  p = xmalloc (sizeof (struct constructor_stack));
+  p = XNEW (struct constructor_stack);
   p->type = constructor_type;
   p->fields = constructor_fields;
   p->index = constructor_index;
@@ -4941,7 +4941,7 @@ push_range_stack (tree range_end)
 {
   struct constructor_range_stack *p;
 
-  p = ggc_alloc (sizeof (struct constructor_range_stack));
+  p = GGC_NEW (struct constructor_range_stack);
   p->prev = constructor_range_stack;
   p->next = 0;
   p->fields = constructor_fields;
@@ -5122,7 +5122,7 @@ add_pending_init (tree purpose, tree val
 	}
     }
 
-  r = ggc_alloc (sizeof (struct init_node));
+  r = GGC_NEW (struct init_node);
   r->purpose = purpose;
   r->value = value;
 
@@ -6391,8 +6391,9 @@ c_start_case (tree exp)
     }
 
   /* Add this new SWITCH_STMT to the stack.  */
-  cs = xmalloc (sizeof (*cs));
-  cs->switch_stmt = build_stmt (SWITCH_STMT, exp, NULL_TREE, orig_type);
+  cs = XNEW (struct c_switch);
+  cs->switch_stmt = build_stmt ((enum tree_code) SWITCH_STMT, exp, NULL_TREE,
+				orig_type);
   cs->orig_type = orig_type;
   cs->cases = splay_tree_new (case_compare, NULL, NULL);
   cs->next = c_switch_stack;
@@ -6440,7 +6441,7 @@ c_finish_case (tree body)
   /* Pop the stack.  */
   c_switch_stack = cs->next;
   splay_tree_delete (cs->cases);
-  free (cs);
+  XDELETE (cs);
 }
 
 /* Emit an if statement.  IF_LOCUS is the location of the 'if'.  COND,
Index: gcc/genconditions.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genconditions.c,v
retrieving revision 1.11
diff -u -p -r1.11 genconditions.c
--- gcc/genconditions.c	25 Jul 2004 00:13:00 -0000	1.11
+++ gcc/genconditions.c	25 Jul 2004 19:57:00 -0000
@@ -57,7 +57,7 @@ add_condition (const char *expr)
   if (expr[0] == 0)
     return;
 
-  test = xmalloc (sizeof (struct c_test));
+  test = XNEW (struct c_test);
   test->expr = expr;
 
   *(htab_find_slot (condition_table, test, INSERT)) = test;
Index: gcc/gengtype-lex.l
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype-lex.l,v
retrieving revision 1.24
diff -u -p -r1.24 gengtype-lex.l
--- gcc/gengtype-lex.l	15 Jul 2004 00:02:29 -0000	1.24
+++ gcc/gengtype-lex.l	25 Jul 2004 19:57:02 -0000
@@ -433,10 +433,10 @@ push_macro_expansion (const char *name, 
     if (strlen (macro_defs[ix].name) == name_len
         && !memcmp (name, macro_defs[ix].name, name_len))
       {
-        macro_t *expansion = xmalloc (sizeof (*expansion));
+        macro_t *expansion = XNEW (macro_t);
 
 	expansion->next = macro_expns;
-	expansion->name = xmemdup (arg, arg_len, arg_len+1);
+	expansion->name = (char *) xmemdup (arg, arg_len, arg_len+1);
 	expansion->expansion = macro_defs[ix].expansion;
 	macro_expns = expansion;
 	return;
Index: gcc/gengtype-yacc.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype-yacc.y,v
retrieving revision 1.14
diff -u -p -r1.14 gengtype-yacc.y
--- gcc/gengtype-yacc.y	23 Jun 2004 09:08:21 -0000	1.14
+++ gcc/gengtype-yacc.y	25 Jul 2004 19:57:02 -0000
@@ -160,10 +160,10 @@ yacc_ids: /* empty */
 	{ $$ = NULL; }
      | yacc_ids ID
         {
-	  pair_p p = xcalloc (1, sizeof (*p));
+	  pair_p p = XCNEW (struct pair);
 	  p->next = $1;
 	  p->line = lexer_line;
-	  p->opt = xmalloc (sizeof (*(p->opt)));
+	  p->opt = XNEW (struct options);
 	  p->opt->name = "tag";
 	  p->opt->next = NULL;
 	  p->opt->info = (char *)$2;
@@ -171,10 +171,10 @@ yacc_ids: /* empty */
 	}
      | yacc_ids CHAR
         {
-	  pair_p p = xcalloc (1, sizeof (*p));
+	  pair_p p = XCNEW (struct pair);
 	  p->next = $1;
 	  p->line = lexer_line;
-	  p->opt = xmalloc (sizeof (*(p->opt)));
+	  p->opt = XNEW (struct options);
 	  p->opt->name = "tag";
 	  p->opt->next = NULL;
 	  p->opt->info = xasprintf ("'%s'", $2);
@@ -185,7 +185,7 @@ yacc_ids: /* empty */
 struct_fields: { $$ = NULL; }
 	       | type optionsopt ID bitfieldopt ';' struct_fields
 	          {
-	            pair_p p = xmalloc (sizeof (*p));
+	            pair_p p = XNEW (struct pair);
 		    p->type = adjust_field_type ($1, $2);
 		    p->opt = $2;
 		    p->name = $3;
@@ -195,7 +195,7 @@ struct_fields: { $$ = NULL; }
 		  }
 	       | type optionsopt ID ARRAY ';' struct_fields
 	          {
-	            pair_p p = xmalloc (sizeof (*p));
+	            pair_p p = XNEW (struct pair);
 		    p->type = adjust_field_type (create_array ($1, $4), $2);
 		    p->opt = $2;
 		    p->name = $3;
@@ -205,7 +205,7 @@ struct_fields: { $$ = NULL; }
 		  }
 	       | type optionsopt ID ARRAY ARRAY ';' struct_fields
 	          {
-	            pair_p p = xmalloc (sizeof (*p));
+	            pair_p p = XNEW (struct pair);
 		    p->type = create_array (create_array ($1, $5), $4);
 		    p->opt = $2;
 		    p->name = $3;
@@ -314,7 +314,7 @@ stringseq: STRING
 	     {
 	       size_t l1 = strlen ($1);
 	       size_t l2 = strlen ($2);
-	       char *s = xrealloc ((char *)$1, l1 + l2 + 1);
+	       char *s = (char *) xrealloc ((char *)$1, l1 + l2 + 1);
 	       memcpy (s + l1, $2, l2 + 1);
 	       free ((void *)$2);
 	       $$ = s;
Index: gcc/gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.57
diff -u -p -r1.57 gengtype.c
--- gcc/gengtype.c	25 Jul 2004 00:13:00 -0000	1.57
+++ gcc/gengtype.c	25 Jul 2004 19:57:05 -0000
@@ -117,7 +117,7 @@ do_typedef (const char *s, type_p t, str
 	return;
       }
 
-  p = xmalloc (sizeof (struct pair));
+  p = XNEW (struct pair);
   p->next = typedefs;
   p->name = s;
   p->type = t;
@@ -173,7 +173,7 @@ new_structure (const char *name, int isu
 	else if (si->u.s.line.file != NULL && si->u.s.bitmap != bitmap)
 	  {
 	    ls = si;
-	    si = xcalloc (1, sizeof (struct type));
+	    si = XCNEW (struct type);
 	    memcpy (si, ls, sizeof (struct type));
 	    ls->kind = TYPE_LANG_STRUCT;
 	    ls->u.s.lang_struct = si;
@@ -187,7 +187,7 @@ new_structure (const char *name, int isu
 
 	if (ls != NULL && s == NULL)
 	  {
-	    s = xcalloc (1, sizeof (struct type));
+	    s = XCNEW (struct type);
 	    s->next = ls->u.s.lang_struct;
 	    ls->u.s.lang_struct = s;
 	    s->u.s.lang_struct = ls;
@@ -197,7 +197,7 @@ new_structure (const char *name, int isu
 
   if (s == NULL)
     {
-      s = xcalloc (1, sizeof (struct type));
+      s = XCNEW (struct type);
       s->next = structures;
       structures = s;
     }
@@ -233,7 +233,7 @@ find_structure (const char *name, int is
 	&& UNION_P (s) == isunion)
       return s;
 
-  s = xcalloc (1, sizeof (struct type));
+  s = XCNEW (struct type);
   s->next = structures;
   structures = s;
   s->kind = isunion ? TYPE_UNION : TYPE_STRUCT;
@@ -258,7 +258,7 @@ find_param_structure (type_p t, type_p p
       break;
   if (res == NULL)
     {
-      res = xcalloc (1, sizeof (*res));
+      res = XCNEW (struct type);
       res->kind = TYPE_PARAM_STRUCT;
       res->next = param_structs;
       param_structs = res;
@@ -273,9 +273,9 @@ find_param_structure (type_p t, type_p p
 type_p
 create_scalar_type (const char *name, size_t name_len)
 {
-  type_p r = xcalloc (1, sizeof (struct type));
+  type_p r = XCNEW (struct type);
   r->kind = TYPE_SCALAR;
-  r->u.sc = xmemdup (name, name_len, name_len + 1);
+  r->u.sc = (char *) xmemdup (name, name_len, name_len + 1);
   return r;
 }
 
@@ -286,7 +286,7 @@ create_pointer (type_p t)
 {
   if (! t->pointer_to)
     {
-      type_p r = xcalloc (1, sizeof (struct type));
+      type_p r = XCNEW (struct type);
       r->kind = TYPE_POINTER;
       r->u.p = t;
       t->pointer_to = r;
@@ -301,7 +301,7 @@ create_array (type_p t, const char *len)
 {
   type_p v;
 
-  v = xcalloc (1, sizeof (*v));
+  v = XCNEW (struct type);
   v->kind = TYPE_ARRAY;
   v->u.a.p = t;
   v->u.a.len = len;
@@ -312,7 +312,7 @@ create_array (type_p t, const char *len)
 options_p
 create_option (const char *name, void *info)
 {
-  options_p o = xmalloc (sizeof (*o));
+  options_p o = XNEW (struct options);
   o->name = name;
   o->info = info;
   return o;
@@ -325,7 +325,7 @@ void
 note_variable (const char *s, type_p t, options_p o, struct fileloc *pos)
 {
   pair_p n;
-  n = xmalloc (sizeof (*n));
+  n = XNEW (struct pair);
   n->name = s;
   n->type = t;
   n->line = *pos;
@@ -412,7 +412,7 @@ adjust_field_rtx_def (type_p t, options_
       return &string_type;
     }
 
-  nodot = xmalloc (sizeof (*nodot));
+  nodot = XNEW (struct options);
   nodot->next = NULL;
   nodot->name = "dot";
   nodot->info = "";
@@ -434,10 +434,10 @@ adjust_field_rtx_def (type_p t, options_
       {
 	pair_p old_note_flds = note_flds;
 
-	note_flds = xmalloc (sizeof (*note_flds));
+	note_flds = XNEW (struct pair);
 	note_flds->line.file = __FILE__;
 	note_flds->line.line = __LINE__;
-	note_flds->opt = xmalloc (sizeof (*note_flds->opt));
+	note_flds->opt = XNEW (struct options);
 	note_flds->opt->next = nodot;
 	note_flds->opt->name = "tag";
 	note_flds->opt->info = xasprintf ("%d", c);
@@ -586,7 +586,7 @@ adjust_field_rtx_def (type_p t, options_
 	      break;
 	    }
 
-	  subfields = xmalloc (sizeof (*subfields));
+	  subfields = XNEW (struct pair);
 	  subfields->next = old_subf;
 	  subfields->type = t;
 	  subfields->name = xasprintf (".fld[%lu].%s", (unsigned long)aindex,
@@ -595,7 +595,7 @@ adjust_field_rtx_def (type_p t, options_
 	  subfields->line.line = __LINE__;
 	  if (t == note_union_tp)
 	    {
-	      subfields->opt = xmalloc (sizeof (*subfields->opt));
+	      subfields->opt = XNEW (struct options);
 	      subfields->opt->next = nodot;
 	      subfields->opt->name = "desc";
 	      subfields->opt->info = "NOTE_LINE_NUMBER (&%0)";
@@ -603,7 +603,7 @@ adjust_field_rtx_def (type_p t, options_
 	  else if (t == basic_block_tp)
 	    {
 	      /* We don't presently GC basic block structures...  */
-	      subfields->opt = xmalloc (sizeof (*subfields->opt));
+	      subfields->opt = XNEW (struct options);
 	      subfields->opt->next = nodot;
 	      subfields->opt->name = "skip";
 	      subfields->opt->info = NULL;
@@ -612,7 +612,7 @@ adjust_field_rtx_def (type_p t, options_
 	    subfields->opt = nodot;
 	}
 
-      flds = xmalloc (sizeof (*flds));
+      flds = XNEW (struct pair);
       flds->next = old_flds;
       flds->name = "";
       sname = xasprintf ("rtx_def_%s", rtx_name[i]);
@@ -620,7 +620,7 @@ adjust_field_rtx_def (type_p t, options_
       flds->type = find_structure (sname, 0);
       flds->line.file = __FILE__;
       flds->line.line = __LINE__;
-      flds->opt = xmalloc (sizeof (*flds->opt));
+      flds->opt = XNEW (struct options);
       flds->opt->next = nodot;
       flds->opt->name = "tag";
       ftag = xstrdup (rtx_name[i]);
@@ -652,24 +652,24 @@ adjust_field_tree_exp (type_p t, options
       return &string_type;
     }
 
-  nodot = xmalloc (sizeof (*nodot));
+  nodot = XNEW (struct options);
   nodot->next = NULL;
   nodot->name = "dot";
   nodot->info = "";
 
-  flds = xmalloc (sizeof (*flds));
+  flds = XNEW (struct pair);
   flds->next = NULL;
   flds->name = "";
   flds->type = t;
   flds->line.file = __FILE__;
   flds->line.line = __LINE__;
-  flds->opt = xmalloc (sizeof (*flds->opt));
+  flds->opt = XNEW (struct options);
   flds->opt->next = nodot;
   flds->opt->name = "length";
   flds->opt->info = "TREE_CODE_LENGTH (TREE_CODE ((tree) &%0))";
   {
     options_p oldopt = flds->opt;
-    flds->opt = xmalloc (sizeof (*flds->opt));
+    flds->opt = XNEW (struct options);
     flds->opt->next = oldopt;
     flds->opt->name = "default";
     flds->opt->info = "";
@@ -998,7 +998,7 @@ create_file (const char *name, const cha
   outf_p f;
   size_t i;
 
-  f = xcalloc (sizeof (*f), 1);
+  f = XCNEW (struct outf);
   f->next = output_files;
   f->name = oname;
   output_files = f;
@@ -1028,7 +1028,7 @@ oprintf (outf_p o, const char *format, .
       do {
 	new_len *= 2;
       } while (o->bufused + slength >= new_len);
-      o->buf = xrealloc (o->buf, new_len);
+      o->buf = (char *) xrealloc (o->buf, new_len);
       o->buflength = new_len;
     }
   memcpy (o->buf + o->bufused, s, slength);
@@ -2716,7 +2716,7 @@ write_roots (pair_p variables)
 	  break;
       if (fli == NULL)
 	{
-	  fli = xmalloc (sizeof (*fli));
+	  fli = XNEW (struct flist);
 	  fli->f = f;
 	  fli->next = flp;
 	  fli->started_p = 0;
Index: gcc/genmodes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genmodes.c,v
retrieving revision 1.11
diff -u -p -r1.11 genmodes.c
--- gcc/genmodes.c	25 Jul 2004 17:57:23 -0000	1.11
+++ gcc/genmodes.c	25 Jul 2004 19:57:06 -0000
@@ -226,7 +226,7 @@ new_adjust (const char *name,
 	return;
       }
 
-  a = xmalloc (sizeof (struct mode_adjust));
+  a = XNEW (struct mode_adjust);
   a->mode = mode;
   a->adjustment = adjustment;
   a->file = file;
Index: gcc/gensupport.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gensupport.c,v
retrieving revision 1.51
diff -u -p -r1.51 gensupport.c
--- gcc/gensupport.c	25 Jul 2004 19:09:35 -0000	1.51
+++ gcc/gensupport.c	25 Jul 2004 19:57:09 -0000
@@ -144,7 +144,7 @@ static struct queue_elem *
 queue_pattern (rtx pattern, struct queue_elem ***list_tail,
 	       const char *filename, int lineno)
 {
-  struct queue_elem *e = xmalloc (sizeof (*e));
+  struct queue_elem *e = XNEW(struct queue_elem);
   e->data = pattern;
   e->filename = filename;
   e->lineno = lineno;
@@ -594,7 +594,7 @@ alter_predicate_for_insn (rtx pattern, i
 	  {
 	    size_t c_len = strlen (c);
 	    size_t len = alt * (c_len + 1);
-	    char *new_c = xmalloc (len);
+	    char *new_c = XNEWVEC(char, len);
 
 	    memcpy (new_c, c, c_len);
 	    for (i = 1; i < alt; ++i)
@@ -887,7 +887,7 @@ process_define_cond_exec (void)
 static char *
 save_string (const char *s, int len)
 {
-  char *result = xmalloc (len + 1);
+  char *result = XNEWVEC (char, len + 1);
 
   memcpy (result, s, len);
   result[len] = 0;
@@ -921,7 +921,7 @@ init_md_reader_args (int argc, char **ar
 	      {
 		struct file_name_list *dirtmp;
 
-		dirtmp = xmalloc (sizeof (struct file_name_list));
+		dirtmp = XNEW (struct file_name_list);
 		dirtmp->next = 0;	/* New one goes on the end */
 		if (first_dir_md_include == 0)
 		  first_dir_md_include = dirtmp;
@@ -1122,7 +1122,7 @@ maybe_eval_c_test (const char *expr)
     return -1;
 
   dummy.expr = expr;
-  test = htab_find (condition_table, &dummy);
+  test = (const struct c_test *)htab_find (condition_table, &dummy);
   if (!test)
     abort ();
 
Index: gcc/read-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/read-rtl.c,v
retrieving revision 1.23
diff -u -p -r1.23 read-rtl.c
--- gcc/read-rtl.c	10 May 2004 18:35:43 -0000	1.23
+++ gcc/read-rtl.c	25 Jul 2004 19:57:09 -0000
@@ -439,10 +439,10 @@ read_constants (FILE *infile, char *tmp_
 
       if (c != '(')
 	fatal_expected_char (infile, '(', c);
-      def = xmalloc (sizeof (struct md_constant));
+      def = XNEW (struct md_constant);
       def->name = tmp_char;
       read_name (tmp_char, infile);
-      entry_ptr = htab_find_slot (defs, def, TRUE);
+      entry_ptr = htab_find_slot (defs, def, INSERT);
       if (! *entry_ptr)
 	def->name = xstrdup (tmp_char);
       c = read_skip_spaces (infile);
