* gdbtypes.c (alloc_type, alloc_type_instance, create_range_type)
(create_array_type, create_set_type, init_flags_type) (copy_type_recursive): Replace pairs of calls to XALLOC and memset with a call to XZALLOC or XCALLOC, and pairs of calls to obstack_alloc and memset with a call to OBSTACK_ZALLOC.
This commit is contained in:
parent
3c16cced40
commit
1deafd4ea5
@ -1,3 +1,11 @@
|
||||
2009-01-26 Pedro Alves <pedro@codesourcery.com>
|
||||
|
||||
* gdbtypes.c (alloc_type, alloc_type_instance, create_range_type)
|
||||
(create_array_type, create_set_type, init_flags_type)
|
||||
(copy_type_recursive): Replace pairs of calls to XALLOC and memset
|
||||
with a call to XZALLOC or XCALLOC, and pairs of calls to
|
||||
obstack_alloc and memset with a call to OBSTACK_ZALLOC.
|
||||
|
||||
2009-01-26 Pedro Alves <pedro@codesourcery.com>
|
||||
|
||||
Add "maint set|show internal-error|internal-warning quit|corefile
|
||||
|
@ -162,20 +162,16 @@ alloc_type (struct objfile *objfile)
|
||||
|
||||
if (objfile == NULL)
|
||||
{
|
||||
type = xmalloc (sizeof (struct type));
|
||||
memset (type, 0, sizeof (struct type));
|
||||
TYPE_MAIN_TYPE (type) = xmalloc (sizeof (struct main_type));
|
||||
type = XZALLOC (struct type);
|
||||
TYPE_MAIN_TYPE (type) = XZALLOC (struct main_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = obstack_alloc (&objfile->objfile_obstack,
|
||||
sizeof (struct type));
|
||||
memset (type, 0, sizeof (struct type));
|
||||
TYPE_MAIN_TYPE (type) = obstack_alloc (&objfile->objfile_obstack,
|
||||
sizeof (struct main_type));
|
||||
type = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct type);
|
||||
TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (&objfile->objfile_obstack,
|
||||
struct main_type);
|
||||
OBJSTAT (objfile, n_types++);
|
||||
}
|
||||
memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type));
|
||||
|
||||
/* Initialize the fields that might not be zero. */
|
||||
|
||||
@ -199,16 +195,11 @@ alloc_type_instance (struct type *oldtype)
|
||||
/* Allocate the structure. */
|
||||
|
||||
if (TYPE_OBJFILE (oldtype) == NULL)
|
||||
{
|
||||
type = xmalloc (sizeof (struct type));
|
||||
memset (type, 0, sizeof (struct type));
|
||||
}
|
||||
type = XZALLOC (struct type);
|
||||
else
|
||||
{
|
||||
type = obstack_alloc (&TYPE_OBJFILE (oldtype)->objfile_obstack,
|
||||
sizeof (struct type));
|
||||
memset (type, 0, sizeof (struct type));
|
||||
}
|
||||
type = OBSTACK_ZALLOC (&TYPE_OBJFILE (oldtype)->objfile_obstack,
|
||||
struct type);
|
||||
|
||||
TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype);
|
||||
|
||||
TYPE_CHAIN (type) = type; /* Chain back to itself for now. */
|
||||
@ -705,9 +696,7 @@ create_range_type (struct type *result_type, struct type *index_type,
|
||||
int low_bound, int high_bound)
|
||||
{
|
||||
if (result_type == NULL)
|
||||
{
|
||||
result_type = alloc_type (TYPE_OBJFILE (index_type));
|
||||
}
|
||||
result_type = alloc_type (TYPE_OBJFILE (index_type));
|
||||
TYPE_CODE (result_type) = TYPE_CODE_RANGE;
|
||||
TYPE_TARGET_TYPE (result_type) = index_type;
|
||||
if (TYPE_STUB (index_type))
|
||||
@ -715,11 +704,9 @@ create_range_type (struct type *result_type, struct type *index_type,
|
||||
else
|
||||
TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
|
||||
TYPE_NFIELDS (result_type) = 2;
|
||||
TYPE_FIELDS (result_type) = TYPE_ALLOC (result_type,
|
||||
TYPE_NFIELDS (result_type)
|
||||
* sizeof (struct field));
|
||||
memset (TYPE_FIELDS (result_type), 0,
|
||||
TYPE_NFIELDS (result_type) * sizeof (struct field));
|
||||
TYPE_FIELDS (result_type) = TYPE_ZALLOC (result_type,
|
||||
TYPE_NFIELDS (result_type)
|
||||
* sizeof (struct field));
|
||||
TYPE_LOW_BOUND (result_type) = low_bound;
|
||||
TYPE_HIGH_BOUND (result_type) = high_bound;
|
||||
|
||||
@ -835,8 +822,7 @@ create_array_type (struct type *result_type,
|
||||
TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
|
||||
TYPE_NFIELDS (result_type) = 1;
|
||||
TYPE_FIELDS (result_type) =
|
||||
(struct field *) TYPE_ALLOC (result_type, sizeof (struct field));
|
||||
memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
|
||||
(struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
|
||||
TYPE_INDEX_TYPE (result_type) = range_type;
|
||||
TYPE_VPTR_FIELDNO (result_type) = -1;
|
||||
|
||||
@ -883,9 +869,7 @@ create_set_type (struct type *result_type, struct type *domain_type)
|
||||
}
|
||||
TYPE_CODE (result_type) = TYPE_CODE_SET;
|
||||
TYPE_NFIELDS (result_type) = 1;
|
||||
TYPE_FIELDS (result_type) = (struct field *)
|
||||
TYPE_ALLOC (result_type, 1 * sizeof (struct field));
|
||||
memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
|
||||
TYPE_FIELDS (result_type) = TYPE_ZALLOC (result_type, sizeof (struct field));
|
||||
|
||||
if (!TYPE_STUB (domain_type))
|
||||
{
|
||||
@ -931,9 +915,7 @@ init_flags_type (char *name, int length)
|
||||
type = init_type (TYPE_CODE_FLAGS, length,
|
||||
TYPE_FLAG_UNSIGNED, name, NULL);
|
||||
TYPE_NFIELDS (type) = nfields;
|
||||
TYPE_FIELDS (type) = TYPE_ALLOC (type,
|
||||
nfields * sizeof (struct field));
|
||||
memset (TYPE_FIELDS (type), 0, nfields * sizeof (struct field));
|
||||
TYPE_FIELDS (type) = TYPE_ZALLOC (type, nfields * sizeof (struct field));
|
||||
|
||||
return type;
|
||||
}
|
||||
@ -2981,8 +2963,7 @@ copy_type_recursive (struct objfile *objfile,
|
||||
int i, nfields;
|
||||
|
||||
nfields = TYPE_NFIELDS (type);
|
||||
TYPE_FIELDS (new_type) = xmalloc (sizeof (struct field) * nfields);
|
||||
memset (TYPE_FIELDS (new_type), 0, sizeof (struct field) * nfields);
|
||||
TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field);
|
||||
for (i = 0; i < nfields; i++)
|
||||
{
|
||||
TYPE_FIELD_ARTIFICIAL (new_type, i) =
|
||||
|
Loading…
Reference in New Issue
Block a user