/* Allocate a new GDBARCH-associated type structure and fill it
with some defaults. Space for the type structure is allocated
- on the heap. */
+ on the obstack associated with GDBARCH. */
struct type *
alloc_type_arch (struct gdbarch *gdbarch)
/* Alloc the structure and start off with all fields zeroed. */
- type = XCNEW (struct type);
- TYPE_MAIN_TYPE (type) = XCNEW (struct main_type);
+ type = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct type);
+ TYPE_MAIN_TYPE (type) = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct main_type);
TYPE_OBJFILE_OWNED (type) = 0;
TYPE_OWNER (type).gdbarch = gdbarch;
struct value **args, int nargs)
{
int i;
- struct badness_vector *bv;
+ struct badness_vector *bv = XNEW (struct badness_vector);
int min_len = nparms < nargs ? nparms : nargs;
- bv = xmalloc (sizeof (struct badness_vector));
bv->length = nargs + 1; /* add 1 for the length-match rank. */
bv->rank = XNEWVEC (struct rank, nargs + 1);
}
/* Recursively copy (deep copy) TYPE, if it is associated with
- OBJFILE. Return a new type allocated using malloc, a saved type if
- we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
- not associated with OBJFILE. */
+ OBJFILE. Return a new type owned by the gdbarch associated with the type, a
+ saved type if we have already visited TYPE (using COPIED_TYPES), or TYPE if
+ it is not associated with OBJFILE. */
struct type *
copy_type_recursive (struct objfile *objfile,
/* We must add the new type to the hash table immediately, in case
we encounter this type again during a recursive call below. */
- stored
- = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair));
+ stored = XOBNEW (&objfile->objfile_obstack, struct type_pair);
stored->old = type;
stored->newobj = new_type;
*slot = stored;
/* For range types, copy the bounds information. */
if (TYPE_CODE (type) == TYPE_CODE_RANGE)
{
- TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
+ TYPE_RANGE_DATA (new_type) = XNEW (struct range_bounds);
*TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
}
TYPE_LENGTH (type) = length;
if (name)
- TYPE_NAME (type) = xstrdup (name);
+ TYPE_NAME (type) = gdbarch_obstack_strdup (gdbarch, name);
return type;
}