aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2009-01-26 18:57:44 +0000
committerPedro Alves <palves@redhat.com>2009-01-26 18:57:44 +0000
commit1deafd4ea5ec0948407fe58c3ea5d1737e000133 (patch)
treee1bcb25ee0448d400ea6c8939515c067e87006f5 /gdb
parent3c16cced400ed60fb35435dd28c31e982a064328 (diff)
downloadgdb-1deafd4ea5ec0948407fe58c3ea5d1737e000133.zip
gdb-1deafd4ea5ec0948407fe58c3ea5d1737e000133.tar.gz
gdb-1deafd4ea5ec0948407fe58c3ea5d1737e000133.tar.bz2
* 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/gdbtypes.c53
2 files changed, 25 insertions, 36 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8e8f7c9..032afd8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
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
ask|yes|no" commands.
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index dfa06ae..9f73173 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -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) =