* 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().
From-SVN: r85163
+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().
+
2004-07-25 Bernardo Innocenti <bernie@develer.com>
* c-decl.c (groktypename, groktypename_in_param_context): Rename
obstack_chunk_free);
}
- element = obstack_alloc (&bitmap_obstack, sizeof (bitmap_element));
+ element = XOBNEW (&bitmap_obstack, bitmap_element);
}
}
else
bitmap_ggc_free = element->next;
}
else
- element = ggc_alloc (sizeof (bitmap_element));
+ element = GGC_NEW (bitmap_element);
}
memset (element->bits, 0, sizeof (element->bits));
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;
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;
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;
binding_freelist = b->prev;
}
else
- b = ggc_alloc (sizeof (struct c_binding));
+ b = GGC_NEW (struct c_binding);
b->shadowed = 0;
b->decl = decl;
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;
/* 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
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");
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;
/* 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;
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;
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;
}
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;
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;
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);
}
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];
/* 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)
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';
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
{ \
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); \
} \
\
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)
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);
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;
{
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;
}
}
- r = ggc_alloc (sizeof (struct init_node));
+ r = GGC_NEW (struct init_node);
r->purpose = purpose;
r->value = value;
}
/* 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;
/* Pop the stack. */
c_switch_stack = cs->next;
splay_tree_delete (cs->cases);
- free (cs);
+ XDELETE (cs);
}
\f
/* Emit an if statement. IF_LOCUS is the location of the 'if'. COND,
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;
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;
{ $$ = 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;
}
| 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);
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;
}
| 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;
}
| 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;
{
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;
return;
}
- p = xmalloc (sizeof (struct pair));
+ p = XNEW (struct pair);
p->next = typedefs;
p->name = s;
p->type = t;
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;
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;
if (s == NULL)
{
- s = xcalloc (1, sizeof (struct type));
+ s = XCNEW (struct type);
s->next = structures;
structures = s;
}
&& 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;
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;
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;
}
{
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;
{
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;
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;
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;
return &string_type;
}
- nodot = xmalloc (sizeof (*nodot));
+ nodot = XNEW (struct options);
nodot->next = NULL;
nodot->name = "dot";
nodot->info = "";
{
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);
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,
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)";
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;
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]);
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]);
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 = "";
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;
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);
break;
if (fli == NULL)
{
- fli = xmalloc (sizeof (*fli));
+ fli = XNEW (struct flist);
fli->f = f;
fli->next = flp;
fli->started_p = 0;
return;
}
- a = xmalloc (sizeof (struct mode_adjust));
+ a = XNEW (struct mode_adjust);
a->mode = mode;
a->adjustment = adjustment;
a->file = file;
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;
{
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)
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;
{
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;
return -1;
dummy.expr = expr;
- test = htab_find (condition_table, &dummy);
+ test = (const struct c_test *)htab_find (condition_table, &dummy);
if (!test)
abort ();
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);