* [PATCH] use XNEW and related macros more
@ 2016-04-24 8:30 tbsaunde+binutils
2016-04-25 8:41 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: tbsaunde+binutils @ 2016-04-24 8:30 UTC (permalink / raw)
To: binutils; +Cc: Trevor Saunders
From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
Hi,
More of the same, Its a bit shorter and simpler than raw xmalloc.
built crosses to one target per tc-*.c, and regtested x86_64-linux-gnu, ok?
Trev
gas/ChangeLog:
2016-04-24 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* app.c (app_push): Use XNEW and related macros.
* as.c (parse_args): Likewise.
* cgen.c (make_right_shifted_expr): Likewise.
(gas_cgen_tc_gen_reloc): Likewise.
* config/bfin-defs.h: Likewise.
* config/bfin-parse.y: Likewise.
* config/obj-coff.c (stack_init): Likewise.
(stack_push): Likewise.
(coff_obj_symbol_new_hook): Likewise.
(coff_obj_symbol_clone_hook): Likewise.
(add_lineno): Likewise.
(coff_frob_symbol): Likewise.
* config/obj-elf.c (obj_elf_section_name): Likewise.
(build_group_lists): Likewise.
* config/obj-evax.c (evax_symbol_new_hook): Likewise.
* config/obj-macho.c (obj_mach_o_indirect_symbol): Likewise.
* config/tc-aarch64.c (insert_reg_alias): Likewise.
(find_or_make_literal_pool): Likewise.
(add_to_lit_pool): Likewise.
(fill_instruction_hash_table): Likewise.
* config/tc-alpha.c (load_expression): Likewise.
(emit_jsrjmp): Likewise.
(s_alpha_ent): Likewise.
(s_alpha_end): Likewise.
(s_alpha_linkage): Likewise.
(md_begin): Likewise.
(tc_gen_reloc): Likewise.
* config/tc-arc.c (arc_insert_opcode): Likewise.
(arc_extcorereg): Likewise.
* config/tc-bfin.c: Likewise.
* config/tc-cr16.c: Likewise.
* config/tc-cris.c: Likewise.
* config/tc-crx.c (preprocess_reglist): Likewise.
* config/tc-d10v.c: Likewise.
* config/tc-frv.c (frv_insert_vliw_insn): Likewise.
(frv_tomcat_shuffle): Likewise.
* config/tc-h8300.c: Likewise.
* config/tc-i370.c (i370_macro): Likewise.
* config/tc-i386.c (lex_got): Likewise.
(md_parse_option): Likewise.
* config/tc-ia64.c (alloc_record): Likewise.
(set_imask): Likewise.
(save_prologue_count): Likewise.
(dot_proc): Likewise.
(dot_endp): Likewise.
(ia64_frob_label): Likewise.
(add_qp_imply): Likewise.
(add_qp_mutex): Likewise.
(mark_resource): Likewise.
(dot_alias): Likewise.
* config/tc-m68hc11.c: Likewise.
* config/tc-m68k.c (m68k_frob_label): Likewise.
(s_save): Likewise.
(mri_control_label): Likewise.
(push_mri_control): Likewise.
(build_mri_control_operand): Likewise.
(s_mri_else): Likewise.
(s_mri_break): Likewise.
(s_mri_next): Likewise.
(s_mri_for): Likewise.
(s_mri_endw): Likewise.
* config/tc-metag.c (create_mnemonic_htab): Likewise.
* config/tc-microblaze.c: Likewise.
* config/tc-mmix.c (s_loc): Likewise.
* config/tc-nds32.c (nds32_relax_hint): Likewise.
* config/tc-nios2.c (nios2_insn_reloc_new): Likewise.
* config/tc-rl78.c: Likewise.
* config/tc-rx.c (rx_include): Likewise.
* config/tc-sh.c: Likewise.
* config/tc-sh64.c (shmedia_frob_section_type): Likewise.
* config/tc-sparc.c: Likewise.
* config/tc-spu.c: Likewise.
* config/tc-tic6x.c (static tic6x_unwind_info *tic6x_get_unwind): Likewise.
(tic6x_start_unwind_section): Likewise.
* config/tc-tilegx.c: Likewise.
* config/tc-tilepro.c: Likewise.
* config/tc-v850.c: Likewise.
* config/tc-visium.c: Likewise.
* config/tc-xgate.c: Likewise.
* config/tc-xtensa.c (xtensa_translate_old_userreg_ops): Likewise.
(new_resource_table): Likewise.
(resize_resource_table): Likewise.
(xtensa_create_trampoline_frag): Likewise.
(xtensa_maybe_create_literal_pool_frag): Likewise.
(cache_literal_section): Likewise.
* config/xtensa-relax.c (append_transition): Likewise.
(append_condition): Likewise.
(append_value_condition): Likewise.
(append_constant_value_condition): Likewise.
(append_literal_op): Likewise.
(append_label_op): Likewise.
(append_constant_op): Likewise.
(append_field_op): Likewise.
(append_user_fn_field_op): Likewise.
(enter_opname_n): Likewise.
(enter_opname): Likewise.
(split_string): Likewise.
(parse_insn_templ): Likewise.
(clone_req_or_option_list): Likewise.
(clone_req_option_list): Likewise.
(parse_option_cond): Likewise.
(parse_insn_pattern): Likewise.
(parse_insn_repl): Likewise.
(build_transition): Likewise.
(build_transition_table): Likewise.
* dw2gencfi.c (alloc_fde_entry): Likewise.
(alloc_cfi_insn_data): Likewise.
(cfi_add_CFA_remember_state): Likewise.
(dot_cfi_escape): Likewise.
(dot_cfi_fde_data): Likewise.
(select_cie_for_fde): Likewise.
* dwarf2dbg.c (dwarf2_directive_loc): Likewise.
* ecoff.c (ecoff_add_bytes): Likewise.
(ecoff_build_debug): Likewise.
* input-scrub.c (input_scrub_push): Likewise.
(input_scrub_begin): Likewise.
(input_scrub_next_buffer): Likewise.
* itbl-ops.c (append_insns_as_macros): Likewise.
(alloc_entry): Likewise.
(alloc_field): Likewise.
* listing.c (listing_newline): Likewise.
(listing_listing): Likewise.
* macro.c (get_any_string): Likewise.
(delete_macro): Likewise.
* stabs.c (generate_asm_file): Likewise.
(stabs_generate_asm_lineno): Likewise.
* subsegs.c (subseg_change): Likewise.
(subseg_get): Likewise.
* symbols.c (define_dollar_label): Likewise.
(symbol_relc_make_sym): Likewise.
* write.c (write_relocs): Likewise.
---
gas/app.c | 2 +-
gas/as.c | 4 ++--
gas/cgen.c | 6 +++---
gas/config/bfin-defs.h | 1 -
gas/config/bfin-parse.y | 2 +-
gas/config/obj-coff.c | 22 ++++++++++-----------
gas/config/obj-elf.c | 8 +++-----
gas/config/obj-evax.c | 3 +--
gas/config/obj-macho.c | 3 +--
gas/config/tc-aarch64.c | 9 +++++----
gas/config/tc-alpha.c | 21 +++++++++-----------
gas/config/tc-arc.c | 17 ++++++++--------
gas/config/tc-bfin.c | 4 ++--
gas/config/tc-cr16.c | 4 ++--
gas/config/tc-cris.c | 4 ++--
gas/config/tc-crx.c | 2 +-
gas/config/tc-d10v.c | 4 ++--
gas/config/tc-frv.c | 10 +++++-----
gas/config/tc-h8300.c | 5 ++---
gas/config/tc-i370.c | 6 +++---
gas/config/tc-i386.c | 14 +++++++-------
gas/config/tc-ia64.c | 31 +++++++++++-------------------
gas/config/tc-m68hc11.c | 11 ++++-------
gas/config/tc-m68k.c | 32 +++++++++++++++----------------
gas/config/tc-metag.c | 6 +++---
gas/config/tc-microblaze.c | 4 ++--
gas/config/tc-mmix.c | 7 +++----
gas/config/tc-nds32.c | 10 +++++-----
gas/config/tc-nios2.c | 6 +++---
gas/config/tc-rl78.c | 8 ++++----
gas/config/tc-rx.c | 4 ++--
gas/config/tc-sh.c | 4 ++--
gas/config/tc-sh64.c | 2 +-
gas/config/tc-sparc.c | 8 ++++----
gas/config/tc-spu.c | 4 ++--
gas/config/tc-tic6x.c | 4 ++--
gas/config/tc-tilegx.c | 4 ++--
gas/config/tc-tilepro.c | 4 ++--
gas/config/tc-v850.c | 4 ++--
gas/config/tc-visium.c | 4 ++--
gas/config/tc-xgate.c | 10 ++++------
gas/config/tc-xtensa.c | 14 +++++++-------
gas/config/xtensa-relax.c | 48 ++++++++++++++++++++++------------------------
gas/dw2gencfi.c | 19 ++++++++----------
gas/dwarf2dbg.c | 2 +-
gas/ecoff.c | 4 ++--
gas/input-scrub.c | 18 ++++++++---------
gas/itbl-ops.c | 11 ++++-------
gas/listing.c | 31 ++++++++++++++----------------
gas/macro.c | 6 +++---
gas/stabs.c | 6 +++---
gas/subsegs.c | 4 ++--
gas/symbols.c | 15 ++++++++-------
gas/write.c | 2 +-
54 files changed, 231 insertions(+), 267 deletions(-)
diff --git a/gas/app.c b/gas/app.c
index c59421c..38d8e78 100644
--- a/gas/app.c
+++ b/gas/app.c
@@ -259,7 +259,7 @@ app_push (void)
saved->saved_input = NULL;
else
{
- saved->saved_input = (char *) xmalloc (saved_input_len);
+ saved->saved_input = XNEWVEC (char, saved_input_len);
memcpy (saved->saved_input, saved_input, saved_input_len);
saved->saved_input_len = saved_input_len;
}
diff --git a/gas/as.c b/gas/as.c
index 15f53ea..badeac9 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -569,7 +569,7 @@ parse_args (int * pargc, char *** pargv)
old_argv = *pargv;
/* Initialize a new argv that contains no options. */
- new_argv = (char **) xmalloc (sizeof (char *) * (old_argc + 1));
+ new_argv = XNEWVEC (char *, old_argc + 1);
new_argv[0] = old_argv[0];
new_argc = 1;
new_argv[new_argc] = NULL;
@@ -726,7 +726,7 @@ This program has absolutely no warranty.\n"));
as_fatal (_("bad defsym; format is --defsym name=value"));
*s++ = '\0';
i = bfd_scan_vma (s, (const char **) NULL, 0);
- n = (struct defsym_list *) xmalloc (sizeof *n);
+ n = XNEW (struct defsym_list);
n->next = defsyms;
n->name = optarg;
n->value = i;
diff --git a/gas/cgen.c b/gas/cgen.c
index c04a921..c897dcf 100644
--- a/gas/cgen.c
+++ b/gas/cgen.c
@@ -811,7 +811,7 @@ make_right_shifted_expr (expressionS * exp,
stmp->bsym->flags |= BSF_RELC;
/* Then wrap that in a "symbol expr" for good measure. */
- new_exp = xmalloc (sizeof (expressionS));
+ new_exp = XNEW (expressionS);
memset (new_exp, 0, sizeof (expressionS));
new_exp->X_op = O_symbol;
new_exp->X_op_symbol = 0;
@@ -1012,7 +1012,7 @@ gas_cgen_tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
bfd_reloc_code_real_type r_type = fixP->fx_r_type;
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
#ifdef GAS_CGEN_PCREL_R_TYPE
if (fixP->fx_pcrel)
@@ -1029,7 +1029,7 @@ gas_cgen_tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
gas_assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
/* Use fx_offset for these cases. */
diff --git a/gas/config/bfin-defs.h b/gas/config/bfin-defs.h
index 4c1d8b7..256587c 100644
--- a/gas/config/bfin-defs.h
+++ b/gas/config/bfin-defs.h
@@ -325,7 +325,6 @@ Expr_Node *Expr_Node_Create (Expr_Node_Type type,
INSTR_T Expr_Node_Gen_Reloc (Expr_Node *head, int parent_reloc);
#define MKREF(x) mkexpr (0,x)
-#define ALLOCATE(x) malloc (x)
#define NULL_CODE ((INSTR_T) 0)
diff --git a/gas/config/bfin-parse.y b/gas/config/bfin-parse.y
index 26070c1..a2eaa4c 100644
--- a/gas/config/bfin-parse.y
+++ b/gas/config/bfin-parse.y
@@ -4494,7 +4494,7 @@ expr_1: expr_1 STAR expr_1
EXPR_T
mkexpr (int x, SYMBOL_T s)
{
- EXPR_T e = (EXPR_T) ALLOCATE (sizeof (struct expression_cell));
+ EXPR_T e = XNEW (struct expression_cell);
e->value = x;
EXPR_SYMBOL(e) = s;
return e;
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index 02c0634..b8754e1 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -77,10 +77,8 @@ stack_init (unsigned long chunk_size,
{
stack *st;
- st = malloc (sizeof (* st));
- if (!st)
- return NULL;
- st->data = malloc (chunk_size);
+ st = XNEW (stack);
+ st->data = XNEWVEC (char, chunk_size);
if (!st->data)
{
free (st);
@@ -99,8 +97,7 @@ stack_push (stack *st, char *element)
if (st->pointer + st->element_size >= st->size)
{
st->size += st->chunk_size;
- if ((st->data = xrealloc (st->data, st->size)) == NULL)
- return NULL;
+ st->data = XRESIZEVEC (char, st->data, st->size);
}
memcpy (st->data + st->pointer, element, st->element_size);
st->pointer += st->element_size;
@@ -383,7 +380,7 @@ void
coff_obj_symbol_new_hook (symbolS *symbolP)
{
long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type);
- char * s = xmalloc (sz);
+ char * s = XNEWVEC (char, sz);
memset (s, 0, sz);
coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s;
@@ -403,10 +400,11 @@ coff_obj_symbol_new_hook (symbolS *symbolP)
void
coff_obj_symbol_clone_hook (symbolS *newsymP, symbolS *orgsymP)
{
- long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type);
- combined_entry_type * s = xmalloc (sz);
+ long elts = OBJ_COFF_MAX_AUXENTRIES + 1;
+ combined_entry_type * s = XNEWVEC (combined_entry_type, elts);
- memcpy (s, coffsymbol (symbol_get_bfdsym (orgsymP))->native, sz);
+ memcpy (s, coffsymbol (symbol_get_bfdsym (orgsymP))->native,
+ elts * sizeof (combined_entry_type));
coffsymbol (symbol_get_bfdsym (newsymP))->native = s;
SF_SET (newsymP, SF_GET (orgsymP));
@@ -423,7 +421,7 @@ int coff_n_line_nos;
static void
add_lineno (fragS * frag, addressT offset, int num)
{
- struct line_no * new_line = xmalloc (sizeof (* new_line));
+ struct line_no * new_line = XNEW (struct line_no);
if (!current_lineno_sym)
abort ();
@@ -1444,7 +1442,7 @@ coff_frob_symbol (symbolS *symp, int *punt)
/* We need i entries for line numbers, plus 1 for the first
entry which BFD will override, plus 1 for the last zero
entry (a marker for BFD). */
- l = xmalloc ((i + 2) * sizeof (* l));
+ l = XNEWVEC (alent, (i + 2));
coffsymbol (symbol_get_bfdsym (symp))->lineno = l;
l[i + 1].line_number = 0;
l[i + 1].u.sym = NULL;
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 1404443..3a876a7 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -959,7 +959,7 @@ obj_elf_section_name (void)
int oldlen = strlen (name);
int substlen = strlen (now_seg->name);
int newlen = oldlen - 2 + substlen;
- char *newname = (char *) xmalloc (newlen + 1);
+ char *newname = XNEWVEC (char, newlen + 1);
int headlen = subst - name;
memcpy (newname, name, headlen);
strcpy (newname + headlen, now_seg->name);
@@ -2324,10 +2324,8 @@ build_group_lists (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
if ((i & 127) == 0)
{
unsigned int newsize = i + 128;
- list->head = (asection **) xrealloc (list->head,
- newsize * sizeof (*list->head));
- list->elt_count = (unsigned int *)
- xrealloc (list->elt_count, newsize * sizeof (*list->elt_count));
+ list->head = XRESIZEVEC (asection *, list->head, newsize);
+ list->elt_count = XRESIZEVEC (unsigned int, list->elt_count, newsize);
}
list->head[i] = sec;
list->elt_count[i] = 1;
diff --git a/gas/config/obj-evax.c b/gas/config/obj-evax.c
index aa925a9..9de65b0 100644
--- a/gas/config/obj-evax.c
+++ b/gas/config/obj-evax.c
@@ -86,8 +86,7 @@ evax_symbol_new_hook (symbolS *sym)
{
struct evax_private_udata_struct *udata;
- udata = (struct evax_private_udata_struct *)
- xmalloc (sizeof (struct evax_private_udata_struct));
+ udata = XNEW (struct evax_private_udata_struct);
udata->bsym = symbol_get_bfdsym (sym);
udata->enbsym = NULL;
diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index ba079f3..13d0043 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -1195,8 +1195,7 @@ obj_mach_o_indirect_symbol (int arg ATTRIBUTE_UNUSED)
indirect, it is promoted to a 'real' one. Fetching the bfd sym
achieves this. */
symbol_get_bfdsym (sym);
- isym = (obj_mach_o_indirect_sym *)
- xmalloc (sizeof (obj_mach_o_indirect_sym));
+ isym = XNEW (obj_mach_o_indirect_sym);
/* Just record the data for now, we will validate it when we
compute the output in obj_mach_o_set_indirect_symbols. */
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 4b5099f..693e3f3 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1187,7 +1187,7 @@ insert_reg_alias (char *str, int number, aarch64_reg_type type)
}
name = xstrdup (str);
- new = xmalloc (sizeof (reg_entry));
+ new = XNEW (reg_entry);
new->name = name;
new->number = number;
@@ -1575,7 +1575,7 @@ find_or_make_literal_pool (int size)
if (pool == NULL)
{
/* Create a new pool. */
- pool = xmalloc (sizeof (*pool));
+ pool = XNEW (literal_pool);
if (!pool)
return NULL;
@@ -1652,7 +1652,8 @@ add_to_lit_pool (expressionS *exp, int size)
{
/* PR 16688: Bignums are held in a single global array. We must
copy and preserve that value now, before it is overwritten. */
- pool->literals[entry].bignum = xmalloc (CHARS_PER_LITTLENUM * exp->X_add_number);
+ pool->literals[entry].bignum = XNEWVEC (LITTLENUM_TYPE,
+ exp->X_add_number);
memcpy (pool->literals[entry].bignum, generic_bignum,
CHARS_PER_LITTLENUM * exp->X_add_number);
}
@@ -7505,7 +7506,7 @@ fill_instruction_hash_table (void)
templates *templ, *new_templ;
templ = hash_find (aarch64_ops_hsh, opcode->name);
- new_templ = (templates *) xmalloc (sizeof (templates));
+ new_templ = XNEW (templates);
new_templ->opcode = opcode;
new_templ->next = NULL;
diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c
index 970e06f..d775c9d 100644
--- a/gas/config/tc-alpha.c
+++ b/gas/config/tc-alpha.c
@@ -1384,7 +1384,7 @@ load_expression (int targreg,
ptr1 = strstr (symname, "..") + 2;
if (ptr1 > ptr2)
ptr1 = symname;
- ensymname = (char *) xmalloc (ptr2 - ptr1 + 5);
+ ensymname = XNEWVEC (char, ptr2 - ptr1 + 5);
memcpy (ensymname, ptr1, ptr2 - ptr1);
memcpy (ensymname + (ptr2 - ptr1), "..en", 5);
@@ -2881,7 +2881,7 @@ emit_jsrjmp (const expressionS *tok,
char *ensymname;
/* Build the entry name as 'NAME..en'. */
- ensymname = (char *) xmalloc (symlen + 5);
+ ensymname = XNEWVEC (char, symlen + 5);
memcpy (ensymname, symname, symlen);
memcpy (ensymname + symlen, "..en", 5);
@@ -3733,8 +3733,7 @@ s_alpha_ent (int dummy ATTRIBUTE_UNUSED)
sym = symbol_find_or_make (name);
symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION;
- cur_frame_data = (struct alpha_elf_frame_data *)
- calloc (1, sizeof (*cur_frame_data));
+ cur_frame_data = XCNEW (struct alpha_elf_frame_data);
cur_frame_data->func_sym = sym;
/* Provide sensible defaults. */
@@ -3789,7 +3788,7 @@ s_alpha_end (int dummy ATTRIBUTE_UNUSED)
if (sym && cur_frame_data)
{
OBJ_SYMFIELD_TYPE *obj = symbol_get_obj (sym);
- expressionS *exp = (expressionS *) xmalloc (sizeof (expressionS));
+ expressionS *exp = XNEW (expressionS);
obj->size = exp;
exp->X_op = O_subtract;
@@ -4712,8 +4711,7 @@ s_alpha_linkage (int ignore ATTRIBUTE_UNUSED)
(FAKE_LABEL_NAME, now_seg, (valueT) frag_now_fix (), frag_now);
/* Create a linkage element. */
- linkage_fixup = (struct alpha_linkage_fixups *)
- xmalloc (sizeof (struct alpha_linkage_fixups));
+ linkage_fixup = XNEW (struct alpha_linkage_fixups);
linkage_fixup->fixp = fixp;
linkage_fixup->next = NULL;
linkage_fixup->label = alpha_insn_label;
@@ -5439,7 +5437,7 @@ md_begin (void)
if ((slash = strchr (name, '/')) != NULL)
{
- char *p = (char *) xmalloc (strlen (name));
+ char *p = XNEWVEC (char, strlen (name));
memcpy (p, name, slash - name);
strcpy (p + (slash - name), slash + 1);
@@ -6220,8 +6218,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED,
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (* reloc));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
@@ -6296,8 +6294,7 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED,
pname = symbol_get_bfdsym (sym)->name;
}
- udata = (struct evax_private_udata_struct *)
- xmalloc (sizeof (struct evax_private_udata_struct));
+ udata = XNEW (struct evax_private_udata_struct);
udata->enbsym = symbol_get_bfdsym (fixp->fx_addsy);
udata->bsym = symbol_get_bfdsym (fixp->tc_fix_data.info->psym);
udata->origname = (char *)pname;
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index af02cfb..5f5b4b0 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -698,7 +698,7 @@ arc_insert_opcode (const struct arc_opcode *opcode)
entry = hash_find (arc_opcode_hash, name);
if (entry == NULL)
{
- entry = xmalloc (sizeof (*entry));
+ entry = XNEW (struct arc_opcode_hash_entry);
entry->count = 0;
entry->opcode = NULL;
@@ -708,9 +708,8 @@ arc_insert_opcode (const struct arc_opcode *opcode)
name, retval);
}
- entry->opcode = xrealloc (entry->opcode,
- sizeof (const struct arc_opcode *)
- * (entry->count + 1));
+ entry->opcode = XRESIZEVEC (const struct arc_opcode *, entry->opcode,
+ entry->count + 1);
if (entry->opcode == NULL)
as_fatal (_("Virtual memory exhausted"));
@@ -2928,8 +2927,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
arelent *reloc;
bfd_reloc_code_real_type code;
- reloc = (arelent *) xmalloc (sizeof (* reloc));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
@@ -4460,7 +4459,7 @@ arc_extcorereg (int opertype)
break;
case EXT_AUX_REGISTER:
/* Auxiliary register. */
- auxr = xmalloc (sizeof (struct arc_aux_reg));
+ auxr = XNEW (struct arc_aux_reg);
auxr->name = ereg.name;
auxr->cpu = arc_target;
auxr->subclass = NONE;
@@ -4477,8 +4476,8 @@ arc_extcorereg (int opertype)
ereg.number);
ext_condcode.size ++;
ext_condcode.arc_ext_condcode =
- xrealloc (ext_condcode.arc_ext_condcode,
- (ext_condcode.size + 1) * sizeof (struct arc_flag_operand));
+ XRESIZEVEC (struct arc_flag_operand, ext_condcode.arc_ext_condcode,
+ ext_condcode.size + 1);
if (ext_condcode.arc_ext_condcode == NULL)
as_fatal (_("Virtual memory exhausted"));
diff --git a/gas/config/tc-bfin.c b/gas/config/tc-bfin.c
index 4f9ad7e..18da7ec 100644
--- a/gas/config/tc-bfin.c
+++ b/gas/config/tc-bfin.c
@@ -811,8 +811,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-cr16.c b/gas/config/tc-cr16.c
index 119f130..b7fffa7 100644
--- a/gas/config/tc-cr16.c
+++ b/gas/config/tc-cr16.c
@@ -528,8 +528,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
&& (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)))
return NULL;
- reloc = xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
reloc->addend = fixP->fx_offset;
diff --git a/gas/config/tc-cris.c b/gas/config/tc-cris.c
index 536e6cb..74af4ce 100644
--- a/gas/config/tc-cris.c
+++ b/gas/config/tc-cris.c
@@ -3959,9 +3959,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
return 0;
}
- relP = (arelent *) xmalloc (sizeof (arelent));
+ relP = XNEW (arelent);
gas_assert (relP != 0);
- relP->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ relP->sym_ptr_ptr = XNEW (asymbol *);
*relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
diff --git a/gas/config/tc-crx.c b/gas/config/tc-crx.c
index 7993e72..4b829c2 100644
--- a/gas/config/tc-crx.c
+++ b/gas/config/tc-crx.c
@@ -1765,7 +1765,7 @@ preprocess_reglist (char *param, int *allocated)
while (*paramP++ != '{');
- new_param = (char *)xcalloc (MAX_INST_LEN, sizeof (char));
+ new_param = XCNEWVEC (char, MAX_INST_LEN);
*allocated = 1;
strncpy (new_param, param, paramP - param - 1);
diff --git a/gas/config/tc-d10v.c b/gas/config/tc-d10v.c
index e2a2caa..03b264d 100644
--- a/gas/config/tc-d10v.c
+++ b/gas/config/tc-d10v.c
@@ -1451,8 +1451,8 @@ arelent *
tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
diff --git a/gas/config/tc-frv.c b/gas/config/tc-frv.c
index 61d17a7..8912f44 100644
--- a/gas/config/tc-frv.c
+++ b/gas/config/tc-frv.c
@@ -524,7 +524,7 @@ frv_insert_vliw_insn (bfd_boolean count)
if (current_vliw_chain == NULL)
{
- vliw_chain_entry = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain));
+ vliw_chain_entry = XNEW (struct vliw_chain);
vliw_chain_entry->insn_count = 0;
vliw_chain_entry->insn_list = NULL;
vliw_chain_entry->next = NULL;
@@ -537,7 +537,7 @@ frv_insert_vliw_insn (bfd_boolean count)
previous_vliw_chain->next = vliw_chain_entry;
}
- vliw_insn_list_entry = (struct vliw_insn_list *) xmalloc (sizeof (struct vliw_insn_list));
+ vliw_insn_list_entry = XNEW (struct vliw_insn_list);
vliw_insn_list_entry->type = VLIW_GENERIC_TYPE;
vliw_insn_list_entry->insn = NULL;
vliw_insn_list_entry->sym = NULL;
@@ -678,9 +678,9 @@ frv_tomcat_shuffle (enum vliw_nop_type this_nop_type,
struct vliw_insn_list *prev_insn = NULL;
struct vliw_insn_list *curr_insn = vliw_to_split->insn_list;
- struct vliw_chain *double_nop = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain));
- struct vliw_chain *single_nop = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain));
- struct vliw_chain *second_part = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain));
+ struct vliw_chain *double_nop = XNEW (struct vliw_chain);
+ struct vliw_chain *single_nop = XNEW (struct vliw_chain);
+ struct vliw_chain *second_part = XNEW (struct vliw_chain);
struct vliw_chain *curr_vliw = vliw_chain_top;
struct vliw_chain *prev_vliw = NULL;
diff --git a/gas/config/tc-h8300.c b/gas/config/tc-h8300.c
index 5100f0d..048d31e 100644
--- a/gas/config/tc-h8300.c
+++ b/gas/config/tc-h8300.c
@@ -252,8 +252,7 @@ md_begin (void)
nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode);
- h8_instructions = (struct h8_instruction *)
- xmalloc (nopcodes * sizeof (struct h8_instruction));
+ h8_instructions = XNEWVEC (struct h8_instruction, nopcodes);
pi = h8_instructions;
p1 = h8_opcodes;
@@ -273,7 +272,7 @@ md_begin (void)
break;
/* Strip off any . part when inserting the opcode and only enter
unique codes into the hash table. */
- dst = buffer = malloc (strlen (src) + 1);
+ dst = buffer = XNEWVEC (char, strlen (src) + 1);
while (*src)
{
if (*src == '.')
diff --git a/gas/config/tc-i370.c b/gas/config/tc-i370.c
index 7e2f146..ac8aa95 100644
--- a/gas/config/tc-i370.c
+++ b/gas/config/tc-i370.c
@@ -1867,7 +1867,7 @@ i370_macro (char *str, const struct i370_macro *macro)
}
/* Put the string together. */
- complete = s = xmalloc (len + 1);
+ complete = s = XNEWVEC (char, len + 1);
format = macro->format;
while (*format != '\0')
{
@@ -2603,9 +2603,9 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index f382a73..04e91a4 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -2511,7 +2511,7 @@ md_begin (void)
/* Setup for loop. */
optab = i386_optab;
- core_optab = (templates *) xmalloc (sizeof (templates));
+ core_optab = XNEW (templates);
core_optab->start = optab;
while (1)
@@ -2534,7 +2534,7 @@ md_begin (void)
}
if (optab->name == NULL)
break;
- core_optab = (templates *) xmalloc (sizeof (templates));
+ core_optab = XNEW (templates);
core_optab->start = optab;
}
}
@@ -7605,7 +7605,7 @@ lex_got (enum bfd_reloc_code_real *rel,
/* Allocate and copy string. The trailing NUL shouldn't
be necessary, but be safe. */
- tmpbuf = (char *) xmalloc (first + second + 2);
+ tmpbuf = XNEWVEC (char, first + second + 2);
memcpy (tmpbuf, input_line_pointer, first);
if (second != 0 && *past_reloc != ' ')
/* Replace the relocation token with ' ', so that
@@ -7713,7 +7713,7 @@ lex_got (enum bfd_reloc_code_real *rel ATTRIBUTE_UNUSED,
/* Allocate and copy string. The trailing NUL shouldn't
be necessary, but be safe. */
- tmpbuf = (char *) xmalloc (first + second + 2);
+ tmpbuf = XNEWVEC (char, first + second + 2);
memcpy (tmpbuf, input_line_pointer, first);
if (second != 0 && *past_reloc != ' ')
/* Replace the relocation token with ' ', so that
@@ -9795,7 +9795,7 @@ md_parse_option (int c, const char *arg)
char *n, *t;
const char *s;
- n = (char *) xmalloc (strlen (i386_comment_chars) + 1);
+ n = XNEWVEC (char, strlen (i386_comment_chars) + 1);
t = n;
for (s = i386_comment_chars; *s != '\0'; s++)
if (*s != '/')
@@ -10601,8 +10601,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
code = BFD_RELOC_X86_64_GOTPC64;
}
- rel = (arelent *) xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index 2d10e8a..4f1f83c 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -1741,7 +1741,7 @@ static unw_rec_list *
alloc_record (unw_record_type t)
{
unw_rec_list *ptr;
- ptr = xmalloc (sizeof (*ptr));
+ ptr = XNEW (unw_rec_list);
memset (ptr, 0, sizeof (*ptr));
ptr->slot_number = SLOT_NUM_NOT_SET;
ptr->r.type = t;
@@ -2650,8 +2650,7 @@ set_imask (unw_rec_list *region,
if (!imask)
{
imask_size = (region->r.record.r.rlen * 2 + 7) / 8 + 1;
- imask = xmalloc (imask_size);
- memset (imask, 0, imask_size);
+ imask = XCNEWVEC (unsigned char, imask_size);
region->r.record.r.imask_size = imask_size;
region->r.record.r.mask.i = imask;
@@ -4110,7 +4109,7 @@ save_prologue_count (unsigned long lbl, unsigned int count)
lpc->prologue_count = count;
else
{
- label_prologue_count *new_lpc = xmalloc (sizeof (* new_lpc));
+ label_prologue_count *new_lpc = XNEW (label_prologue_count);
new_lpc->next = unwind.saved_prologue_counts;
new_lpc->label_number = lbl;
@@ -4262,7 +4261,7 @@ dot_proc (int dummy ATTRIBUTE_UNUSED)
}
else
{
- pending = xmalloc (sizeof (*pending));
+ pending = XNEW (proc_pending);
pending->sym = sym;
last_pending = last_pending->next = pending;
}
@@ -4484,8 +4483,7 @@ dot_endp (int dummy ATTRIBUTE_UNUSED)
S_SET_SIZE (sym, frag_now_fix () - S_GET_VALUE (sym));
else
{
- symbol_get_obj (sym)->size =
- (expressionS *) xmalloc (sizeof (expressionS));
+ symbol_get_obj (sym)->size = XNEW (expressionS);
symbol_get_obj (sym)->size->X_op = O_subtract;
symbol_get_obj (sym)->size->X_add_symbol
= symbol_new (FAKE_LABEL_NAME, now_seg,
@@ -7789,9 +7787,8 @@ ia64_frob_label (struct symbol *sym)
if (md.path == md.maxpaths)
{
md.maxpaths += 20;
- md.entry_labels = (const char **)
- xrealloc ((void *) md.entry_labels,
- md.maxpaths * sizeof (char *));
+ md.entry_labels = XRESIZEVEC (const char *, md.entry_labels,
+ md.maxpaths);
}
md.entry_labels[md.path++] = S_GET_NAME (sym);
}
@@ -9732,9 +9729,7 @@ add_qp_imply (int p1, int p2)
if (qp_implieslen == qp_impliestotlen)
{
qp_impliestotlen += 20;
- qp_implies = (struct qp_imply *)
- xrealloc ((void *) qp_implies,
- qp_impliestotlen * sizeof (struct qp_imply));
+ qp_implies = XRESIZEVEC (struct qp_imply, qp_implies, qp_impliestotlen);
}
if (md.debug_dv)
fprintf (stderr, " Registering PR%d implies PR%d\n", p1, p2);
@@ -9777,9 +9772,7 @@ add_qp_mutex (valueT mask)
if (qp_mutexeslen == qp_mutexestotlen)
{
qp_mutexestotlen += 20;
- qp_mutexes = (struct qpmutex *)
- xrealloc ((void *) qp_mutexes,
- qp_mutexestotlen * sizeof (struct qpmutex));
+ qp_mutexes = XRESIZEVEC (struct qpmutex, qp_mutexes, qp_mutexestotlen);
}
if (md.debug_dv)
{
@@ -10193,9 +10186,7 @@ mark_resource (struct ia64_opcode *idesc ATTRIBUTE_UNUSED,
if (regdepslen == regdepstotlen)
{
regdepstotlen += 20;
- regdeps = (struct rsrc *)
- xrealloc ((void *) regdeps,
- regdepstotlen * sizeof (struct rsrc));
+ regdeps = XRESIZEVEC (struct rsrc, regdeps, regdepstotlen);
}
regdeps[regdepslen] = *spec;
@@ -11837,7 +11828,7 @@ dot_alias (int section)
goto out;
}
- h = (struct alias *) xmalloc (sizeof (struct alias));
+ h = XNEW (struct alias);
h->file = as_where (&h->line);
h->name = name;
diff --git a/gas/config/tc-m68hc11.c b/gas/config/tc-m68hc11.c
index c61bded..35aa491 100644
--- a/gas/config/tc-m68hc11.c
+++ b/gas/config/tc-m68hc11.c
@@ -613,9 +613,7 @@ md_begin (void)
m68hc11_hash = hash_new ();
/* Get a writable copy of the opcode table and sort it on the names. */
- opcodes = (struct m68hc11_opcode *) xmalloc (m68hc11_num_opcodes *
- sizeof (struct
- m68hc11_opcode));
+ opcodes = XNEWVEC (struct m68hc11_opcode, m68hc11_num_opcodes);
m68hc11_sorted_opcodes = opcodes;
num_opcodes = 0;
for (i = 0; i < m68hc11_num_opcodes; i++)
@@ -644,8 +642,7 @@ md_begin (void)
qsort (opcodes, num_opcodes, sizeof (struct m68hc11_opcode),
(int (*) (const void*, const void*)) cmp_opcode);
- opc = (struct m68hc11_opcode_def *)
- xmalloc (num_opcodes * sizeof (struct m68hc11_opcode_def));
+ opc = XNEWVEC (struct m68hc11_opcode_def, num_opcodes);
m68hc11_opcode_defs = opc--;
/* Insert unique names into hash table. The M6811 instruction set
@@ -3831,8 +3828,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
if (fixp->fx_r_type == 0)
diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
index 50e910b..4d2c0e4 100644
--- a/gas/config/tc-m68k.c
+++ b/gas/config/tc-m68k.c
@@ -1334,8 +1334,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
#undef F
#undef MAP
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
#ifndef OBJ_ELF
@@ -4786,7 +4786,7 @@ m68k_frob_label (symbolS *sym)
{
struct label_line *n;
- n = (struct label_line *) xmalloc (sizeof *n);
+ n = XNEW (struct label_line);
n->next = labels;
n->label = sym;
n->file = as_where (&n->line);
@@ -6102,7 +6102,7 @@ s_save (int ignore ATTRIBUTE_UNUSED)
{
struct save_opts *s;
- s = (struct save_opts *) xmalloc (sizeof (struct save_opts));
+ s = XNEW (struct save_opts);
s->abspcadd = m68k_abspcadd;
s->symbols_case_sensitive = symbols_case_sensitive;
s->keep_locals = flag_keep_locals;
@@ -6222,7 +6222,7 @@ mri_control_label (void)
{
char *n;
- n = (char *) xmalloc (20);
+ n = XNEWVEC (char, 20);
sprintf (n, "%smc%d", FAKE_LABEL_NAME, mri_control_index);
++mri_control_index;
return n;
@@ -6235,7 +6235,7 @@ push_mri_control (enum mri_control_type type)
{
struct mri_control_info *n;
- n = (struct mri_control_info *) xmalloc (sizeof (struct mri_control_info));
+ n = XNEW (struct mri_control_info);
n->type = type;
n->else_seen = 0;
@@ -6514,9 +6514,9 @@ build_mri_control_operand (int qual, int cc, char *leftstart, char *leftstop,
if (leftstart != NULL)
{
- buf = (char *) xmalloc (20
- + (leftstop - leftstart)
- + (rightstop - rightstart));
+ buf = XNEWVEC (char, (20
+ + (leftstop - leftstart)
+ + (rightstop - rightstart)));
s = buf;
*s++ = 'c';
*s++ = 'm';
@@ -6534,7 +6534,7 @@ build_mri_control_operand (int qual, int cc, char *leftstart, char *leftstop,
free (buf);
}
- buf = (char *) xmalloc (20 + strlen (truelab));
+ buf = XNEWVEC (char, 20 + strlen (truelab));
s = buf;
*s++ = 'b';
*s++ = cc >> 8;
@@ -6783,7 +6783,7 @@ s_mri_else (int qual)
mri_control_stack->else_seen = 1;
- buf = (char *) xmalloc (20 + strlen (mri_control_stack->bottom));
+ buf = XNEWVEC (char, 20 + strlen (mri_control_stack->bottom));
q[0] = TOLOWER (qual);
q[1] = '\0';
sprintf (buf, "bra%s %s", q, mri_control_stack->bottom);
@@ -6854,7 +6854,7 @@ s_mri_break (int extent)
return;
}
- buf = (char *) xmalloc (20 + strlen (n->bottom));
+ buf = XNEWVEC (char, 20 + strlen (n->bottom));
ex[0] = TOLOWER (extent);
ex[1] = '\0';
sprintf (buf, "bra%s %s", ex, n->bottom);
@@ -6892,7 +6892,7 @@ s_mri_next (int extent)
return;
}
- buf = (char *) xmalloc (20 + strlen (n->next));
+ buf = XNEWVEC (char, 20 + strlen (n->next));
ex[0] = TOLOWER (extent);
ex[1] = '\0';
sprintf (buf, "bra%s %s", ex, n->next);
@@ -7066,7 +7066,7 @@ s_mri_for (int qual)
/* We have fully parsed the FOR operands. Now build the loop. */
n = push_mri_control (mri_for);
- buf = (char *) xmalloc (50 + (input_line_pointer - varstart));
+ buf = XNEWVEC (char, 50 + (input_line_pointer - varstart));
/* Move init,var. */
s = buf;
@@ -7300,7 +7300,7 @@ s_mri_endw (int ignore ATTRIBUTE_UNUSED)
return;
}
- buf = (char *) xmalloc (20 + strlen (mri_control_stack->next));
+ buf = XNEWVEC (char, 20 + strlen (mri_control_stack->next));
sprintf (buf, "bra %s", mri_control_stack->next);
mri_assemble (buf);
free (buf);
@@ -7581,7 +7581,7 @@ md_parse_option (int c, const char *arg)
char *n, *t;
const char *s;
- n = (char *) xmalloc (strlen (m68k_comment_chars) + 1);
+ n = XNEWVEC (char, strlen (m68k_comment_chars) + 1);
t = n;
for (s = m68k_comment_chars; *s != '\0'; s++)
if (*s != '|')
diff --git a/gas/config/tc-metag.c b/gas/config/tc-metag.c
index cc9140b..d5922d6 100644
--- a/gas/config/tc-metag.c
+++ b/gas/config/tc-metag.c
@@ -6331,7 +6331,7 @@ create_mnemonic_htab (void)
insn_templates **slot = NULL;
insn_templates *new_entry;
- new_entry = xmalloc (sizeof (insn_templates));
+ new_entry = XNEW (insn_templates);
new_entry->template = template;
new_entry->next = NULL;
@@ -7008,8 +7008,8 @@ tc_gen_reloc (seg, fixp)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index ceb4365..b4985f0 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -2432,8 +2432,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
break;
}
- rel = (arelent *) xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
if (code == BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM)
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
diff --git a/gas/config/tc-mmix.c b/gas/config/tc-mmix.c
index d3d971d..24362ad7 100644
--- a/gas/config/tc-mmix.c
+++ b/gas/config/tc-mmix.c
@@ -2874,9 +2874,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
return NULL;
}
- relP = (arelent *) xmalloc (sizeof (arelent));
+ relP = XNEW (arelent);
gas_assert (relP != 0);
- relP->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ relP->sym_ptr_ptr = XNEW (asymbol *);
*relP->sym_ptr_ptr = baddsy;
relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
@@ -4089,8 +4089,7 @@ s_loc (int ignore ATTRIBUTE_UNUSED)
if (section == undefined_section)
{
struct loc_assert_s *next = loc_asserts;
- loc_asserts
- = (struct loc_assert_s *) xmalloc (sizeof (*loc_asserts));
+ loc_asserts = XNEW (struct loc_assert_s);
loc_asserts->next = next;
loc_asserts->old_seg = now_seg;
loc_asserts->loc_sym = esym;
diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c
index 4e65616..888e8aa 100644
--- a/gas/config/tc-nds32.c
+++ b/gas/config/tc-nds32.c
@@ -3709,14 +3709,14 @@ nds32_relax_hint (int mode ATTRIBUTE_UNUSED)
relocs = hash_find (nds32_hint_hash, name);
if (relocs == NULL)
{
- relocs = malloc (sizeof (struct nds32_relocs_pattern));
+ relocs = XNEW (struct nds32_relocs_pattern);
hash_insert (nds32_hint_hash, name, relocs);
}
else
{
while (relocs->next)
relocs=relocs->next;
- relocs->next = malloc (sizeof (struct nds32_relocs_pattern));
+ relocs->next = XNEW (struct nds32_relocs_pattern);
relocs = relocs->next;
}
@@ -3729,7 +3729,7 @@ nds32_relax_hint (int mode ATTRIBUTE_UNUSED)
/* It has to build this list because there are maybe more than one
instructions relative to the same instruction. It to connect to
next instruction after md_assemble. */
- new = malloc (sizeof (struct nds32_relocs_group));
+ new = XNEW (struct nds32_relocs_group);
new->pattern = relocs;
new->next = NULL;
group = nds32_relax_hint_current;
@@ -6602,9 +6602,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
arelent *reloc;
bfd_reloc_code_real_type code;
- reloc = (arelent *) xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index 1677d1d..954971b 100644
--- a/gas/config/tc-nios2.c
+++ b/gas/config/tc-nios2.c
@@ -1482,7 +1482,7 @@ static nios2_insn_relocS *
nios2_insn_reloc_new (bfd_reloc_code_real_type reloc_type, unsigned int pcrel)
{
nios2_insn_relocS *retval;
- retval = (nios2_insn_relocS *) malloc (sizeof (nios2_insn_relocS));
+ retval = XNEW (nios2_insn_relocS);
if (retval == NULL)
{
as_bad (_("can't create relocation"));
@@ -3854,8 +3854,8 @@ nios2_frob_symbol (symbolS *symp)
arelent *
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
{
- arelent *reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ arelent *reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-rl78.c b/gas/config/tc-rl78.c
index 0739d34..5fc0134 100644
--- a/gas/config/tc-rl78.c
+++ b/gas/config/tc-rl78.c
@@ -1271,8 +1271,8 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
fixp->fx_subsy = NULL;
}
- reloc[0] = (arelent *) xmalloc (sizeof (arelent));
- reloc[0]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc[0] = XNEW (arelent);
+ reloc[0]->sym_ptr_ptr = XNEW (asymbol *);
* reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc[0]->addend = fixp->fx_offset;
@@ -1284,8 +1284,8 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
}
#define OPX(REL,SYM,ADD) \
- reloc[rp] = (arelent *) xmalloc (sizeof (arelent)); \
- reloc[rp]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); \
+ reloc[rp] = XNEW (arelent); \
+ reloc[rp]->sym_ptr_ptr = XNEW (asymbol *); \
reloc[rp]->howto = bfd_reloc_type_lookup (stdoutput, REL); \
reloc[rp]->addend = ADD; \
* reloc[rp]->sym_ptr_ptr = SYM; \
diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c
index dced3ce..9f3014d 100644
--- a/gas/config/tc-rx.c
+++ b/gas/config/tc-rx.c
@@ -301,7 +301,7 @@ rx_include (int ignore)
}
current_filename = as_where (NULL);
- f = (char *) xmalloc (strlen (current_filename) + strlen (filename) + 1);
+ f = XNEWVEC (char, strlen (current_filename) + strlen (filename) + 1);
/* Check the filename. If [@]..FILE[@] is found then replace
this with the current assembler source filename, stripped
@@ -359,7 +359,7 @@ rx_include (int ignore)
if (env && strlen (env) > len)
len = strlen (env);
- path = (char *) xmalloc (strlen (f) + len + 5);
+ path = XNEWVEC (char, strlen (f) + len + 5);
if (current_filename != NULL)
{
diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index 3390a40..b15acf8 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -4424,8 +4424,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
arelent *rel;
bfd_reloc_code_real_type r_type;
- rel = (arelent *) xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-sh64.c b/gas/config/tc-sh64.c
index ec08173..294f96b 100644
--- a/gas/config/tc-sh64.c
+++ b/gas/config/tc-sh64.c
@@ -439,7 +439,7 @@ shmedia_frob_section_type (asection *sec)
sec_elf_data = sh64_elf_section_data (sec)->sh64_info;
if (sec_elf_data == NULL)
{
- sec_elf_data = xcalloc (1, sizeof (*sec_elf_data));
+ sec_elf_data = XCNEW (struct sh64_section_data);
sh64_elf_section_data (sec)->sh64_info = sec_elf_data;
}
diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c
index a51ca1f..0ee8862 100644
--- a/gas/config/tc-sparc.c
+++ b/gas/config/tc-sparc.c
@@ -3685,10 +3685,10 @@ tc_gen_reloc (asection *section, fixS *fixp)
arelent *reloc;
bfd_reloc_code_real_type code;
- relocs[0] = reloc = (arelent *) xmalloc (sizeof (arelent));
+ relocs[0] = reloc = XNEW (arelent);
relocs[1] = NULL;
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
@@ -3893,10 +3893,10 @@ tc_gen_reloc (asection *section, fixS *fixp)
on the same location. */
if (code == BFD_RELOC_SPARC_OLO10)
{
- relocs[1] = reloc = (arelent *) xmalloc (sizeof (arelent));
+ relocs[1] = reloc = XNEW (arelent);
relocs[2] = NULL;
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr
= symbol_get_bfdsym (section_symbol (absolute_section));
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-spu.c b/gas/config/tc-spu.c
index 13e5e2d..c08dcb5 100644
--- a/gas/config/tc-spu.c
+++ b/gas/config/tc-spu.c
@@ -863,8 +863,8 @@ arelent *
tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
if (fixp->fx_addsy)
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
else if (fixp->fx_subsy)
diff --git a/gas/config/tc-tic6x.c b/gas/config/tc-tic6x.c
index ebeafc3..a35ec2a 100644
--- a/gas/config/tc-tic6x.c
+++ b/gas/config/tc-tic6x.c
@@ -201,7 +201,7 @@ static tic6x_unwind_info *tic6x_get_unwind (void)
if (unwind)
return unwind;
- unwind = (tic6x_unwind_info *)xmalloc (sizeof (tic6x_unwind_info));
+ unwind =XNEW (tic6x_unwind_info);
seg_info (now_seg)->tc_segment_info_data.unwind = unwind;
memset (unwind, 0, sizeof (*unwind));
return unwind;
@@ -4642,7 +4642,7 @@ tic6x_start_unwind_section (const segT text_seg, int idx)
prefix_len = strlen (prefix);
text_len = strlen (text_name);
sec_name_len = prefix_len + text_len;
- sec_name = (char *) xmalloc (sec_name_len + 1);
+ sec_name = XNEWVEC (char, sec_name_len + 1);
memcpy (sec_name, prefix, prefix_len);
memcpy (sec_name + prefix_len, text_name, text_len);
sec_name[prefix_len + text_len] = '\0';
diff --git a/gas/config/tc-tilegx.c b/gas/config/tc-tilegx.c
index bd42939..aca7f56 100644
--- a/gas/config/tc-tilegx.c
+++ b/gas/config/tc-tilegx.c
@@ -1735,8 +1735,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-tilepro.c b/gas/config/tc-tilepro.c
index a11b05f..061a41a 100644
--- a/gas/config/tc-tilepro.c
+++ b/gas/config/tc-tilepro.c
@@ -1515,8 +1515,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-v850.c b/gas/config/tc-v850.c
index 5b425a9..929c87d 100644
--- a/gas/config/tc-v850.c
+++ b/gas/config/tc-v850.c
@@ -3337,8 +3337,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-visium.c b/gas/config/tc-visium.c
index c618524..7f00cbf 100644
--- a/gas/config/tc-visium.c
+++ b/gas/config/tc-visium.c
@@ -112,9 +112,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
arelent *reloc;
bfd_reloc_code_real_type code;
- reloc = (arelent *) xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-xgate.c b/gas/config/tc-xgate.c
index 1d68edc..769d158 100644
--- a/gas/config/tc-xgate.c
+++ b/gas/config/tc-xgate.c
@@ -298,8 +298,7 @@ md_begin (void)
/* Create a local copy of our opcode table
including an extra line for NULL termination. */
- xgate_op_table = (struct xgate_opcode *)
- xmalloc ((xgate_num_opcodes) * sizeof (struct xgate_opcode));
+ xgate_op_table = XNEWVEC (struct xgate_opcode, xgate_num_opcodes);
memset (xgate_op_table, 0,
sizeof(struct xgate_opcode) * (xgate_num_opcodes));
@@ -322,8 +321,7 @@ md_begin (void)
prev_op_name = xgate_opcode_ptr->name;
}
- op_handles = (struct xgate_opcode_handle *)
- xmalloc (sizeof(struct xgate_opcode_handle) * (number_of_op_handles));
+ op_handles = XNEWVEC (struct xgate_opcode_handle, number_of_op_handles);
/* Insert unique opcode names into hash table, aliasing duplicates. */
xgate_hash = hash_new ();
@@ -616,8 +614,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
{
arelent * reloc;
- reloc = (arelent *) xmalloc (sizeof(arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof(asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 22181dc..ff1c9aa 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -2424,7 +2424,7 @@ xtensa_translate_old_userreg_ops (char **popname)
/* Translate the opcode. */
sr_name = xtensa_sysreg_name (isa, sr);
- new_opname = (char *) xmalloc (strlen (sr_name) + 6);
+ new_opname = XNEWVEC (char, strlen (sr_name) + 6);
sprintf (new_opname, "%s%cur.%s", (has_underbar ? "_" : ""),
opname[0], sr_name);
free (*popname);
@@ -6147,9 +6147,9 @@ new_resource_table (void *data,
rt->opcode_unit_use = ouuf;
rt->opcode_unit_stage = ousf;
- rt->units = (unsigned char **) xcalloc (cycles, sizeof (unsigned char *));
+ rt->units = XCNEWVEC (unsigned char *, cycles);
for (i = 0; i < cycles; i++)
- rt->units[i] = (unsigned char *) xcalloc (nu, sizeof (unsigned char));
+ rt->units[i] = XCNEWVEC (unsigned char, nu);
return rt;
}
@@ -6183,7 +6183,7 @@ resize_resource_table (resource_table *rt, int cycles)
for (i = 0; i < old_cycles; i++)
rt->units[i] = XRESIZEVEC (unsigned char, rt->units[i], rt->num_units);
for (i = old_cycles; i < cycles; i++)
- rt->units[i] = xcalloc (rt->num_units, sizeof (unsigned char));
+ rt->units[i] = XCNEWVEC (unsigned char, rt->num_units);
}
@@ -7434,7 +7434,7 @@ xtensa_create_trampoline_frag (bfd_boolean needs_jump_around)
if (ts == NULL)
{
- ts = (struct trampoline_seg *)xcalloc(sizeof (struct trampoline_seg), 1);
+ ts = XCNEW(struct trampoline_seg);
ts->next = trampoline_seg_list.next;
trampoline_seg_list.next = ts;
ts->seg = now_seg;
@@ -7549,7 +7549,7 @@ xtensa_maybe_create_literal_pool_frag (bfd_boolean create,
if (lps == NULL)
{
- lps = (struct litpool_seg *)xcalloc (sizeof (struct litpool_seg), 1);
+ lps = XCNEW (struct litpool_seg);
lps->next = litpool_seg_list.next;
litpool_seg_list.next = lps;
lps->seg = now_seg;
@@ -11564,7 +11564,7 @@ cache_literal_section (bfd_boolean use_abs_literals)
|| strncmp (text_name, ".text", 5) == 0))
len -= 5;
- name = xmalloc (len + strlen (base_name) + 1);
+ name = XNEWVEC (char, len + strlen (base_name) + 1);
if (strncmp (text_name, ".text", 5) == 0)
{
strcpy (name, base_name);
diff --git a/gas/config/xtensa-relax.c b/gas/config/xtensa-relax.c
index ac616a1..13fee15 100644
--- a/gas/config/xtensa-relax.c
+++ b/gas/config/xtensa-relax.c
@@ -522,7 +522,7 @@ append_transition (TransitionTable *tt,
TransitionRule *t,
transition_cmp_fn cmp)
{
- TransitionList *tl = (TransitionList *) xmalloc (sizeof (TransitionList));
+ TransitionList *tl = XNEW (TransitionList);
TransitionList *prev;
TransitionList **t_p;
gas_assert (tt != NULL);
@@ -554,8 +554,7 @@ append_transition (TransitionTable *tt,
static void
append_condition (TransitionRule *tr, Precondition *cond)
{
- PreconditionList *pl =
- (PreconditionList *) xmalloc (sizeof (PreconditionList));
+ PreconditionList *pl = XNEW (PreconditionList);
PreconditionList *prev = tr->conditions;
PreconditionList *nxt;
@@ -582,7 +581,7 @@ append_value_condition (TransitionRule *tr,
unsigned op1,
unsigned op2)
{
- Precondition *cond = (Precondition *) xmalloc (sizeof (Precondition));
+ Precondition *cond = XNEW (Precondition);
cond->cmp = cmp;
cond->op_num = op1;
@@ -598,7 +597,7 @@ append_constant_value_condition (TransitionRule *tr,
unsigned op1,
unsigned cnst)
{
- Precondition *cond = (Precondition *) xmalloc (sizeof (Precondition));
+ Precondition *cond = XNEW (Precondition);
cond->cmp = cmp;
cond->op_num = op1;
@@ -654,7 +653,7 @@ append_op (BuildInstr *bi, BuildOp *b_op)
static void
append_literal_op (BuildInstr *bi, unsigned op1, unsigned src_op)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = OP_LITERAL;
@@ -667,7 +666,7 @@ append_literal_op (BuildInstr *bi, unsigned op1, unsigned src_op)
static void
append_label_op (BuildInstr *bi, unsigned op1)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = OP_LABEL;
@@ -680,7 +679,7 @@ append_label_op (BuildInstr *bi, unsigned op1)
static void
append_constant_op (BuildInstr *bi, unsigned op1, unsigned cnst)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = OP_CONSTANT;
@@ -693,7 +692,7 @@ append_constant_op (BuildInstr *bi, unsigned op1, unsigned cnst)
static void
append_field_op (BuildInstr *bi, unsigned op1, unsigned src_op)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = OP_OPERAND;
@@ -711,7 +710,7 @@ append_user_fn_field_op (BuildInstr *bi,
OpType typ,
unsigned src_op)
{
- BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp));
+ BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1;
b_op->typ = typ;
@@ -819,7 +818,7 @@ enter_opname_n (const char *name, int len)
&& strncmp (op->opname, name, len) == 0)
return op->opname;
}
- op = (opname_e *) xmalloc (sizeof (opname_e));
+ op = XNEW (opname_e);
op->opname = xstrndup (name, len);
return op->opname;
}
@@ -835,7 +834,7 @@ enter_opname (const char *name)
if (strcmp (op->opname, name) == 0)
return op->opname;
}
- op = (opname_e *) xmalloc (sizeof (opname_e));
+ op = XNEW (opname_e);
op->opname = xstrdup (name);
return op->opname;
}
@@ -1105,7 +1104,7 @@ split_string (split_rec *rec,
if (rec->count == 0)
return;
- rec->vec = (char **) xmalloc (sizeof (char *) * cnt);
+ rec->vec = XNEWVEC (char *, cnt);
for (i = 0; i < cnt; i++)
rec->vec[i] = 0;
@@ -1189,7 +1188,7 @@ parse_insn_templ (const char *s, insn_templ *t)
for (i = 0; i < oprec.count; i++)
{
const char *opname = oprec.vec[i];
- opname_map_e *e = (opname_map_e *) xmalloc (sizeof (opname_map_e));
+ opname_map_e *e = XNEW (opname_map_e);
e->next = NULL;
e->operand_name = NULL;
e->constant_value = 0;
@@ -1307,7 +1306,7 @@ clone_req_or_option_list (ReqOrOption *req_or_option)
if (req_or_option == NULL)
return NULL;
- new_req_or_option = (ReqOrOption *) xmalloc (sizeof (ReqOrOption));
+ new_req_or_option = XNEW (ReqOrOption);
new_req_or_option->option_name = xstrdup (req_or_option->option_name);
new_req_or_option->is_true = req_or_option->is_true;
new_req_or_option->next = NULL;
@@ -1324,7 +1323,7 @@ clone_req_option_list (ReqOption *req_option)
if (req_option == NULL)
return NULL;
- new_req_option = (ReqOption *) xmalloc (sizeof (ReqOption));
+ new_req_option = XNEW (ReqOption);
new_req_option->or_option_terms = NULL;
new_req_option->next = NULL;
new_req_option->or_option_terms =
@@ -1368,7 +1367,7 @@ parse_option_cond (const char *s, ReqOption *option)
else
option_name = xstrdup (option_name);
- req = (ReqOrOption *) xmalloc (sizeof (ReqOrOption));
+ req = XNEW (ReqOrOption);
req->option_name = option_name;
req->is_true = is_true;
req->next = NULL;
@@ -1436,7 +1435,7 @@ parse_insn_pattern (const char *in, insn_pattern *insn)
for (i = 1; i < rec.count; i++)
{
- precond_e *cond = (precond_e *) xmalloc (sizeof (precond_e));
+ precond_e *cond = XNEW (precond_e);
if (!parse_precond (rec.vec[i], cond))
{
@@ -1455,7 +1454,7 @@ parse_insn_pattern (const char *in, insn_pattern *insn)
{
/* Handle the option conditions. */
ReqOption **r_p;
- ReqOption *req_option = (ReqOption *) xmalloc (sizeof (ReqOption));
+ ReqOption *req_option = XNEW (ReqOption);
req_option->or_option_terms = NULL;
req_option->next = NULL;
@@ -1492,7 +1491,7 @@ parse_insn_repl (const char *in, insn_repl *r_p)
for (i = 0; i < rec.count; i++)
{
- insn_repl_e *e = (insn_repl_e *) xmalloc (sizeof (insn_repl_e));
+ insn_repl_e *e = XNEW (insn_repl_e);
e->next = NULL;
@@ -1628,7 +1627,7 @@ build_transition (insn_pattern *initial_insn,
return NULL;
}
- tr = (TransitionRule *) xmalloc (sizeof (TransitionRule));
+ tr = XNEW (TransitionRule);
tr->opcode = opcode;
tr->conditions = NULL;
tr->to_instr = NULL;
@@ -1723,7 +1722,7 @@ build_transition (insn_pattern *initial_insn,
const char *fn_name;
const char *operand_arg_name;
- bi = (BuildInstr *) xmalloc (sizeof (BuildInstr));
+ bi = XNEW (BuildInstr);
append_build_insn (tr, bi);
bi->opcode = XTENSA_UNDEFINED;
@@ -1853,10 +1852,9 @@ build_transition_table (const string_pattern_pair *transitions,
return table;
/* Otherwise, build it now. */
- table = (TransitionTable *) xmalloc (sizeof (TransitionTable));
+ table = XNEW (TransitionTable);
table->num_opcodes = num_opcodes;
- table->table =
- (TransitionList **) xmalloc (sizeof (TransitionTable *) * num_opcodes);
+ table->table = XNEWVEC (TransitionList *, num_opcodes);
for (i = 0; i < num_opcodes; i++)
table->table[i] = NULL;
diff --git a/gas/dw2gencfi.c b/gas/dw2gencfi.c
index c66402d..fb3e302 100644
--- a/gas/dw2gencfi.c
+++ b/gas/dw2gencfi.c
@@ -434,11 +434,9 @@ struct frch_cfi_data
static struct fde_entry *
alloc_fde_entry (void)
{
- struct fde_entry *fde = (struct fde_entry *)
- xcalloc (1, sizeof (struct fde_entry));
+ struct fde_entry *fde = XCNEW (struct fde_entry);
- frchain_now->frch_cfi_data = (struct frch_cfi_data *)
- xcalloc (1, sizeof (struct frch_cfi_data));
+ frchain_now->frch_cfi_data = XCNEW (struct frch_cfi_data);
frchain_now->frch_cfi_data->cur_fde_data = fde;
*last_fde_data = fde;
last_fde_data = &fde->next;
@@ -467,8 +465,7 @@ static struct fde_entry *last_fde;
static struct cfi_insn_data *
alloc_cfi_insn_data (void)
{
- struct cfi_insn_data *insn = (struct cfi_insn_data *)
- xcalloc (1, sizeof (struct cfi_insn_data));
+ struct cfi_insn_data *insn = XCNEW (struct cfi_insn_data);
struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data;
*cur_fde_data->last = insn;
@@ -662,7 +659,7 @@ cfi_add_CFA_remember_state (void)
cfi_add_CFA_insn (DW_CFA_remember_state);
- p = (struct cfa_save_data *) xmalloc (sizeof (*p));
+ p = XNEW (struct cfa_save_data);
p->cfa_offset = frchain_now->frch_cfi_data->cur_cfa_offset;
p->next = frchain_now->frch_cfi_data->cfa_save_stack;
frchain_now->frch_cfi_data->cfa_save_stack = p;
@@ -947,7 +944,7 @@ dot_cfi_escape (int ignored ATTRIBUTE_UNUSED)
tail = &head;
do
{
- e = (struct cfi_escape_data *) xmalloc (sizeof (*e));
+ e = XNEW (struct cfi_escape_data);
do_parse_cons_expression (&e->exp, 1);
*tail = e;
tail = &e->next;
@@ -1387,7 +1384,7 @@ dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED)
num_ops = 0;
do
{
- e = (struct cfi_escape_data *) xmalloc (sizeof (*e));
+ e = XNEW (struct cfi_escape_data);
do_parse_cons_expression (&e->exp, 1);
*tail = e;
tail = &e->next;
@@ -1409,7 +1406,7 @@ dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED)
num_ops = 3;
last_fde->eh_data_size = num_ops;
- last_fde->eh_data = (bfd_byte *) xmalloc (num_ops);
+ last_fde->eh_data = XNEWVEC (bfd_byte, num_ops);
num_ops = 0;
while (head)
{
@@ -2093,7 +2090,7 @@ select_cie_for_fde (struct fde_entry *fde, bfd_boolean eh_frame,
fail:;
}
- cie = (struct cie_entry *) xmalloc (sizeof (struct cie_entry));
+ cie = XNEW (struct cie_entry);
cie->next = cie_root;
cie_root = cie;
SET_CUR_SEG (cie, CUR_SEG (fde));
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 3cee7d6..82f247c 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -639,7 +639,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
{
size_t dir_len = strlen (dirs[files[filenum].dir]);
size_t file_len = strlen (files[filenum].filename);
- char *cp = (char *) xmalloc (dir_len + 1 + file_len + 1);
+ char *cp = XNEWVEC (char, dir_len + 1 + file_len + 1);
memcpy (cp, dirs[files[filenum].dir], dir_len);
INSERT_DIR_SEPARATOR (cp, dir_len);
diff --git a/gas/ecoff.c b/gas/ecoff.c
index e7d7ab6..a5fc62c 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -3610,7 +3610,7 @@ ecoff_add_bytes (char **buf,
if (need < PAGE_SIZE)
need = PAGE_SIZE;
want = (*bufend - *buf) + need;
- *buf = (char *) xrealloc (*buf, want);
+ *buf = XRESIZEVEC (char, *buf, want);
*bufend = *buf + want;
return *buf + at;
}
@@ -4691,7 +4691,7 @@ ecoff_build_debug (HDRR *hdr,
/* Build the symbolic information. */
offset = 0;
- buf = (char *) xmalloc (PAGE_SIZE);
+ buf = XNEWVEC (char, PAGE_SIZE);
bufend = buf + PAGE_SIZE;
/* Build the line number information. */
diff --git a/gas/input-scrub.c b/gas/input-scrub.c
index 4bbb38f..1de5e03 100644
--- a/gas/input-scrub.c
+++ b/gas/input-scrub.c
@@ -139,7 +139,7 @@ input_scrub_push (char *saved_position)
{
struct input_save *saved;
- saved = (struct input_save *) xmalloc (sizeof *saved);
+ saved = XNEW (struct input_save);
saved->saved_position = saved_position;
saved->buffer_start = buffer_start;
@@ -163,8 +163,8 @@ input_scrub_push (char *saved_position)
buffer_length = input_file_buffer_size ();
sb_index = -1;
- buffer_start = (char *) xmalloc ((BEFORE_SIZE + buffer_length
- + buffer_length + AFTER_SIZE + 1));
+ buffer_start = XNEWVEC (char, (BEFORE_SIZE + buffer_length
+ + buffer_length + AFTER_SIZE + 1));
memcpy (buffer_start, BEFORE_STRING, (int) BEFORE_SIZE);
return saved;
@@ -208,8 +208,8 @@ input_scrub_begin (void)
buffer_length = input_file_buffer_size ();
- buffer_start = (char *) xmalloc ((BEFORE_SIZE + buffer_length
- + buffer_length + AFTER_SIZE + 1));
+ buffer_start = XNEWVEC (char, (BEFORE_SIZE + buffer_length
+ + buffer_length + AFTER_SIZE + 1));
memcpy (buffer_start, BEFORE_STRING, (int) BEFORE_SIZE);
/* Line number things. */
@@ -389,10 +389,10 @@ input_scrub_next_buffer (char **bufp)
partial_size = limit - (buffer_start + BEFORE_SIZE);
buffer_length += input_file_buffer_size ();
- buffer_start = (char *) xrealloc (buffer_start,
- (BEFORE_SIZE
- + 2 * buffer_length
- + AFTER_SIZE + 1));
+ buffer_start = XRESIZEVEC (char, buffer_start,
+ (BEFORE_SIZE
+ + 2 * buffer_length
+ + AFTER_SIZE + 1));
}
/* Tell the listing we've finished the file. */
diff --git a/gas/itbl-ops.c b/gas/itbl-ops.c
index 1a4e2bb..488e3be 100644
--- a/gas/itbl-ops.c
+++ b/gas/itbl-ops.c
@@ -299,7 +299,7 @@ append_insns_as_macros (void)
{
struct ITBL_OPCODE_STRUCT *new_opcodes, *o;
struct itbl_entry *e, **es;
- int n, size, new_size, new_num_opcodes;
+ int n, size, new_num_opcodes;
#ifdef USE_MACROS
int id;
#endif
@@ -320,12 +320,9 @@ append_insns_as_macros (void)
ASSERT (size >= 0);
DBG (("I get=%d\n", size / sizeof (ITBL_OPCODES[0])));
- new_size = sizeof (struct ITBL_OPCODE_STRUCT) * new_num_opcodes;
- ASSERT (new_size > size);
-
/* FIXME since ITBL_OPCODES culd be a static table,
we can't realloc or delete the old memory. */
- new_opcodes = (struct ITBL_OPCODE_STRUCT *) malloc (new_size);
+ new_opcodes = XNEWVEC (struct ITBL_OPCODE_STRUCT, new_num_opcodes);
if (!new_opcodes)
{
printf (_("Unable to allocate memory for new instructions\n"));
@@ -853,7 +850,7 @@ alloc_entry (e_processor processor, e_type type,
struct itbl_entry *e, **es;
if (!name)
return 0;
- e = (struct itbl_entry *) malloc (sizeof (struct itbl_entry));
+ e = XNEW (struct itbl_entry);
if (e)
{
memset (e, 0, sizeof (struct itbl_entry));
@@ -875,7 +872,7 @@ alloc_field (e_type type, int sbit, int ebit,
unsigned long flags)
{
struct itbl_field *f;
- f = (struct itbl_field *) malloc (sizeof (struct itbl_field));
+ f = XNEW (struct itbl_field);
if (f)
{
memset (f, 0, sizeof (struct itbl_field));
diff --git a/gas/listing.c b/gas/listing.c
index 07090d7..1e85e91 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -347,7 +347,7 @@ listing_newline (char *ps)
if (strcmp (file, _("{standard input}")) == 0
&& input_line_pointer != NULL)
{
- char *copy;
+ char *copy, *src, *dest;
int len;
int seen_quote = 0;
int seen_slash = 0;
@@ -367,25 +367,22 @@ listing_newline (char *ps)
len = copy - input_line_pointer + 1;
- copy = (char *) xmalloc (len);
+ copy = XNEWVEC (char, len);
- if (copy != NULL)
- {
- char *src = input_line_pointer;
- char *dest = copy;
-
- while (--len)
- {
- unsigned char c = *src++;
+ src = input_line_pointer;
+ dest = copy;
- /* Omit control characters in the listing. */
- if (!ISCNTRL (c))
- *dest++ = c;
- }
+ while (--len)
+ {
+ unsigned char c = *src++;
- *dest = 0;
+ /* Omit control characters in the listing. */
+ if (!ISCNTRL (c))
+ *dest++ = c;
}
+ *dest = 0;
+
new_i->line_contents = copy;
}
else
@@ -1200,8 +1197,8 @@ listing_listing (char *name ATTRIBUTE_UNUSED)
int show_listing = 1;
unsigned int width;
- buffer = (char *) xmalloc (listing_rhs_width);
- data_buffer = (char *) xmalloc (MAX_BYTES);
+ buffer = XNEWVEC (char, listing_rhs_width);
+ data_buffer = XNEWVEC (char, MAX_BYTES);
eject = 1;
list = head->next;
diff --git a/gas/macro.c b/gas/macro.c
index 851454d..2ccf0fc 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -404,7 +404,7 @@ get_any_string (size_t idx, sb *in, sb *out)
}
else
{
- char *br_buf = (char *) xmalloc (1);
+ char *br_buf = XNEWVEC (char, 1);
char *in_br = br_buf;
*in_br = '\0';
@@ -438,7 +438,7 @@ get_any_string (size_t idx, sb *in, sb *out)
--in_br;
else
{
- br_buf = (char *) xmalloc (strlen (in_br) + 2);
+ br_buf = XNEWVEC (char, strlen (in_br) + 2);
strcpy (br_buf + 1, in_br);
free (in_br);
in_br = br_buf;
@@ -1287,7 +1287,7 @@ delete_macro (const char *name)
macro_entry *macro;
len = strlen (name);
- copy = (char *) xmalloc (len + 1);
+ copy = XNEWVEC (char, len + 1);
for (i = 0; i < len; ++i)
copy[i] = TOLOWER (name[i]);
copy[i] = '\0';
diff --git a/gas/stabs.c b/gas/stabs.c
index 10e271f..916594c 100644
--- a/gas/stabs.c
+++ b/gas/stabs.c
@@ -533,7 +533,7 @@ generate_asm_file (int type, const char *file)
/* Allocate enough space for the file name (possibly extended with
doubled up backslashes), the symbol name, and the other characters
that make up a stabs file directive. */
- bufp = buf = (char *) xmalloc (2 * strlen (file) + strlen (sym) + 12);
+ bufp = buf = XNEWVEC (char, 2 * strlen (file) + strlen (sym) + 12);
*bufp++ = '"';
@@ -629,13 +629,13 @@ stabs_generate_asm_lineno (void)
if (in_dot_func_p)
{
- buf = (char *) xmalloc (100 + strlen (current_function_label));
+ buf = XNEWVEC (char, 100 + strlen (current_function_label));
sprintf (buf, "%d,0,%d,%s-%s\n", N_SLINE, lineno,
sym, current_function_label);
}
else
{
- buf = (char *) xmalloc (100);
+ buf = XNEWVEC (char, 100);
sprintf (buf, "%d,0,%d,%s\n", N_SLINE, lineno, sym);
}
input_line_pointer = buf;
diff --git a/gas/subsegs.c b/gas/subsegs.c
index e9c575c..0647653 100644
--- a/gas/subsegs.c
+++ b/gas/subsegs.c
@@ -63,7 +63,7 @@ subseg_change (segT seg, int subseg)
if (! seginfo)
{
- seginfo = (segment_info_type *) xcalloc (1, sizeof (*seginfo));
+ seginfo = XCNEW (segment_info_type);
seginfo->bfd_section = seg;
bfd_set_section_userdata (stdoutput, seg, seginfo);
}
@@ -165,7 +165,7 @@ subseg_get (const char *segname, int force_new)
if (! seginfo)
{
secptr->output_section = secptr;
- seginfo = (segment_info_type *) xcalloc (1, sizeof (*seginfo));
+ seginfo = XCNEW (segment_info_type);
seginfo->bfd_section = secptr;
bfd_set_section_userdata (stdoutput, secptr, seginfo);
}
diff --git a/gas/symbols.c b/gas/symbols.c
index 0d5a854..082b2c7 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -1639,7 +1639,7 @@ define_dollar_label (long label)
{
dollar_labels = XNEWVEC (long, DOLLAR_LABEL_BUMP_BY);
dollar_label_instances = XNEWVEC (long, DOLLAR_LABEL_BUMP_BY);
- dollar_label_defines = (char *) xmalloc (DOLLAR_LABEL_BUMP_BY);
+ dollar_label_defines = XNEWVEC (char, DOLLAR_LABEL_BUMP_BY);
dollar_label_max = DOLLAR_LABEL_BUMP_BY;
dollar_label_count = 0;
}
@@ -1649,7 +1649,8 @@ define_dollar_label (long label)
dollar_labels = XRESIZEVEC (long, dollar_labels, dollar_label_max);
dollar_label_instances = XRESIZEVEC (long, dollar_label_instances,
dollar_label_max);
- dollar_label_defines = (char *) xrealloc (dollar_label_defines, dollar_label_max);
+ dollar_label_defines = XRESIZEVEC (char, dollar_label_defines,
+ dollar_label_max);
} /* if we needed to grow */
dollar_labels[dollar_label_count] = label;
@@ -3075,11 +3076,11 @@ symbol_relc_make_sym (symbolS * sym)
sname_len = strlen (sname);
typetag = symbol_section_p (sym) ? 'S' : 's';
- terminal = xmalloc (1 /* S or s */
- + 8 /* sname_len in decimal */
- + 1 /* _ spacer */
- + sname_len /* name itself */
- + 1 /* \0 */ );
+ terminal = XNEWVEC (char, (1 /* S or s */
+ + 8 /* sname_len in decimal */
+ + 1 /* _ spacer */
+ + sname_len /* name itself */
+ + 1 /* \0 */ ));
sprintf (terminal, "%c%d:%s", typetag, sname_len, sname);
return terminal;
diff --git a/gas/write.c b/gas/write.c
index c965e68..0dfca0c 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1234,7 +1234,7 @@ write_relocs (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
rp = &r->next;
}
- relocs = (arelent **) xcalloc (n, sizeof (arelent *));
+ relocs = XCNEWVEC (arelent *, n);
n = 0;
r = my_reloc_list;
--
2.1.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] use XNEW and related macros more
2016-04-24 8:30 [PATCH] use XNEW and related macros more tbsaunde+binutils
@ 2016-04-25 8:41 ` Nick Clifton
0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2016-04-25 8:41 UTC (permalink / raw)
To: tbsaunde+binutils, binutils
Hi Trev,
> gas/ChangeLog:
> 2016-04-24 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
>
> * app.c (app_push): Use XNEW and related macros.
> * as.c (parse_args): Likewise.
> * cgen.c (make_right_shifted_expr): Likewise.
> (gas_cgen_tc_gen_reloc): Likewise.
> * config/bfin-defs.h: Likewise.
> * config/bfin-parse.y: Likewise.
> * config/obj-coff.c (stack_init): Likewise.
> (stack_push): Likewise.
> (coff_obj_symbol_new_hook): Likewise.
> (coff_obj_symbol_clone_hook): Likewise.
> (add_lineno): Likewise.
> (coff_frob_symbol): Likewise.
> * config/obj-elf.c (obj_elf_section_name): Likewise.
> (build_group_lists): Likewise.
> * config/obj-evax.c (evax_symbol_new_hook): Likewise.
> * config/obj-macho.c (obj_mach_o_indirect_symbol): Likewise.
> * config/tc-aarch64.c (insert_reg_alias): Likewise.
> (find_or_make_literal_pool): Likewise.
> (add_to_lit_pool): Likewise.
> (fill_instruction_hash_table): Likewise.
> * config/tc-alpha.c (load_expression): Likewise.
> (emit_jsrjmp): Likewise.
> (s_alpha_ent): Likewise.
> (s_alpha_end): Likewise.
> (s_alpha_linkage): Likewise.
> (md_begin): Likewise.
> (tc_gen_reloc): Likewise.
> * config/tc-arc.c (arc_insert_opcode): Likewise.
> (arc_extcorereg): Likewise.
> * config/tc-bfin.c: Likewise.
> * config/tc-cr16.c: Likewise.
> * config/tc-cris.c: Likewise.
> * config/tc-crx.c (preprocess_reglist): Likewise.
> * config/tc-d10v.c: Likewise.
> * config/tc-frv.c (frv_insert_vliw_insn): Likewise.
> (frv_tomcat_shuffle): Likewise.
> * config/tc-h8300.c: Likewise.
> * config/tc-i370.c (i370_macro): Likewise.
> * config/tc-i386.c (lex_got): Likewise.
> (md_parse_option): Likewise.
> * config/tc-ia64.c (alloc_record): Likewise.
> (set_imask): Likewise.
> (save_prologue_count): Likewise.
> (dot_proc): Likewise.
> (dot_endp): Likewise.
> (ia64_frob_label): Likewise.
> (add_qp_imply): Likewise.
> (add_qp_mutex): Likewise.
> (mark_resource): Likewise.
> (dot_alias): Likewise.
> * config/tc-m68hc11.c: Likewise.
> * config/tc-m68k.c (m68k_frob_label): Likewise.
> (s_save): Likewise.
> (mri_control_label): Likewise.
> (push_mri_control): Likewise.
> (build_mri_control_operand): Likewise.
> (s_mri_else): Likewise.
> (s_mri_break): Likewise.
> (s_mri_next): Likewise.
> (s_mri_for): Likewise.
> (s_mri_endw): Likewise.
> * config/tc-metag.c (create_mnemonic_htab): Likewise.
> * config/tc-microblaze.c: Likewise.
> * config/tc-mmix.c (s_loc): Likewise.
> * config/tc-nds32.c (nds32_relax_hint): Likewise.
> * config/tc-nios2.c (nios2_insn_reloc_new): Likewise.
> * config/tc-rl78.c: Likewise.
> * config/tc-rx.c (rx_include): Likewise.
> * config/tc-sh.c: Likewise.
> * config/tc-sh64.c (shmedia_frob_section_type): Likewise.
> * config/tc-sparc.c: Likewise.
> * config/tc-spu.c: Likewise.
> * config/tc-tic6x.c (static tic6x_unwind_info *tic6x_get_unwind): Likewise.
> (tic6x_start_unwind_section): Likewise.
> * config/tc-tilegx.c: Likewise.
> * config/tc-tilepro.c: Likewise.
> * config/tc-v850.c: Likewise.
> * config/tc-visium.c: Likewise.
> * config/tc-xgate.c: Likewise.
> * config/tc-xtensa.c (xtensa_translate_old_userreg_ops): Likewise.
> (new_resource_table): Likewise.
> (resize_resource_table): Likewise.
> (xtensa_create_trampoline_frag): Likewise.
> (xtensa_maybe_create_literal_pool_frag): Likewise.
> (cache_literal_section): Likewise.
> * config/xtensa-relax.c (append_transition): Likewise.
> (append_condition): Likewise.
> (append_value_condition): Likewise.
> (append_constant_value_condition): Likewise.
> (append_literal_op): Likewise.
> (append_label_op): Likewise.
> (append_constant_op): Likewise.
> (append_field_op): Likewise.
> (append_user_fn_field_op): Likewise.
> (enter_opname_n): Likewise.
> (enter_opname): Likewise.
> (split_string): Likewise.
> (parse_insn_templ): Likewise.
> (clone_req_or_option_list): Likewise.
> (clone_req_option_list): Likewise.
> (parse_option_cond): Likewise.
> (parse_insn_pattern): Likewise.
> (parse_insn_repl): Likewise.
> (build_transition): Likewise.
> (build_transition_table): Likewise.
> * dw2gencfi.c (alloc_fde_entry): Likewise.
> (alloc_cfi_insn_data): Likewise.
> (cfi_add_CFA_remember_state): Likewise.
> (dot_cfi_escape): Likewise.
> (dot_cfi_fde_data): Likewise.
> (select_cie_for_fde): Likewise.
> * dwarf2dbg.c (dwarf2_directive_loc): Likewise.
> * ecoff.c (ecoff_add_bytes): Likewise.
> (ecoff_build_debug): Likewise.
> * input-scrub.c (input_scrub_push): Likewise.
> (input_scrub_begin): Likewise.
> (input_scrub_next_buffer): Likewise.
> * itbl-ops.c (append_insns_as_macros): Likewise.
> (alloc_entry): Likewise.
> (alloc_field): Likewise.
> * listing.c (listing_newline): Likewise.
> (listing_listing): Likewise.
> * macro.c (get_any_string): Likewise.
> (delete_macro): Likewise.
> * stabs.c (generate_asm_file): Likewise.
> (stabs_generate_asm_lineno): Likewise.
> * subsegs.c (subseg_change): Likewise.
> (subseg_get): Likewise.
> * symbols.c (define_dollar_label): Likewise.
> (symbol_relc_make_sym): Likewise.
> * write.c (write_relocs): Likewise.
Approved - please apply.
Cheers
Nick
PS. As a matter of interest - what is the motivation for all of these patches ?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] use XNEW and related macros more
2016-04-03 16:51 tbsaunde+binutils
@ 2016-04-04 0:24 ` Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2016-04-04 0:24 UTC (permalink / raw)
To: tbsaunde+binutils; +Cc: binutils
On Sun, Apr 03, 2016 at 12:56:01PM -0400, tbsaunde+binutils@tbsaunde.org wrote:
> * app.c (app_push): use XNEW macro.
> * as.c: Likewise.
> * config/obj-elf.c (obj_elf_change_section): Likewise.
> (elf_copy_symbol_attributes): Likewise.
> (obj_elf_size): Likewise.
> (build_group_lists): Likewise.
> * config/tc-aarch64.c (add_operand_error_record): Likewise.
> (md_assemble): Likewise.
> (tc_gen_reloc): Likewise.
> (get_upper_str): Likewise.
> (aarch64_parse_features): Likewise.
> * config/tc-arm.c (insert_reg_alias): Likewise.
> (insert_neon_reg_alias): Likewise.
> (find_or_make_literal_pool): Likewise.
> (s_arm_elf_cons): Likewise.
> (add_unwind_opcode): Likewise.
> (arm_parse_extension): Likewise.
> * config/tc-avr.c (create_record_for_frag): Likewise.
> * config/tc-crx.c: Likewise.
> * config/tc-d30v.c: Likewise.
> * config/tc-dlx.c (s_proc): Likewise.
> * config/tc-ft32.c: Likewise.
> * config/tc-h8300.c: Likewise.
> * config/tc-hppa.c (pa_proc): Likewise.
> (create_new_space): Likewise.
> (create_new_subspace): Likewise.
> * config/tc-i860.c: Likewise.
> * config/tc-i960.c: Likewise.
> * config/tc-ia64.c: Likewise.
> * config/tc-iq2000.c (iq2000_add_macro): Likewise.
> (iq2000_record_hi16): Likewise.
> * config/tc-m32c.c (m32c_indirect_operand): Likewise.
> * config/tc-m32r.c (debug_sym): Likewise.
> (m32r_record_hi16): Likewise.
> * config/tc-m68k.c (m68k_ip): Likewise.
> (md_begin): Likewise.
> * config/tc-mcore.c: Likewise.
> * config/tc-microblaze.c (check_got): Likewise.
> * config/tc-mips.c (append_insn): Likewise.
> (s_mipsset): Likewise.
> (mips_record_label): Likewise.
> (s_mips_end): Likewise.
> * config/tc-mmix.c (mmix_frob_file): Likewise.
> * config/tc-mn10200.c: Likewise.
> * config/tc-mn10300.c: Likewise.
> * config/tc-moxie.c: Likewise.
> * config/tc-msp430.c: Likewise.
> * config/tc-nds32.c (nds32_elf_save_pseudo_pattern): Likewise.
> * config/tc-ns32k.c: Likewise.
> * config/tc-or1k.c: Likewise.
> * config/tc-pdp11.c: Likewise.
> * config/tc-pj.c (fake_opcode): Likewise.
> * config/tc-ppc.c (ppc_apuinfo_section_add): Likewise.
> (ppc_macro): Likewise.
> (ppc_dwsect): Likewise.
> (ppc_machine): Likewise.
> * config/tc-rl78.c (rl78_frag_init): Likewise.
> * config/tc-rx.c (rx_frag_init): Likewise.
> * config/tc-s390.c (s390_lit_suffix): Likewise.
> (s390_machine): Likewise.
> (s390_machinemode): Likewise.
> * config/tc-score.c (s3_insert_reg): Likewise.
> (s3_gen_reloc): Likewise.
> * config/tc-score7.c (s7_insert_reg): Likewise.
> (s7_gen_reloc): Likewise.
> * config/tc-tic30.c (tic30_operand): Likewise.
> * config/tc-tic4x.c (tic4x_inst_make): Likewise.
> * config/tc-tic54x.c (stag_add_field): Likewise.
> (tic54x_struct): Likewise.
> (tic54x_space): Likewise.
> (tic54x_field): Likewise.
> (tic54x_mlib): Likewise.
> (subsym_substitute): Likewise.
> * config/tc-tic6x.c (tic6x_frob_label): Likewise.
> * config/tc-vax.c: Likewise.
> * config/tc-xc16x.c: Likewise.
> * config/tc-xtensa.c (xtensa_add_insn_label): Likewise.
> (directive_push): Likewise.
> (xtensa_begin_directive): Likewise.
> (tokenize_arguments): Likewise.
> (xtensa_add_literal_sym): Likewise.
> (new_resource_table): Likewise.
> (resize_resource_table): Likewise.
> (emit_single_op): Likewise.
> (xtensa_create_trampoline_frag): Likewise.
> (xtensa_maybe_create_literal_pool_frag): Likewise.
> (xtensa_add_config_info): Likewise.
> (xtensa_realloc_fixup_cache): Likewise.
> (add_subseg_info): Likewise.
> (cache_literal_section): Likewise.
> (add_xt_block_frags): Likewise.
> (add_xt_prop_frags): Likewise.
> (init_op_placement_info_table): Likewise.
> (build_section_rename): Likewise.
> * config/tc-z80.c: Likewise.
> * config/tc-z8k.c: Likewise.
> * depend.c (register_dependency): Likewise.
> * dwarf2dbg.c (get_line_subseg): Likewise.
> (dwarf2_gen_line_info_1): Likewise.
> (get_filenum): Likewise.
> * ecoff.c (allocate_scope): Likewise.
> (allocate_vlinks): Likewise.
> (allocate_shash): Likewise.
> (allocate_thash): Likewise.
> (allocate_tag): Likewise.
> (allocate_forward): Likewise.
> (allocate_thead): Likewise.
> (allocate_lineno_list): Likewise.
> * expr.c (make_expr_symbol): Likewise.
> * hash.c (hash_new_sized): Likewise.
> * input-file.c (input_file_push): Likewise.
> * listing.c (file_info): Likewise.
> (listing_newline): Likewise.
> * macro.c (new_formal): Likewise.
> (define_macro): Likewise.
> * remap.c (add_debug_prefix_map): Likewise.
> * symbols.c (symbol_find_noref): Likewise.
> (define_dollar_label): Likewise.
> (fb_label_instance_inc): Likewise.
> (symbol_relc_make_value): Likewise.
OK with a couple of tweaks. Nice to see the extraneous checks on
xmalloc disappear in tc-aarch64.c and elsewhere, and replacement of
malloc in tc-dlx.c.
> --- a/gas/config/tc-hppa.c
> +++ b/gas/config/tc-hppa.c
> @@ -1388,8 +1388,8 @@ tc_gen_reloc (asection *section, fixS *fixp)
> for (n_relocs = 0; codes[n_relocs]; n_relocs++)
> ;
>
> - relocs = xmalloc (sizeof (arelent *) * n_relocs + 1);
> - reloc = xmalloc (sizeof (arelent) * n_relocs);
> + relocs = XNEWVEC (arelent *, n_relocs + 1);
> + reloc = XNEWVEC (arelent, n_relocs);
> for (i = 0; i < n_relocs; i++)
> relocs[i] = &reloc[i];
>
Also, nice catch here.
> diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
> index f148845..9f18b17 100644
> --- a/gas/config/tc-m68k.c
> +++ b/gas/config/tc-m68k.c
> @@ -4599,7 +4599,7 @@ md_begin (void)
> /* First sort the opcode table into alphabetical order to seperate
> the order that the assembler wants to see the opcodes from the
> order that the disassembler wants to see them. */
> - m68k_sorted_opcodes = xmalloc (m68k_numopcodes * sizeof (* m68k_sorted_opcodes));
> + m68k_sorted_opcodes = XNEWVEC (const struct m68k_opcode *, m68k_numopcodes);
> if (!m68k_sorted_opcodes)
> as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
> m68k_numopcodes * ((int) sizeof (* m68k_sorted_opcodes)));
While you're at it, please delete this useless check on xmalloc return
value.
> @@ -7456,7 +7454,7 @@ xtensa_create_trampoline_frag (bfd_boolean needs_jump_around)
> trampoline_buf = xtensa_insnbuf_alloc (xtensa_default_isa);
> trampoline_slotbuf = xtensa_insnbuf_alloc (xtensa_default_isa);
> }
> - tf = (struct trampoline_frag *)xmalloc(sizeof (struct trampoline_frag));
> + tf = XNEW(struct trampoline_frag);
> tf->next = ts->trampoline_list.next;
> ts->trampoline_list.next = tf;
> tf->needs_jump_around = needs_jump_around;
Formatting.
> @@ -7621,7 +7619,7 @@ xtensa_maybe_create_literal_pool_frag (bfd_boolean create,
> fragP = frag_now;
> }
>
> - lpf = (struct litpool_frag *)xmalloc(sizeof (struct litpool_frag));
> + lpf = XNEW(struct litpool_frag);
> /* Insert at tail of circular list. */
> lpf->addr = 0;
> lps->frag_list.prev->next = lpf;
and here.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] use XNEW and related macros more
@ 2016-04-03 16:51 tbsaunde+binutils
2016-04-04 0:24 ` Alan Modra
0 siblings, 1 reply; 4+ messages in thread
From: tbsaunde+binutils @ 2016-04-03 16:51 UTC (permalink / raw)
To: binutils; +Cc: Trevor Saunders
From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
Hi,
$subject, makes things a bit shorter and simpler.
built one target per tc-*.c (and tried to use different obj-*.c as well), ok?
Trev
gas/ChangeLog:
2016-04-03 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* app.c (app_push): use XNEW macro.
* as.c: Likewise.
* config/obj-elf.c (obj_elf_change_section): Likewise.
(elf_copy_symbol_attributes): Likewise.
(obj_elf_size): Likewise.
(build_group_lists): Likewise.
* config/tc-aarch64.c (add_operand_error_record): Likewise.
(md_assemble): Likewise.
(tc_gen_reloc): Likewise.
(get_upper_str): Likewise.
(aarch64_parse_features): Likewise.
* config/tc-arm.c (insert_reg_alias): Likewise.
(insert_neon_reg_alias): Likewise.
(find_or_make_literal_pool): Likewise.
(s_arm_elf_cons): Likewise.
(add_unwind_opcode): Likewise.
(arm_parse_extension): Likewise.
* config/tc-avr.c (create_record_for_frag): Likewise.
* config/tc-crx.c: Likewise.
* config/tc-d30v.c: Likewise.
* config/tc-dlx.c (s_proc): Likewise.
* config/tc-ft32.c: Likewise.
* config/tc-h8300.c: Likewise.
* config/tc-hppa.c (pa_proc): Likewise.
(create_new_space): Likewise.
(create_new_subspace): Likewise.
* config/tc-i860.c: Likewise.
* config/tc-i960.c: Likewise.
* config/tc-ia64.c: Likewise.
* config/tc-iq2000.c (iq2000_add_macro): Likewise.
(iq2000_record_hi16): Likewise.
* config/tc-m32c.c (m32c_indirect_operand): Likewise.
* config/tc-m32r.c (debug_sym): Likewise.
(m32r_record_hi16): Likewise.
* config/tc-m68k.c (m68k_ip): Likewise.
(md_begin): Likewise.
* config/tc-mcore.c: Likewise.
* config/tc-microblaze.c (check_got): Likewise.
* config/tc-mips.c (append_insn): Likewise.
(s_mipsset): Likewise.
(mips_record_label): Likewise.
(s_mips_end): Likewise.
* config/tc-mmix.c (mmix_frob_file): Likewise.
* config/tc-mn10200.c: Likewise.
* config/tc-mn10300.c: Likewise.
* config/tc-moxie.c: Likewise.
* config/tc-msp430.c: Likewise.
* config/tc-nds32.c (nds32_elf_save_pseudo_pattern): Likewise.
* config/tc-ns32k.c: Likewise.
* config/tc-or1k.c: Likewise.
* config/tc-pdp11.c: Likewise.
* config/tc-pj.c (fake_opcode): Likewise.
* config/tc-ppc.c (ppc_apuinfo_section_add): Likewise.
(ppc_macro): Likewise.
(ppc_dwsect): Likewise.
(ppc_machine): Likewise.
* config/tc-rl78.c (rl78_frag_init): Likewise.
* config/tc-rx.c (rx_frag_init): Likewise.
* config/tc-s390.c (s390_lit_suffix): Likewise.
(s390_machine): Likewise.
(s390_machinemode): Likewise.
* config/tc-score.c (s3_insert_reg): Likewise.
(s3_gen_reloc): Likewise.
* config/tc-score7.c (s7_insert_reg): Likewise.
(s7_gen_reloc): Likewise.
* config/tc-tic30.c (tic30_operand): Likewise.
* config/tc-tic4x.c (tic4x_inst_make): Likewise.
* config/tc-tic54x.c (stag_add_field): Likewise.
(tic54x_struct): Likewise.
(tic54x_space): Likewise.
(tic54x_field): Likewise.
(tic54x_mlib): Likewise.
(subsym_substitute): Likewise.
* config/tc-tic6x.c (tic6x_frob_label): Likewise.
* config/tc-vax.c: Likewise.
* config/tc-xc16x.c: Likewise.
* config/tc-xtensa.c (xtensa_add_insn_label): Likewise.
(directive_push): Likewise.
(xtensa_begin_directive): Likewise.
(tokenize_arguments): Likewise.
(xtensa_add_literal_sym): Likewise.
(new_resource_table): Likewise.
(resize_resource_table): Likewise.
(emit_single_op): Likewise.
(xtensa_create_trampoline_frag): Likewise.
(xtensa_maybe_create_literal_pool_frag): Likewise.
(xtensa_add_config_info): Likewise.
(xtensa_realloc_fixup_cache): Likewise.
(add_subseg_info): Likewise.
(cache_literal_section): Likewise.
(add_xt_block_frags): Likewise.
(add_xt_prop_frags): Likewise.
(init_op_placement_info_table): Likewise.
(build_section_rename): Likewise.
* config/tc-z80.c: Likewise.
* config/tc-z8k.c: Likewise.
* depend.c (register_dependency): Likewise.
* dwarf2dbg.c (get_line_subseg): Likewise.
(dwarf2_gen_line_info_1): Likewise.
(get_filenum): Likewise.
* ecoff.c (allocate_scope): Likewise.
(allocate_vlinks): Likewise.
(allocate_shash): Likewise.
(allocate_thash): Likewise.
(allocate_tag): Likewise.
(allocate_forward): Likewise.
(allocate_thead): Likewise.
(allocate_lineno_list): Likewise.
* expr.c (make_expr_symbol): Likewise.
* hash.c (hash_new_sized): Likewise.
* input-file.c (input_file_push): Likewise.
* listing.c (file_info): Likewise.
(listing_newline): Likewise.
* macro.c (new_formal): Likewise.
(define_macro): Likewise.
* remap.c (add_debug_prefix_map): Likewise.
* symbols.c (symbol_find_noref): Likewise.
(define_dollar_label): Likewise.
(fb_label_instance_inc): Likewise.
(symbol_relc_make_value): Likewise.
---
gas/app.c | 2 +-
gas/as.c | 2 +-
gas/config/obj-elf.c | 9 ++++----
gas/config/tc-aarch64.c | 16 ++++++---------
gas/config/tc-arm.c | 22 +++++++++-----------
gas/config/tc-avr.c | 7 +++----
gas/config/tc-crx.c | 4 ++--
gas/config/tc-d30v.c | 4 ++--
gas/config/tc-dlx.c | 12 +++++------
gas/config/tc-ft32.c | 4 ++--
gas/config/tc-h8300.c | 4 ++--
gas/config/tc-hppa.c | 33 ++++++++++++------------------
gas/config/tc-i860.c | 4 ++--
gas/config/tc-i960.c | 4 ++--
gas/config/tc-ia64.c | 4 ++--
gas/config/tc-iq2000.c | 6 +++---
gas/config/tc-m32c.c | 6 +++---
gas/config/tc-m32r.c | 8 ++++----
gas/config/tc-m68k.c | 4 ++--
gas/config/tc-mcore.c | 4 ++--
gas/config/tc-microblaze.c | 3 ++-
gas/config/tc-mips.c | 13 ++++++------
gas/config/tc-mmix.c | 2 +-
gas/config/tc-mn10200.c | 4 ++--
gas/config/tc-mn10300.c | 10 ++++-----
gas/config/tc-moxie.c | 5 ++---
gas/config/tc-msp430.c | 10 ++++-----
gas/config/tc-nds32.c | 2 +-
gas/config/tc-ns32k.c | 6 +++---
gas/config/tc-or1k.c | 4 ++--
gas/config/tc-pdp11.c | 4 ++--
gas/config/tc-pj.c | 6 +++---
gas/config/tc-ppc.c | 18 ++++++++--------
gas/config/tc-rl78.c | 2 +-
gas/config/tc-rx.c | 42 +++++++++++++++++++-------------------
gas/config/tc-s390.c | 12 +++++------
gas/config/tc-score.c | 12 +++++------
gas/config/tc-score7.c | 12 +++++------
gas/config/tc-tic30.c | 9 ++++----
gas/config/tc-tic4x.c | 9 ++++----
gas/config/tc-tic54x.c | 25 ++++++++++-------------
gas/config/tc-tic6x.c | 10 ++++-----
gas/config/tc-vax.c | 4 ++--
gas/config/tc-xc16x.c | 4 ++--
gas/config/tc-xtensa.c | 51 ++++++++++++++++++++--------------------------
gas/config/tc-z80.c | 4 ++--
gas/config/tc-z8k.c | 6 +++---
gas/depend.c | 2 +-
gas/dwarf2dbg.c | 12 +++++------
gas/ecoff.c | 16 +++++++--------
gas/expr.c | 2 +-
gas/hash.c | 2 +-
gas/input-file.c | 2 +-
gas/listing.c | 6 +++---
gas/macro.c | 4 ++--
gas/remap.c | 2 +-
gas/symbols.c | 25 ++++++++++-------------
57 files changed, 243 insertions(+), 278 deletions(-)
diff --git a/gas/app.c b/gas/app.c
index f53e7ce..c59421c 100644
--- a/gas/app.c
+++ b/gas/app.c
@@ -249,7 +249,7 @@ app_push (void)
{
struct app_save *saved;
- saved = (struct app_save *) xmalloc (sizeof (*saved));
+ saved = XNEW (struct app_save);
saved->state = state;
saved->old_state = old_state;
saved->out_string = out_string;
diff --git a/gas/as.c b/gas/as.c
index cf8e90d..15f53ea 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -747,7 +747,7 @@ This program has absolutely no warranty.\n"));
break;
}
- n = xmalloc (sizeof * n);
+ n = XNEW (struct itbl_file_list);
n->next = itbl_files;
n->name = optarg;
itbl_files = n;
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 68290e2..ea9f7ab 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -568,7 +568,7 @@ obj_elf_change_section (const char *name,
if (push)
{
struct section_stack *elt;
- elt = (struct section_stack *) xmalloc (sizeof (struct section_stack));
+ elt = XNEW (struct section_stack);
elt->next = section_stack;
elt->seg = now_seg;
elt->prev_seg = previous_section;
@@ -1730,7 +1730,7 @@ elf_copy_symbol_attributes (symbolS *dest, symbolS *src)
if (srcelf->size)
{
if (destelf->size == NULL)
- destelf->size = (expressionS *) xmalloc (sizeof (expressionS));
+ destelf->size = XNEW (expressionS);
*destelf->size = *srcelf->size;
}
else
@@ -1847,8 +1847,7 @@ obj_elf_size (int ignore ATTRIBUTE_UNUSED)
}
else
{
- symbol_get_obj (sym)->size =
- (expressionS *) xmalloc (sizeof (expressionS));
+ symbol_get_obj (sym)->size = XNEW (expressionS);
*symbol_get_obj (sym)->size = exp;
}
demand_empty_rest_of_line ();
@@ -2339,7 +2338,7 @@ build_group_lists (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf)
list->num_group += 1;
/* Add index to hash. */
- idx_ptr = (unsigned int *) xmalloc (sizeof (unsigned int));
+ idx_ptr = XNEW (unsigned int);
*idx_ptr = i;
hash_insert (list->indexes, group_name, idx_ptr);
}
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 14b6011..8fb93ee 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -4051,9 +4051,7 @@ add_operand_error_record (const operand_error_record* new_record)
/* Get one empty record. */
if (free_opnd_error_record_nodes == NULL)
{
- record = xmalloc (sizeof (operand_error_record));
- if (record == NULL)
- abort ();
+ record = XNEW (operand_error_record);
}
else
{
@@ -6102,8 +6100,7 @@ md_assemble (char *str)
store the instruction information for the future fix-up. */
struct aarch64_inst *copy;
gas_assert (inst.reloc.type != BFD_RELOC_UNUSED);
- if ((copy = xmalloc (sizeof (struct aarch64_inst))) == NULL)
- abort ();
+ copy = XNEW (struct aarch64_inst);
memcpy (copy, &inst.base, sizeof (struct aarch64_inst));
output_inst (copy);
}
@@ -7198,9 +7195,9 @@ tc_gen_reloc (asection * section, fixS * fixp)
arelent *reloc;
bfd_reloc_code_real_type code;
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
@@ -7541,8 +7538,7 @@ get_upper_str (const char *str)
{
char *ret;
size_t len = strlen (str);
- if ((ret = xmalloc (len + 1)) == NULL)
- abort ();
+ ret = XNEWVEC (char, len + 1);
convert_to_upper (ret, str, len);
return ret;
}
@@ -7838,7 +7834,7 @@ aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p,
adding an extension (1) or removing it (0) and only allowing it to
change in the order -1 -> 1 -> 0. */
int adding_value = -1;
- aarch64_feature_set *ext_set = xmalloc (sizeof (aarch64_feature_set));
+ aarch64_feature_set *ext_set = XNEW (aarch64_feature_set);
/* Copy the feature set, so that we can modify it. */
*ext_set = **opt_p;
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 2ccc053..b5b4117 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -2180,7 +2180,7 @@ insert_reg_alias (char *str, unsigned number, int type)
}
name = xstrdup (str);
- new_reg = (struct reg_entry *) xmalloc (sizeof (struct reg_entry));
+ new_reg = XNEW (struct reg_entry);
new_reg->name = name;
new_reg->number = number;
@@ -2208,8 +2208,7 @@ insert_neon_reg_alias (char *str, int number, int type,
if (atype)
{
- reg->neon = (struct neon_typed_alias *)
- xmalloc (sizeof (struct neon_typed_alias));
+ reg->neon = XNEW (struct neon_typed_alias);
*reg->neon = *atype;
}
}
@@ -3138,7 +3137,7 @@ find_or_make_literal_pool (void)
if (pool == NULL)
{
/* Create a new pool. */
- pool = (literal_pool *) xmalloc (sizeof (* pool));
+ pool = XNEW (literal_pool);
if (! pool)
return NULL;
@@ -3535,7 +3534,7 @@ s_arm_elf_cons (int nbytes)
XXX Surely there is a cleaner way to do this. */
char *p = input_line_pointer;
int offset;
- char *save_buf = xmalloc (input_line_pointer - base);
+ char *save_buf = XNEWVEC (char, input_line_pointer - base);
memcpy (save_buf, base, input_line_pointer - base);
memmove (base + (input_line_pointer - before_reloc),
@@ -21760,10 +21759,10 @@ add_unwind_opcode (valueT op, int length)
{
unwind.opcode_alloc += ARM_OPCODE_CHUNK_SIZE;
if (unwind.opcodes)
- unwind.opcodes = (unsigned char *) xrealloc (unwind.opcodes,
- unwind.opcode_alloc);
+ unwind.opcodes = XRESIZEVEC (unsigned char, unwind.opcodes,
+ unwind.opcode_alloc);
else
- unwind.opcodes = (unsigned char *) xmalloc (unwind.opcode_alloc);
+ unwind.opcodes = XNEWVEC (unsigned char, unwind.opcode_alloc);
}
while (length > 0)
{
@@ -24012,9 +24011,9 @@ tc_gen_reloc (asection *section, fixS *fixp)
arelent * reloc;
bfd_reloc_code_real_type code;
- reloc = (arelent *) xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
@@ -25588,8 +25587,7 @@ struct arm_long_option_table
static bfd_boolean
arm_parse_extension (const char *str, const arm_feature_set **opt_p)
{
- arm_feature_set *ext_set = (arm_feature_set *)
- xmalloc (sizeof (arm_feature_set));
+ arm_feature_set *ext_set = XNEW (arm_feature_set);
/* We insist on extensions being specified in alphabetical order, and with
extensions being added before being removed. We achieve this by having
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 999ffb4..abcbcc7 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -1616,9 +1616,9 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED,
return NULL;
}
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
@@ -2069,8 +2069,7 @@ create_record_for_frag (segT sec, fragS *fragP)
{
struct avr_property_record_link *prop_rec_link;
- prop_rec_link = xmalloc (sizeof (struct avr_property_record_link));
- memset (prop_rec_link, 0, sizeof (*prop_rec_link));
+ prop_rec_link = XCNEW (struct avr_property_record_link);
gas_assert (fragP->fr_next != NULL);
if (fragP->tc_frag_data.is_org)
diff --git a/gas/config/tc-crx.c b/gas/config/tc-crx.c
index 7c8d7ed..7993e72 100644
--- a/gas/config/tc-crx.c
+++ b/gas/config/tc-crx.c
@@ -308,8 +308,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
{
arelent * reloc;
- reloc = xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
reloc->addend = fixP->fx_offset;
diff --git a/gas/config/tc-d30v.c b/gas/config/tc-d30v.c
index ae870ee..88fc124 100644
--- a/gas/config/tc-d30v.c
+++ b/gas/config/tc-d30v.c
@@ -1760,8 +1760,8 @@ arelent *
tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c
index a806fe6..b636cec 100644
--- a/gas/config/tc-dlx.c
+++ b/gas/config/tc-dlx.c
@@ -245,7 +245,7 @@ s_proc (int end_p)
if (leading_char)
{
unsigned len = strlen (name) + 1;
- label = xmalloc (len + 1);
+ label = XNEWVEC (char, len + 1);
label[0] = leading_char;
memcpy (label + 1, name, len);
}
@@ -930,7 +930,7 @@ md_assemble (char *str)
switch (fixP->fx_r_type)
{
case RELOC_DLX_REL26:
- bitP = malloc (sizeof (bit_fixS));
+ bitP = XNEW (bit_fixS);
bitP->fx_bit_size = 26;
bitP->fx_bit_offset = 25;
bitP->fx_bit_base = the_insn.opcode & 0xFC000000;
@@ -942,7 +942,7 @@ md_assemble (char *str)
break;
case RELOC_DLX_LO16:
case RELOC_DLX_REL16:
- bitP = malloc (sizeof (bit_fixS));
+ bitP = XNEW (bit_fixS);
bitP->fx_bit_size = 16;
bitP->fx_bit_offset = 15;
bitP->fx_bit_base = the_insn.opcode & 0xFFFF0000;
@@ -953,7 +953,7 @@ md_assemble (char *str)
fixP->fx_bit_fixP = bitP;
break;
case RELOC_DLX_HI16:
- bitP = malloc (sizeof (bit_fixS));
+ bitP = XNEW (bit_fixS);
bitP->fx_bit_size = 16;
bitP->fx_bit_offset = 15;
bitP->fx_bit_base = the_insn.opcode & 0xFFFF0000;
@@ -1187,7 +1187,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
{
arelent * reloc;
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type);
if (reloc->howto == NULL)
@@ -1201,7 +1201,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
gas_assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
diff --git a/gas/config/tc-ft32.c b/gas/config/tc-ft32.c
index 56c0a68..505d126 100644
--- a/gas/config/tc-ft32.c
+++ b/gas/config/tc-ft32.c
@@ -582,9 +582,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
return 0;
}
- relP = xmalloc (sizeof (arelent));
+ relP = XNEW (arelent);
gas_assert (relP != 0);
- relP->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ relP->sym_ptr_ptr = XNEW (asymbol *);
*relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
diff --git a/gas/config/tc-h8300.c b/gas/config/tc-h8300.c
index edca456..5100f0d 100644
--- a/gas/config/tc-h8300.c
+++ b/gas/config/tc-h8300.c
@@ -2335,8 +2335,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
}
}
- rel = xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
rel->addend = fixp->fx_offset;
diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c
index 82d33c2..6bf1bba 100644
--- a/gas/config/tc-hppa.c
+++ b/gas/config/tc-hppa.c
@@ -1355,9 +1355,9 @@ tc_gen_reloc (asection *section, fixS *fixp)
gas_assert (hppa_fixp != 0);
gas_assert (section != 0);
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
/* Allow fixup_segment to recognize hand-written pc-relative relocations.
@@ -1388,8 +1388,8 @@ tc_gen_reloc (asection *section, fixS *fixp)
for (n_relocs = 0; codes[n_relocs]; n_relocs++)
;
- relocs = xmalloc (sizeof (arelent *) * n_relocs + 1);
- reloc = xmalloc (sizeof (arelent) * n_relocs);
+ relocs = XNEWVEC (arelent *, n_relocs + 1);
+ reloc = XNEWVEC (arelent, n_relocs);
for (i = 0; i < n_relocs; i++)
relocs[i] = &reloc[i];
@@ -1447,7 +1447,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
break;
}
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->howto = bfd_reloc_type_lookup (stdoutput,
(bfd_reloc_code_real_type) code);
@@ -1463,7 +1463,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
{
code = *codes[i];
- relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
*relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
relocs[i]->howto =
bfd_reloc_type_lookup (stdoutput,
@@ -1484,14 +1484,14 @@ tc_gen_reloc (asection *section, fixS *fixp)
(bfd_reloc_code_real_type) *codes[0]);
relocs[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
relocs[0]->addend = 0;
- relocs[1]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ relocs[1]->sym_ptr_ptr = XNEW (asymbol *);
*relocs[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
relocs[1]->howto
= bfd_reloc_type_lookup (stdoutput,
(bfd_reloc_code_real_type) *codes[1]);
relocs[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
relocs[1]->addend = 0;
- relocs[2]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ relocs[2]->sym_ptr_ptr = XNEW (asymbol *);
*relocs[2]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
relocs[2]->howto
= bfd_reloc_type_lookup (stdoutput,
@@ -1546,7 +1546,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
case R_N0SEL:
case R_N1SEL:
/* There is no symbol or addend associated with these fixups. */
- relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
*relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol);
relocs[i]->addend = 0;
break;
@@ -1555,7 +1555,7 @@ tc_gen_reloc (asection *section, fixS *fixp)
case R_ENTRY:
case R_EXIT:
/* There is no symbol associated with these fixups. */
- relocs[i]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ relocs[i]->sym_ptr_ptr = XNEW (asymbol *);
*relocs[i]->sym_ptr_ptr = symbol_get_bfdsym (dummy_symbol);
relocs[i]->addend = fixp->fx_offset;
break;
@@ -6925,7 +6925,7 @@ pa_proc (int unused ATTRIBUTE_UNUSED)
within_procedure = TRUE;
/* Create another call_info structure. */
- call_info = xmalloc (sizeof (struct call_info));
+ call_info = XNEW (struct call_info);
if (!call_info)
as_fatal (_("Cannot allocate unwind descriptor\n"));
@@ -7718,11 +7718,7 @@ create_new_space (const char *name,
{
sd_chain_struct *chain_entry;
- chain_entry = xmalloc (sizeof (sd_chain_struct));
- if (!chain_entry)
- as_fatal (_("Out of memory: could not allocate new space chain entry: %s\n"),
- name);
-
+ chain_entry = XNEW (sd_chain_struct);
SPACE_NAME (chain_entry) = xstrdup (name);
SPACE_DEFINED (chain_entry) = defined;
SPACE_USER_DEFINED (chain_entry) = user_defined;
@@ -7805,10 +7801,7 @@ create_new_subspace (sd_chain_struct *space,
{
ssd_chain_struct *chain_entry;
- chain_entry = xmalloc (sizeof (ssd_chain_struct));
- if (!chain_entry)
- as_fatal (_("Out of memory: could not allocate new subspace chain entry: %s\n"), name);
-
+ chain_entry = XNEW (ssd_chain_struct);
SUBSPACE_NAME (chain_entry) = xstrdup (name);
/* Initialize subspace_defined. When we hit a .subspace directive
diff --git a/gas/config/tc-i860.c b/gas/config/tc-i860.c
index 85855e9..858d81e 100644
--- a/gas/config/tc-i860.c
+++ b/gas/config/tc-i860.c
@@ -1426,8 +1426,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
{
arelent *reloc;
- reloc = xmalloc (sizeof (*reloc));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->addend = fixp->fx_offset;
diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c
index 1335da1..59ef760 100644
--- a/gas/config/tc-i960.c
+++ b/gas/config/tc-i960.c
@@ -2623,7 +2623,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
{
arelent * reloc;
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
/* HACK: Is this right? */
fixP->fx_r_type = tc_bfd_fix2rtype (fixP);
@@ -2640,7 +2640,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
gas_assert (!fixP->fx_pcrel == !reloc->howto->pc_relative);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
reloc->addend = fixP->fx_addnumber;
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index 8da09e0..2d10e8a 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -11551,8 +11551,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = xmalloc (sizeof (*reloc));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->addend = fixp->fx_offset;
diff --git a/gas/config/tc-iq2000.c b/gas/config/tc-iq2000.c
index f1f7945..f150e19 100644
--- a/gas/config/tc-iq2000.c
+++ b/gas/config/tc-iq2000.c
@@ -233,7 +233,7 @@ iq2000_add_macro (const char * name,
sb macro_name;
const char *namestr;
- macro = xmalloc (sizeof (macro_entry));
+ macro = XNEW (macro_entry);
sb_new (& macro->sub);
sb_new (& macro_name);
@@ -253,7 +253,7 @@ iq2000_add_macro (const char * name,
{
formal_entry *formal;
- formal = xmalloc (sizeof (formal_entry));
+ formal = XNEW (formal_entry);
sb_new (& formal->name);
sb_new (& formal->def);
@@ -535,7 +535,7 @@ iq2000_record_hi16 (int reloc_type,
gas_assert (reloc_type == BFD_RELOC_HI16);
- hi_fixup = xmalloc (sizeof * hi_fixup);
+ hi_fixup = XNEW (struct iq2000_hi_fixup);
hi_fixup->fixp = fixP;
hi_fixup->seg = now_seg;
hi_fixup->next = iq2000_hi_fixup_list;
diff --git a/gas/config/tc-m32c.c b/gas/config/tc-m32c.c
index 0219d9b..70f0aeb 100644
--- a/gas/config/tc-m32c.c
+++ b/gas/config/tc-m32c.c
@@ -267,7 +267,7 @@ m32c_indirect_operand (char *str)
operand = 1;
ns_len = strlen (str);
- new_str = (char*) xmalloc (ns_len);
+ new_str = XNEWVEC (char, ns_len);
ns = new_str;
ns_end = ns + ns_len;
@@ -1064,9 +1064,9 @@ tc_gen_reloc (asection *sec, fixS *fx)
{
arelent * reloc;
- reloc = xmalloc (sizeof (* reloc));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fx->fx_addsy);
reloc->address = fx->fx_frag->fr_address + fx->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fx->fx_r_type);
diff --git a/gas/config/tc-m32r.c b/gas/config/tc-m32r.c
index 126ab9c..f77c1f1 100644
--- a/gas/config/tc-m32r.c
+++ b/gas/config/tc-m32r.c
@@ -585,7 +585,7 @@ debug_sym (int ignore ATTRIBUTE_UNUSED)
else
{
- lnk = (sym_linkS *) xmalloc (sizeof (sym_linkS));
+ lnk = XNEW (sym_linkS);
lnk->symbol = symbolP;
lnk->next = debug_sym_link;
debug_sym_link = lnk;
@@ -1898,7 +1898,7 @@ m32r_record_hi16 (int reloc_type,
gas_assert (reloc_type == BFD_RELOC_M32R_HI16_SLO
|| reloc_type == BFD_RELOC_M32R_HI16_ULO);
- hi_fixup = xmalloc (sizeof (* hi_fixup));
+ hi_fixup = XNEW (struct m32r_hi_fixup);
hi_fixup->fixp = fixP;
hi_fixup->seg = now_seg;
hi_fixup->next = m32r_hi_fixup_list;
@@ -2195,9 +2195,9 @@ tc_gen_reloc (asection * section, fixS * fixP)
arelent * reloc;
bfd_reloc_code_real_type code;
- reloc = xmalloc (sizeof (* reloc));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
index f148845..9f18b17 100644
--- a/gas/config/tc-m68k.c
+++ b/gas/config/tc-m68k.c
@@ -2348,7 +2348,7 @@ m68k_ip (char *instring)
const struct m68k_cpu *cpu;
int any = 0;
size_t space = 400;
- char *buf = xmalloc (space + 1);
+ char *buf = XNEWVEC (char, space + 1);
size_t len;
int paren = 1;
@@ -4599,7 +4599,7 @@ md_begin (void)
/* First sort the opcode table into alphabetical order to seperate
the order that the assembler wants to see the opcodes from the
order that the disassembler wants to see them. */
- m68k_sorted_opcodes = xmalloc (m68k_numopcodes * sizeof (* m68k_sorted_opcodes));
+ m68k_sorted_opcodes = XNEWVEC (const struct m68k_opcode *, m68k_numopcodes);
if (!m68k_sorted_opcodes)
as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"),
m68k_numopcodes * ((int) sizeof (* m68k_sorted_opcodes)));
diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c
index 67d1ea8..f8b934d 100644
--- a/gas/config/tc-mcore.c
+++ b/gas/config/tc-mcore.c
@@ -2183,8 +2183,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
break;
}
- rel = xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
/* Always pass the addend along! */
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index e720ee8..ceb4365 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -798,7 +798,8 @@ check_got (int * got_type, int * got_len)
for (new_pointer = past_got; !is_end_of_line[(unsigned char) *new_pointer++];)
;
second = new_pointer - past_got;
- tmpbuf = xmalloc (first + second + 2); /* One extra byte for ' ' and one for NUL. */
+ /* One extra byte for ' ' and one for NUL. */
+ tmpbuf = XNEWVEC (char, first + second + 2);
memcpy (tmpbuf, input_line_pointer, first);
tmpbuf[first] = ' '; /* @GOTOFF is replaced with a single space. */
memcpy (tmpbuf + first + 1, past_got, second);
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index ca1098b..b596b8b 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -7414,8 +7414,7 @@ append_insn (struct mips_cl_insn *ip, expressionS *address_expr,
if (hi_fixup == 0
|| !fixup_has_matching_lo_p (hi_fixup->fixp))
{
- hi_fixup = ((struct mips_hi_fixup *)
- xmalloc (sizeof (struct mips_hi_fixup)));
+ hi_fixup = XNEW (struct mips_hi_fixup);
hi_fixup->next = mips_hi_fixup_list;
mips_hi_fixup_list = hi_fixup;
}
@@ -15681,7 +15680,7 @@ s_mipsset (int x ATTRIBUTE_UNUSED)
{
struct mips_option_stack *s;
- s = (struct mips_option_stack *) xmalloc (sizeof *s);
+ s = XNEW (struct mips_option_stack);
s->next = mips_opts_stack;
s->options = mips_opts;
mips_opts_stack = s;
@@ -17170,8 +17169,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
bfd_reloc_code_real_type code;
memset (retval, 0, sizeof(retval));
- reloc = retval[0] = (arelent *) xcalloc (1, sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = retval[0] = XCNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
@@ -17888,7 +17887,7 @@ mips_record_label (symbolS *sym)
struct insn_label_list *l;
if (free_insn_labels == NULL)
- l = (struct insn_label_list *) xmalloc (sizeof *l);
+ l = XNEW (struct insn_label_list);
else
{
l = free_insn_labels;
@@ -18369,7 +18368,7 @@ s_mips_end (int x ATTRIBUTE_UNUSED)
if (p && cur_proc_ptr)
{
OBJ_SYMFIELD_TYPE *obj = symbol_get_obj (p);
- expressionS *exp = xmalloc (sizeof (expressionS));
+ expressionS *exp = XNEW (expressionS);
obj->size = exp;
exp->X_op = O_subtract;
diff --git a/gas/config/tc-mmix.c b/gas/config/tc-mmix.c
index 2400a0b..00a326e 100644
--- a/gas/config/tc-mmix.c
+++ b/gas/config/tc-mmix.c
@@ -3775,7 +3775,7 @@ mmix_frob_file (void)
if (gregs == NULL)
{
- gregs = xmalloc (sizeof (*gregs));
+ gregs = XNEW (struct mmix_symbol_gregs);
gregs->n_gregs = 0;
symbol_set_tc (sym, &gregs);
all_greg_symbols[n_greg_symbols++] = gregs;
diff --git a/gas/config/tc-mn10200.c b/gas/config/tc-mn10200.c
index 2cdfa68..1831b9f 100644
--- a/gas/config/tc-mn10200.c
+++ b/gas/config/tc-mn10200.c
@@ -748,7 +748,7 @@ arelent *
tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
if (fixp->fx_subsy != NULL)
{
@@ -781,7 +781,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
return NULL;
}
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->addend = fixp->fx_offset;
return reloc;
diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c
index 9a5d3be..52c37e1 100644
--- a/gas/config/tc-mn10300.c
+++ b/gas/config/tc-mn10300.c
@@ -2168,7 +2168,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
static arelent * relocs[MAX_RELOC_EXPANSION + 1];
arelent *reloc;
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
if (reloc->howto == NULL)
@@ -2204,7 +2204,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
even local symbols defined in the same section. */
if (ssec != absolute_section || asec != absolute_section)
{
- arelent * reloc2 = xmalloc (sizeof * reloc);
+ arelent * reloc2 = XNEW (arelent);
relocs[0] = reloc2;
relocs[1] = reloc;
@@ -2212,7 +2212,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
reloc2->address = reloc->address;
reloc2->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_MN10300_SYM_DIFF);
reloc2->addend = - S_GET_VALUE (fixp->fx_subsy);
- reloc2->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc2->sym_ptr_ptr = XNEW (asymbol *);
*reloc2->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
reloc->addend = fixp->fx_offset;
@@ -2223,7 +2223,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
}
else
{
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
}
@@ -2268,7 +2268,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
}
else
{
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->addend = fixp->fx_offset;
}
diff --git a/gas/config/tc-moxie.c b/gas/config/tc-moxie.c
index 24c9aec..9201cb5 100644
--- a/gas/config/tc-moxie.c
+++ b/gas/config/tc-moxie.c
@@ -771,9 +771,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
return 0;
}
- relP = xmalloc (sizeof (arelent));
- gas_assert (relP != 0);
- relP->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ relP = XNEW (arelent);
+ relP->sym_ptr_ptr = XNEW (asymbol *);
*relP->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index 3621fdb..817ab45 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -4164,7 +4164,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
static arelent * relocs[MAX_RELOC_EXPANSION + 1];
arelent *reloc;
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
@@ -4215,7 +4215,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
&& ! S_IS_GAS_LOCAL (fixp->fx_addsy)
&& ! S_IS_GAS_LOCAL (fixp->fx_subsy))
{
- arelent * reloc2 = xmalloc (sizeof * reloc);
+ arelent * reloc2 = XNEW (arelent);
relocs[0] = reloc2;
relocs[1] = reloc;
@@ -4229,7 +4229,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
reloc2->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
else
{
- reloc2->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc2->sym_ptr_ptr = XNEW (asymbol *);
*reloc2->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
}
@@ -4241,7 +4241,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
}
else
{
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
}
@@ -4298,7 +4298,7 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
return & no_relocs;
}
#endif
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->addend = fixp->fx_offset;
diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c
index 897561d..4e65616 100644
--- a/gas/config/tc-nds32.c
+++ b/gas/config/tc-nds32.c
@@ -4123,7 +4123,7 @@ nds32_elf_save_pseudo_pattern (fixS* fixP, struct nds32_opcode *opcode,
fragS *fragP)
{
if (!reloc_ptr)
- reloc_ptr = malloc (sizeof (struct nds32_relocs_pattern));
+ reloc_ptr = XNEW (struct nds32_relocs_pattern);
reloc_ptr->seg = now_seg;
reloc_ptr->sym = sym;
reloc_ptr->frag = fragP;
diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c
index 0af829f..86a1de7 100644
--- a/gas/config/tc-ns32k.c
+++ b/gas/config/tc-ns32k.c
@@ -1908,7 +1908,7 @@ md_begin (void)
}
/* Some private space please! */
- freeptr_static = (char *) malloc (PRIVATE_SIZE);
+ freeptr_static = XNEWVEC (char, PRIVATE_SIZE);
}
/* Turn the string pointed to by litP into a floating point constant
@@ -2228,8 +2228,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
code = reloc (fixp->fx_size, fixp->fx_pcrel, fix_im_disp (fixp));
- rel = xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
if (fixp->fx_pcrel)
diff --git a/gas/config/tc-or1k.c b/gas/config/tc-or1k.c
index 10fd2de..383c613 100644
--- a/gas/config/tc-or1k.c
+++ b/gas/config/tc-or1k.c
@@ -303,9 +303,9 @@ tc_gen_reloc (asection * section, fixS * fixp)
arelent *reloc;
bfd_reloc_code_real_type code;
- reloc = xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-pdp11.c b/gas/config/tc-pdp11.c
index 529df4f..f6cf025 100644
--- a/gas/config/tc-pdp11.c
+++ b/gas/config/tc-pdp11.c
@@ -1384,9 +1384,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
arelent *reloc;
bfd_reloc_code_real_type code;
- reloc = xmalloc (sizeof (* reloc));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-pj.c b/gas/config/tc-pj.c
index 6a947fa..37fd481 100644
--- a/gas/config/tc-pj.c
+++ b/gas/config/tc-pj.c
@@ -171,7 +171,7 @@ static void
fake_opcode (const char *name,
void (*func) (struct pj_opc_info_t *, char *))
{
- pj_opc_info_t * fake = xmalloc (sizeof (pj_opc_info_t));
+ pj_opc_info_t * fake = XNEW (pj_opc_info_t);
fake->opcode = -1;
fake->opcode_next = -1;
@@ -472,8 +472,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
arelent *rel;
bfd_reloc_code_real_type r_type;
- rel = xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 23a84a7..1d2c57f 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -2569,14 +2569,13 @@ ppc_apuinfo_section_add (unsigned int apu, unsigned int version)
if (ppc_apuinfo_num_alloc == 0)
{
ppc_apuinfo_num_alloc = 4;
- ppc_apuinfo_list = (unsigned long *)
- xmalloc (sizeof (unsigned long) * ppc_apuinfo_num_alloc);
+ ppc_apuinfo_list = XNEWVEC (unsigned long, ppc_apuinfo_num_alloc);
}
else
{
ppc_apuinfo_num_alloc += 4;
- ppc_apuinfo_list = (unsigned long *) xrealloc (ppc_apuinfo_list,
- sizeof (unsigned long) * ppc_apuinfo_num_alloc);
+ ppc_apuinfo_list = XRESIZEVEC (unsigned long, ppc_apuinfo_list,
+ ppc_apuinfo_num_alloc);
}
}
ppc_apuinfo_list[ppc_apuinfo_num++] = APUID (apu, version);
@@ -3519,7 +3518,7 @@ ppc_macro (char *str, const struct powerpc_macro *macro)
}
/* Put the string together. */
- complete = s = (char *) xmalloc (len + 1);
+ complete = s = XNEWVEC (char, len + 1);
format = macro->format;
while (*format != '\0')
{
@@ -4010,8 +4009,7 @@ ppc_dwsect (int ignore ATTRIBUTE_UNUSED)
else
{
/* Create a new dw subsection. */
- subseg = (struct dw_subsection *)
- xmalloc (sizeof (struct dw_subsection));
+ subseg = XNEW (struct dw_subsection);
if (opt_label == NULL)
{
@@ -4964,7 +4962,7 @@ ppc_machine (int ignore ATTRIBUTE_UNUSED)
if (strcmp (cpu_string, "push") == 0)
{
if (cpu_history == NULL)
- cpu_history = xmalloc (MAX_HISTORY * sizeof (*cpu_history));
+ cpu_history = XNEWVEC (ppc_cpu_t, MAX_HISTORY);
if (curr_hist >= MAX_HISTORY)
as_bad (_(".machine stack overflow"));
@@ -7133,9 +7131,9 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
diff --git a/gas/config/tc-rl78.c b/gas/config/tc-rl78.c
index 0ecdb15..0739d34 100644
--- a/gas/config/tc-rl78.c
+++ b/gas/config/tc-rl78.c
@@ -502,7 +502,7 @@ rl78_frag_init (fragS * fragP)
{
if (rl78_bytes.n_relax || rl78_bytes.link_relax)
{
- fragP->tc_frag_data = malloc (sizeof (rl78_bytesT));
+ fragP->tc_frag_data = XNEW (rl78_bytesT);
memcpy (fragP->tc_frag_data, & rl78_bytes, sizeof (rl78_bytesT));
}
else
diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c
index 435d046..e0af5b5 100644
--- a/gas/config/tc-rx.c
+++ b/gas/config/tc-rx.c
@@ -1031,7 +1031,7 @@ rx_frag_init (fragS * fragP)
{
if (rx_bytes.n_relax || rx_bytes.link_relax || rx_bytes.n_base < 0)
{
- fragP->tc_frag_data = malloc (sizeof (rx_bytesT));
+ fragP->tc_frag_data = XNEW (rx_bytesT);
memcpy (fragP->tc_frag_data, & rx_bytes, sizeof (rx_bytesT));
}
else
@@ -2443,8 +2443,8 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
fixp->fx_subsy = NULL;
}
- reloc[0] = (arelent *) xmalloc (sizeof (arelent));
- reloc[0]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc[0] = XNEW (arelent);
+ reloc[0]->sym_ptr_ptr = XNEW (asymbol *);
* reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc[0]->addend = fixp->fx_offset;
@@ -2466,20 +2466,20 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
case BFD_RELOC_RX_DIFF:
reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[1] = (arelent *) xmalloc (sizeof (arelent));
- reloc[1]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc[1] = XNEW (arelent);
+ reloc[1]->sym_ptr_ptr = XNEW (asymbol *);
* reloc[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);
reloc[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc[1]->addend = 0;
reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[2] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[2] = XNEW (arelent);
reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
reloc[2]->addend = 0;
reloc[2]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
- reloc[3] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[3] = XNEW (arelent);
switch (fixp->fx_size)
{
case 1:
@@ -2510,8 +2510,8 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
case BFD_RELOC_RX_GPRELL:
reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[1] = (arelent *) xmalloc (sizeof (arelent));
- reloc[1]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc[1] = XNEW (arelent);
+ reloc[1]->sym_ptr_ptr = XNEW (asymbol *);
if (gp_symbol == NULL)
{
if (symbol_table_frozen)
@@ -2532,13 +2532,13 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
reloc[1]->addend = 0;
reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[2] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[2] = XNEW (arelent);
reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
reloc[2]->addend = 0;
reloc[2]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
- reloc[3] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[3] = XNEW (arelent);
reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16UL);
reloc[3]->addend = 0;
reloc[3]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
@@ -2550,8 +2550,8 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
case BFD_RELOC_RX_GPRELW:
reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[1] = (arelent *) xmalloc (sizeof (arelent));
- reloc[1]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc[1] = XNEW (arelent);
+ reloc[1]->sym_ptr_ptr = XNEW (asymbol *);
if (gp_symbol == NULL)
{
if (symbol_table_frozen)
@@ -2572,13 +2572,13 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
reloc[1]->addend = 0;
reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[2] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[2] = XNEW (arelent);
reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
reloc[2]->addend = 0;
reloc[2]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
- reloc[3] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[3] = XNEW (arelent);
reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16UW);
reloc[3]->addend = 0;
reloc[3]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
@@ -2590,8 +2590,8 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
case BFD_RELOC_RX_GPRELB:
reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[1] = (arelent *) xmalloc (sizeof (arelent));
- reloc[1]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc[1] = XNEW (arelent);
+ reloc[1]->sym_ptr_ptr = XNEW (asymbol *);
if (gp_symbol == NULL)
{
if (symbol_table_frozen)
@@ -2612,13 +2612,13 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
reloc[1]->addend = 0;
reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[2] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[2] = XNEW (arelent);
reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_SUBTRACT);
reloc[2]->addend = 0;
reloc[2]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
reloc[2]->address = fixp->fx_frag->fr_address + fixp->fx_where;
- reloc[3] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[3] = XNEW (arelent);
reloc[3]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS16U);
reloc[3]->addend = 0;
reloc[3]->sym_ptr_ptr = reloc[1]->sym_ptr_ptr;
@@ -2630,13 +2630,13 @@ tc_gen_reloc (asection * sec ATTRIBUTE_UNUSED, fixS * fixp)
case BFD_RELOC_RX_NEG32:
reloc[0]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_SYM);
- reloc[1] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[1] = XNEW (arelent);
reloc[1]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_OP_NEG);
reloc[1]->addend = 0;
reloc[1]->sym_ptr_ptr = reloc[0]->sym_ptr_ptr;
reloc[1]->address = fixp->fx_frag->fr_address + fixp->fx_where;
- reloc[2] = (arelent *) xmalloc (sizeof (arelent));
+ reloc[2] = XNEW (arelent);
reloc[2]->howto = bfd_reloc_type_lookup (stdoutput, BFD_RELOC_RX_ABS32);
reloc[2]->addend = 0;
reloc[2]->sym_ptr_ptr = reloc[0]->sym_ptr_ptr;
diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index e2677f7..098debc 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -1032,7 +1032,7 @@ s390_lit_suffix (char **str_p, expressionS *exp_p, elf_suffix_type suffix)
}
else
{
- lpe = (struct s390_lpe *) xmalloc (sizeof (struct s390_lpe));
+ lpe = XNEW (struct s390_lpe);
}
lpe->ex = *exp_p;
@@ -1879,7 +1879,7 @@ static void
s390_machine (int ignore ATTRIBUTE_UNUSED)
{
char *cpu_string;
- static struct
+ static struct cpu_history
{
unsigned int cpu;
unsigned int flags;
@@ -1923,7 +1923,7 @@ s390_machine (int ignore ATTRIBUTE_UNUSED)
if (strcmp (cpu_string, "push") == 0)
{
if (cpu_history == NULL)
- cpu_history = xmalloc (MAX_HISTORY * sizeof (*cpu_history));
+ cpu_history = XNEWVEC (struct cpu_history, MAX_HISTORY);
if (curr_hist >= MAX_HISTORY)
as_bad (_(".machine stack overflow"));
@@ -1995,7 +1995,7 @@ s390_machinemode (int ignore ATTRIBUTE_UNUSED)
if (strcmp (mode_string, "push") == 0)
{
if (mode_history == NULL)
- mode_history = xmalloc (MAX_HISTORY * sizeof (*mode_history));
+ mode_history = XNEWVEC (unsigned int, MAX_HISTORY);
if (curr_hist >= MAX_HISTORY)
as_bad (_(".machinemode stack overflow"));
@@ -2548,8 +2548,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
code = BFD_RELOC_390_GOTPCDBL;
}
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
diff --git a/gas/config/tc-score.c b/gas/config/tc-score.c
index 8ea1084..8f74caf 100644
--- a/gas/config/tc-score.c
+++ b/gas/config/tc-score.c
@@ -6273,8 +6273,8 @@ s3_insert_reg (const struct s3_reg_entry *r, struct hash_control *htab)
{
int i = 0;
int len = strlen (r->name) + 2;
- char *buf = xmalloc (len);
- char *buf2 = xmalloc (len);
+ char *buf = XNEWVEC (char, len);
+ char *buf2 = XNEWVEC (char, len);
strcpy (buf + i, r->name);
for (i = 0; buf[i]; i++)
@@ -7400,10 +7400,10 @@ s3_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
bfd_reloc_code_real_type code;
char *type;
- reloc = retval[0] = xmalloc (sizeof (arelent));
+ reloc = retval[0] = XNEW (arelent);
retval[1] = NULL;
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->addend = fixp->fx_offset;
@@ -7431,9 +7431,9 @@ s3_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
newval |= (((off >> 14) & 0x3) << 16);
s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);
- retval[1] = xmalloc (sizeof (arelent));
+ retval[1] = XNEW (arelent);
retval[2] = NULL;
- retval[1]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ retval[1]->sym_ptr_ptr = XNEW (asymbol *);
*retval[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
retval[1]->address = (reloc->address + s3_RELAX_RELOC2 (fixp->fx_frag->fr_subtype));
diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c
index 97dfea2..8ec0fb0 100644
--- a/gas/config/tc-score7.c
+++ b/gas/config/tc-score7.c
@@ -5353,8 +5353,8 @@ s7_insert_reg (const struct s7_reg_entry *r, struct hash_control *htab)
{
int i = 0;
int len = strlen (r->name) + 2;
- char *buf = xmalloc (len);
- char *buf2 = xmalloc (len);
+ char *buf = XNEWVEC (char, len);
+ char *buf2 = XNEWVEC (char, len);
strcpy (buf + i, r->name);
for (i = 0; buf[i]; i++)
@@ -6877,10 +6877,10 @@ s7_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
bfd_reloc_code_real_type code;
char *type;
- reloc = retval[0] = xmalloc (sizeof (arelent));
+ reloc = retval[0] = XNEW (arelent);
retval[1] = NULL;
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->addend = fixp->fx_offset;
@@ -6908,9 +6908,9 @@ s7_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
newval |= (((off >> 14) & 0x3) << 16);
s7_number_to_chars (buf, newval, s7_INSN_SIZE);
- retval[1] = xmalloc (sizeof (arelent));
+ retval[1] = XNEW (arelent);
retval[2] = NULL;
- retval[1]->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ retval[1]->sym_ptr_ptr = XNEW (asymbol *);
*retval[1]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
retval[1]->address = (reloc->address + s7_RELAX_RELOC2 (fixp->fx_frag->fr_subtype));
diff --git a/gas/config/tc-tic30.c b/gas/config/tc-tic30.c
index 10653ed..725691c 100644
--- a/gas/config/tc-tic30.c
+++ b/gas/config/tc-tic30.c
@@ -402,8 +402,7 @@ tic30_operand (char *token)
operand *current_op;
debug ("In tic30_operand with %s\n", token);
- current_op = malloc (sizeof (* current_op));
- memset (current_op, '\0', sizeof (operand));
+ current_op = XCNEW (operand);
if (*token == DIRECT_REFERENCE)
{
@@ -464,7 +463,7 @@ tic30_operand (char *token)
ind_addr_type *ind_addr_op;
char * ind_buffer;
- ind_buffer = xmalloc (strlen (token));
+ ind_buffer = XNEWVEC (char, strlen (token));
debug ("Found indirect reference\n");
ind_buffer[0] = *token;
@@ -1391,9 +1390,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
#undef MAP
#undef F
- rel = xmalloc (sizeof (* rel));
+ rel = XNEW (arelent);
gas_assert (rel != 0);
- rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
rel->address = fixP->fx_frag->fr_address + fixP->fx_where;
rel->addend = 0;
diff --git a/gas/config/tc-tic4x.c b/gas/config/tc-tic4x.c
index ba0aa38..97f830c 100644
--- a/gas/config/tc-tic4x.c
+++ b/gas/config/tc-tic4x.c
@@ -1241,10 +1241,9 @@ tic4x_inst_make (const char *name, unsigned long opcode, const char *args)
if (insts == NULL)
{
/* Allocate memory to store name strings. */
- names = (char *) xmalloc (sizeof (char) * 8192);
+ names = XNEWVEC (char, 8192);
/* Allocate memory for additional insts. */
- insts = (tic4x_inst_t *)
- xmalloc (sizeof (tic4x_inst_t) * 1024);
+ insts = XNEWVEC (tic4x_inst_t, 1024);
}
insts[iindex].name = names;
insts[iindex].opcode = opcode;
@@ -3011,9 +3010,9 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixP)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
+ reloc = XNEW (arelent);
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
reloc->address /= OCTETS_PER_BYTE;
diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c
index 8c33df4..5dd772e 100644
--- a/gas/config/tc-tic54x.c
+++ b/gas/config/tc-tic54x.c
@@ -593,9 +593,8 @@ stag_add_field (struct stag *parent,
bfd_vma offset,
struct stag *stag)
{
- struct stag_field *sfield = xmalloc (sizeof (struct stag_field));
+ struct stag_field *sfield = XCNEW (struct stag_field);
- memset (sfield, 0, sizeof (*sfield));
sfield->name = xstrdup (name);
sfield->offset = offset;
sfield->bitfield_offset = parent->current_bitfield_offset;
@@ -656,8 +655,7 @@ tic54x_struct (int arg)
if (current_stag)
{
/* Nesting, link to outer one. */
- current_stag->inner = (struct stag *) xmalloc (sizeof (struct stag));
- memset (current_stag->inner, 0, sizeof (struct stag));
+ current_stag->inner = XCNEW (struct stag);
current_stag->inner->outer = current_stag;
current_stag = current_stag->inner;
if (start_offset)
@@ -666,8 +664,7 @@ tic54x_struct (int arg)
}
else
{
- current_stag = (struct stag *) xmalloc (sizeof (struct stag));
- memset (current_stag, 0, sizeof (struct stag));
+ current_stag = XCNEW (struct stag);
abs_section_offset = start_offset;
}
current_stag->is_union = is_union;
@@ -1236,7 +1233,7 @@ tic54x_space (int arg)
partial allocation has not been completed yet. */
if (expn.X_op != O_constant || frag_bit_offset (frag_now, now_seg) == -1)
{
- struct bit_info *bi = xmalloc (sizeof (struct bit_info));
+ struct bit_info *bi = XNEW (struct bit_info);
bi->seg = now_seg;
bi->type = bes;
@@ -1744,7 +1741,7 @@ tic54x_field (int ignore ATTRIBUTE_UNUSED)
fragS *alloc_frag = bit_offset_frag (frag_now, now_seg);
if (bit_offset == -1)
{
- struct bit_info *bi = xmalloc (sizeof (struct bit_info));
+ struct bit_info *bi = XNEW (struct bit_info);
/* We don't know the previous offset at this time, so store the
info we need and figure it out later. */
expressionS size_exp;
@@ -2299,7 +2296,7 @@ tic54x_mlib (int ignore ATTRIBUTE_UNUSED)
demand_empty_rest_of_line ();
tic54x_set_default_include (0);
- path = xmalloc ((unsigned long) len + include_dir_maxlen + 5);
+ path = XNEWVEC (char, (unsigned long) len + include_dir_maxlen + 5);
for (i = 0; i < include_dir_count; i++)
{
@@ -2348,7 +2345,7 @@ tic54x_mlib (int ignore ATTRIBUTE_UNUSED)
{
/* Get a size at least as big as the archive member. */
bfd_size_type size = bfd_get_size (mbfd);
- char *buf = xmalloc (size);
+ char *buf = XNEWVEC (char, size);
char *fname = tmpnam (NULL);
FILE *ftmp;
@@ -4563,7 +4560,7 @@ subsym_substitute (char *line, int forced)
farg2 = (float) strtod (ptr, &ptr);
}
fresult = (*math_entry->proc) (farg1, farg2);
- value = xmalloc (128);
+ value = XNEWVEC (char, 128);
if (math_entry->int_return)
sprintf (value, "%d", (int) fresult);
else
@@ -4624,7 +4621,7 @@ subsym_substitute (char *line, int forced)
break;
}
val = (*entry->proc) (arg1, arg2);
- value = xmalloc (64);
+ value = XNEWVEC (char, 64);
sprintf (value, "%d", val);
}
/* Fix things up to replace the entire expression, not just the
@@ -5077,8 +5074,8 @@ tc_gen_reloc (asection *section, fixS *fixP)
bfd_reloc_code_real_type code = fixP->fx_r_type;
asymbol *sym = symbol_get_bfdsym (fixP->fx_addsy);
- rel = (arelent *) xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = sym;
/* We assume that all rel->address are host byte offsets. */
rel->address = fixP->fx_frag->fr_address + fixP->fx_where;
diff --git a/gas/config/tc-tic6x.c b/gas/config/tc-tic6x.c
index 2135dbf..ebeafc3 100644
--- a/gas/config/tc-tic6x.c
+++ b/gas/config/tc-tic6x.c
@@ -761,7 +761,7 @@ md_begin (void)
for (id = 0; id < tic6x_opcode_max; id++)
{
const char *errmsg;
- tic6x_opcode_list *opc = xmalloc (sizeof (tic6x_opcode_list));
+ tic6x_opcode_list *opc = XNEW (tic6x_opcode_list);
opc->id = id;
opc->next = hash_find (opcode_hash, tic6x_opcode_table[id].name);
@@ -948,7 +948,7 @@ tic6x_frob_label (symbolS *sym)
si = seg_info (now_seg);
list = si->tc_segment_info_data.label_list;
- si->tc_segment_info_data.label_list = xmalloc (sizeof (tic6x_label_list));
+ si->tc_segment_info_data.label_list = XNEW (tic6x_label_list);
si->tc_segment_info_data.label_list->next = list;
si->tc_segment_info_data.label_list->label = sym;
@@ -3253,7 +3253,7 @@ md_assemble (char *str)
for (opc = opc_list; opc; opc = opc->next)
max_matching_opcodes++;
num_matching_opcodes = 0;
- opcm = xmalloc (max_matching_opcodes * sizeof (*opcm));
+ opcm = XNEWVEC (tic6x_opcode_id, max_matching_opcodes);
max_num_operands = 0;
ok_this_arch = FALSE;
ok_this_fu = FALSE;
@@ -4505,8 +4505,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
asymbol *symbol;
bfd_reloc_code_real_type r_type;
- reloc = xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
symbol = symbol_get_bfdsym (fixp->fx_addsy);
*reloc->sym_ptr_ptr = symbol;
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c
index 538a994..33ef6e3 100644
--- a/gas/config/tc-vax.c
+++ b/gas/config/tc-vax.c
@@ -2388,8 +2388,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
#undef F
#undef MAP
- reloc = xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
#ifndef OBJ_ELF
diff --git a/gas/config/tc-xc16x.c b/gas/config/tc-xc16x.c
index 1fb964b..49c0970 100644
--- a/gas/config/tc-xc16x.c
+++ b/gas/config/tc-xc16x.c
@@ -294,8 +294,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
}
}
- rel = xmalloc (sizeof (arelent));
- rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ rel = XNEW (arelent);
+ rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where;
rel->addend = fixp->fx_offset;
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index c006418..167a209 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -1067,7 +1067,7 @@ xtensa_add_insn_label (symbolS *sym)
sym_list *l;
if (!free_insn_labels)
- l = (sym_list *) xmalloc (sizeof (sym_list));
+ l = XNEW (sym_list);
else
{
l = free_insn_labels;
@@ -1167,7 +1167,7 @@ directive_push (directiveE directive, bfd_boolean negated, const void *datum)
{
const char *file;
unsigned int line;
- state_stackS *stack = (state_stackS *) xmalloc (sizeof (state_stackS));
+ state_stackS *stack = XNEW (state_stackS);
file = as_where (&line);
@@ -1323,7 +1323,7 @@ xtensa_begin_directive (int ignore ATTRIBUTE_UNUSED)
insn_labels = NULL;
}
as_warn (_(".begin literal is deprecated; use .literal instead"));
- state = (emit_state *) xmalloc (sizeof (emit_state));
+ state = XNEW (emit_state);
xtensa_switch_to_literal_fragment (state);
directive_push (directive_literal, negated, state);
break;
@@ -1342,7 +1342,7 @@ xtensa_begin_directive (int ignore ATTRIBUTE_UNUSED)
/* Allocate the literal state for this section and push
onto the directive stack. */
- ls = xmalloc (sizeof (lit_state));
+ ls = XNEW (lit_state);
gas_assert (ls);
*ls = default_lit_sections;
@@ -2026,7 +2026,7 @@ tokenize_arguments (char **args, char *str)
arg_end += 1;
arg_len = arg_end - input_line_pointer;
- arg = (char *) xmalloc ((saw_colon ? 1 : 0) + arg_len + 1);
+ arg = XNEWVEC (char, (saw_colon ? 1 : 0) + arg_len + 1);
args[num_args] = arg;
if (saw_colon)
@@ -4125,7 +4125,7 @@ xtensa_add_literal_sym (symbolS *sym)
{
sym_list *l;
- l = (sym_list *) xmalloc (sizeof (sym_list));
+ l = XNEW (sym_list);
l->sym = sym;
l->next = literal_syms;
literal_syms = l;
@@ -6095,8 +6095,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
{
arelent *reloc;
- reloc = (arelent *) xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
@@ -6141,7 +6141,7 @@ new_resource_table (void *data,
opcode_funcUnit_use_stage_func ousf)
{
int i;
- resource_table *rt = (resource_table *) xmalloc (sizeof (resource_table));
+ resource_table *rt = XNEW (resource_table);
rt->data = data;
rt->cycles = cycles;
rt->allocated_cycles = cycles;
@@ -6183,11 +6183,9 @@ resize_resource_table (resource_table *rt, int cycles)
old_cycles = rt->allocated_cycles;
rt->allocated_cycles = cycles;
- rt->units = xrealloc (rt->units,
- rt->allocated_cycles * sizeof (unsigned char *));
+ rt->units = XRESIZEVEC (unsigned char *, rt->units, rt->allocated_cycles);
for (i = 0; i < old_cycles; i++)
- rt->units[i] = xrealloc (rt->units[i],
- rt->num_units * sizeof (unsigned char));
+ rt->units[i] = XRESIZEVEC (unsigned char, rt->units[i], rt->num_units);
for (i = old_cycles; i < cycles; i++)
rt->units[i] = xcalloc (rt->num_units, sizeof (unsigned char));
}
@@ -6967,7 +6965,7 @@ emit_single_op (TInsn *orig_insn)
case ITYPE_LABEL:
{
static int relaxed_sym_idx = 0;
- char *label = xmalloc (strlen (FAKE_LABEL_NAME) + 12);
+ char *label = XNEWVEC (char, strlen (FAKE_LABEL_NAME) + 12);
sprintf (label, "%s_rl_%x", FAKE_LABEL_NAME, relaxed_sym_idx++);
colon (label);
gas_assert (label_sym == NULL);
@@ -7456,7 +7454,7 @@ xtensa_create_trampoline_frag (bfd_boolean needs_jump_around)
trampoline_buf = xtensa_insnbuf_alloc (xtensa_default_isa);
trampoline_slotbuf = xtensa_insnbuf_alloc (xtensa_default_isa);
}
- tf = (struct trampoline_frag *)xmalloc(sizeof (struct trampoline_frag));
+ tf = XNEW(struct trampoline_frag);
tf->next = ts->trampoline_list.next;
ts->trampoline_list.next = tf;
tf->needs_jump_around = needs_jump_around;
@@ -7621,7 +7619,7 @@ xtensa_maybe_create_literal_pool_frag (bfd_boolean create,
fragP = frag_now;
}
- lpf = (struct litpool_frag *)xmalloc(sizeof (struct litpool_frag));
+ lpf = XNEW(struct litpool_frag);
/* Insert at tail of circular list. */
lpf->addr = 0;
lps->frag_list.prev->next = lpf;
@@ -8638,7 +8636,7 @@ xtensa_add_config_info (void)
info_sec = subseg_new (".xtensa.info", 0);
bfd_set_section_flags (stdoutput, info_sec, SEC_HAS_CONTENTS | SEC_READONLY);
- data = xmalloc (100);
+ data = XNEWVEC (char, 100);
sprintf (data, "USE_ABSOLUTE_LITERALS=%d\nABI=%d\n",
XSHAL_USE_ABSOLUTE_LITERALS, XSHAL_ABI);
sz = strlen (data) + 1;
@@ -9092,8 +9090,7 @@ static void xtensa_realloc_fixup_cache (fixup_cacheS *cache, unsigned add)
if (cache->n_fixups + add > cache->n_max)
{
cache->n_max = (cache->n_fixups + add) * 2;
- cache->fixups = xrealloc (cache->fixups,
- sizeof (*cache->fixups) * cache->n_max);
+ cache->fixups = XRESIZEVEC (cached_fixupS, cache->fixups, cache->n_max);
}
}
@@ -10942,7 +10939,7 @@ get_subseg_info (segT seg, subsegT subseg)
static subseg_map *
add_subseg_info (segT seg, subsegT subseg)
{
- subseg_map *subseg_e = (subseg_map *) xmalloc (sizeof (subseg_map));
+ subseg_map *subseg_e = XNEW (subseg_map);
memset (subseg_e, 0, sizeof (subseg_map));
subseg_e->seg = seg;
subseg_e->subseg = subseg;
@@ -11600,7 +11597,7 @@ cache_literal_section (bfd_boolean use_abs_literals)
if (! use_abs_literals)
{
/* Add the newly created literal segment to the list. */
- seg_list *n = (seg_list *) xmalloc (sizeof (seg_list));
+ seg_list *n = XNEW (seg_list);
n->seg = seg;
n->next = literal_head->next;
literal_head->next = n;
@@ -11977,8 +11974,7 @@ add_xt_block_frags (segT sec,
}
if (*xt_block == NULL)
{
- xtensa_block_info *new_block = (xtensa_block_info *)
- xmalloc (sizeof (xtensa_block_info));
+ xtensa_block_info *new_block = XNEW (xtensa_block_info);
new_block->sec = sec;
new_block->offset = fragP->fr_address;
new_block->size = fragP->fr_fix;
@@ -12235,8 +12231,7 @@ add_xt_prop_frags (segT sec,
xtensa_block_info *new_block;
if ((*xt_block) != NULL)
xt_block = &(*xt_block)->next;
- new_block = (xtensa_block_info *)
- xmalloc (sizeof (xtensa_block_info));
+ new_block = XNEW (xtensa_block_info);
*new_block = tmp_block;
*xt_block = new_block;
}
@@ -12261,8 +12256,7 @@ init_op_placement_info_table (void)
int slot;
int num_opcodes = xtensa_isa_num_opcodes (isa);
- op_placement_table = (op_placement_info_table)
- xmalloc (sizeof (op_placement_info) * num_opcodes);
+ op_placement_table = XNEWVEC (op_placement_info, num_opcodes);
gas_assert (xtensa_isa_num_formats (isa) < MAX_FORMATS);
for (opcode = 0; opcode < num_opcodes; opcode++)
@@ -13166,8 +13160,7 @@ build_section_rename (const char *arg)
}
/* Now add it. */
- r = (struct rename_section_struct *)
- xmalloc (sizeof (struct rename_section_struct));
+ r = XNEW (struct rename_section_struct);
r->old_name = xstrdup (old_name);
r->new_name = xstrdup (new_name);
r->next = section_rename;
diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c
index 7b1e72a..dcc74f6 100644
--- a/gas/config/tc-z80.c
+++ b/gas/config/tc-z80.c
@@ -2058,8 +2058,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED , fixS *fixp)
return NULL;
}
- reloc = xmalloc (sizeof (arelent));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
diff --git a/gas/config/tc-z8k.c b/gas/config/tc-z8k.c
index 6a0d596..265adc6 100644
--- a/gas/config/tc-z8k.c
+++ b/gas/config/tc-z8k.c
@@ -162,7 +162,7 @@ md_begin (void)
for (idx = 0; md_pseudo_table[idx].poc_name; idx++)
{
opcode_entry_type *fake_opcode;
- fake_opcode = (opcode_entry_type *) malloc (sizeof (opcode_entry_type));
+ fake_opcode = XNEW (opcode_entry_type);
fake_opcode->name = md_pseudo_table[idx].poc_name;
fake_opcode->func = (void *) (md_pseudo_table + idx);
fake_opcode->opcode = 250;
@@ -1357,8 +1357,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
{
arelent *reloc;
- reloc = xmalloc (sizeof (*reloc));
- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
+ reloc = XNEW (arelent);
+ reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->addend = fixp->fx_offset;
diff --git a/gas/depend.c b/gas/depend.c
index 2dd35a4..7203e59 100644
--- a/gas/depend.c
+++ b/gas/depend.c
@@ -67,7 +67,7 @@ register_dependency (const char *filename)
return;
}
- dep = (struct dependency *) xmalloc (sizeof (struct dependency));
+ dep = XNEW (struct dependency);
dep->file = xstrdup (filename);
dep->next = dep_chain;
dep_chain = dep;
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index c719a5a..27b2646 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -253,7 +253,7 @@ get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p)
if (!create_p)
return NULL;
- s = (struct line_seg *) xmalloc (sizeof (*s));
+ s = XNEW (struct line_seg);
s->next = NULL;
s->seg = seg;
s->head = NULL;
@@ -271,7 +271,7 @@ get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p)
break;
}
- lss = (struct line_subseg *) xmalloc (sizeof (*lss));
+ lss = XNEW (struct line_subseg);
lss->next = *pss;
lss->subseg = subseg;
lss->head = NULL;
@@ -291,7 +291,7 @@ dwarf2_gen_line_info_1 (symbolS *label, struct dwarf2_line_info *loc)
struct line_subseg *lss;
struct line_entry *e;
- e = (struct line_entry *) xmalloc (sizeof (*e));
+ e = XNEW (struct line_entry);
e->next = NULL;
e->label = label;
e->loc = *loc;
@@ -512,8 +512,7 @@ get_filenum (const char *filename, unsigned int num)
if (dir >= dirs_allocated)
{
dirs_allocated = dir + 32;
- dirs = (char **)
- xrealloc (dirs, (dir + 32) * sizeof (const char *));
+ dirs = XRESIZEVEC (char *, dirs, dirs_allocated);
}
dirs[dir] = (char *) xmalloc (dir_len + 1);
@@ -543,8 +542,7 @@ get_filenum (const char *filename, unsigned int num)
unsigned int old = files_allocated;
files_allocated = i + 32;
- files = (struct file_entry *)
- xrealloc (files, (i + 32) * sizeof (struct file_entry));
+ files = XRESIZEVEC (struct file_entry, files, files_allocated);
memset (files + old, 0, (i + 32 - old) * sizeof (struct file_entry));
}
diff --git a/gas/ecoff.c b/gas/ecoff.c
index 25c3d94..e7d7ab6 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -4850,7 +4850,7 @@ allocate_scope (void)
#else
- ptr = (scope_t *) xmalloc (sizeof (scope_t));
+ ptr = XNEW (scope_t);
#endif
@@ -4899,7 +4899,7 @@ allocate_vlinks (void)
#else
- ptr = (vlinks_t *) xmalloc (sizeof (vlinks_t));
+ ptr = XNEW (vlinks_t);
#endif
@@ -4933,7 +4933,7 @@ allocate_shash (void)
#else
- ptr = (shash_t *) xmalloc (sizeof (shash_t));
+ ptr = XNEW (shash_t);
#endif
@@ -4967,7 +4967,7 @@ allocate_thash (void)
#else
- ptr = (thash_t *) xmalloc (sizeof (thash_t));
+ ptr = XNEW (thash_t);
#endif
@@ -5007,7 +5007,7 @@ allocate_tag (void)
#else
- ptr = (tag_t *) xmalloc (sizeof (tag_t));
+ ptr = XNEW (tag_t);
#endif
@@ -5056,7 +5056,7 @@ allocate_forward (void)
#else
- ptr = (forward_t *) xmalloc (sizeof (forward_t));
+ ptr = XNEW (forward_t);
#endif
@@ -5096,7 +5096,7 @@ allocate_thead (void)
#else
- ptr = (thead_t *) xmalloc (sizeof (thead_t));
+ ptr = XNEW (thead_t);
#endif
@@ -5143,7 +5143,7 @@ allocate_lineno_list (void)
#else
- ptr = (lineno_list_t *) xmalloc (sizeof (lineno_list_t));
+ ptr = XNEW (lineno_list_t);
#endif
diff --git a/gas/expr.c b/gas/expr.c
index 777504f..66f041c 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -108,7 +108,7 @@ make_expr_symbol (expressionS *expressionP)
if (expressionP->X_op == O_constant)
resolve_symbol_value (symbolP);
- n = (struct expr_symbol_line *) xmalloc (sizeof *n);
+ n = XNEW (struct expr_symbol_line);
n->sym = symbolP;
n->file = as_where (&n->line);
n->next = expr_symbol_lines;
diff --git a/gas/hash.c b/gas/hash.c
index 09925f0..655ddfc 100644
--- a/gas/hash.c
+++ b/gas/hash.c
@@ -87,7 +87,7 @@ hash_new_sized (unsigned long size)
unsigned long alloc;
struct hash_control *ret;
- ret = (struct hash_control *) xmalloc (sizeof *ret);
+ ret = XNEW (struct hash_control);
obstack_begin (&ret->memory, chunksize);
alloc = size * sizeof (struct hash_entry *);
ret->table = (struct hash_entry **) obstack_alloc (&ret->memory, alloc);
diff --git a/gas/input-file.c b/gas/input-file.c
index a3dcd9d..8b9830f 100644
--- a/gas/input-file.c
+++ b/gas/input-file.c
@@ -81,7 +81,7 @@ input_file_push (void)
{
struct saved_file *saved;
- saved = (struct saved_file *) xmalloc (sizeof *saved);
+ saved = XNEW (struct saved_file);
saved->f_in = f_in;
saved->file_name = file_name;
diff --git a/gas/listing.c b/gas/listing.c
index 53e84ab..c90c575 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -276,7 +276,7 @@ file_info (const char *file_name)
}
/* Make new entry. */
- p = (file_info_type *) xmalloc (sizeof (file_info_type));
+ p = XNEW (file_info_type);
p->next = file_info_head;
file_info_head = p;
p->filename = xstrdup (file_name);
@@ -334,7 +334,7 @@ listing_newline (char *ps)
&& !(last_file && file && filename_cmp (file, last_file)))
return;
- new_i = (list_info_type *) xmalloc (sizeof (list_info_type));
+ new_i = XNEW (list_info_type);
/* Detect if we are reading from stdin by examining the file
name returned by as_where().
@@ -396,7 +396,7 @@ listing_newline (char *ps)
}
else
{
- new_i = (list_info_type *) xmalloc (sizeof (list_info_type));
+ new_i = XNEW (list_info_type);
new_i->line_contents = ps;
}
diff --git a/gas/macro.c b/gas/macro.c
index cddf26a..615bfda 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -471,7 +471,7 @@ new_formal (void)
{
formal_entry *formal;
- formal = (formal_entry *) xmalloc (sizeof (formal_entry));
+ formal = XNEW (formal_entry);
sb_new (&formal->name);
sb_new (&formal->def);
@@ -655,7 +655,7 @@ define_macro (size_t idx, sb *in, sb *label,
sb name;
const char *error = NULL;
- macro = (macro_entry *) xmalloc (sizeof (macro_entry));
+ macro = XNEW (macro_entry);
sb_new (¯o->sub);
sb_new (&name);
macro->file = file;
diff --git a/gas/remap.c b/gas/remap.c
index 87eda01..2af7a9e 100644
--- a/gas/remap.c
+++ b/gas/remap.c
@@ -53,7 +53,7 @@ add_debug_prefix_map (const char *arg)
as_fatal (_("invalid argument '%s' to -fdebug-prefix-map"), arg);
return;
}
- map = (struct debug_prefix_map *) xmalloc (sizeof (debug_prefix_map));
+ map = XNEW (debug_prefix_map);
o = xstrdup (arg);
map->old_prefix = o;
map->old_len = p - arg;
diff --git a/gas/symbols.c b/gas/symbols.c
index c69e400..642f6d7 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -762,7 +762,7 @@ symbol_find_noref (const char *name, int noref)
orig = name;
if (copy != NULL)
copy2 = copy;
- name = copy = xmalloc (strlen (name) + 1);
+ name = copy = XNEWVEC (char, strlen (name) + 1);
while ((c = *orig++) != '\0')
*copy++ = TOUPPER (c);
@@ -1634,8 +1634,8 @@ define_dollar_label (long label)
if (dollar_labels == NULL)
{
- dollar_labels = (long *) xmalloc (DOLLAR_LABEL_BUMP_BY * sizeof (long));
- dollar_label_instances = (long *) xmalloc (DOLLAR_LABEL_BUMP_BY * sizeof (long));
+ dollar_labels = XNEWVEC (long, DOLLAR_LABEL_BUMP_BY);
+ dollar_label_instances = XNEWVEC (long, DOLLAR_LABEL_BUMP_BY);
dollar_label_defines = (char *) xmalloc (DOLLAR_LABEL_BUMP_BY);
dollar_label_max = DOLLAR_LABEL_BUMP_BY;
dollar_label_count = 0;
@@ -1643,10 +1643,9 @@ define_dollar_label (long label)
else if (dollar_label_count == dollar_label_max)
{
dollar_label_max += DOLLAR_LABEL_BUMP_BY;
- dollar_labels = (long *) xrealloc ((char *) dollar_labels,
- dollar_label_max * sizeof (long));
- dollar_label_instances = (long *) xrealloc ((char *) dollar_label_instances,
- dollar_label_max * sizeof (long));
+ dollar_labels = XRESIZEVEC (long, dollar_labels, dollar_label_max);
+ dollar_label_instances = XRESIZEVEC (long, dollar_label_instances,
+ dollar_label_max);
dollar_label_defines = (char *) xrealloc (dollar_label_defines, dollar_label_max);
} /* if we needed to grow */
@@ -1776,8 +1775,8 @@ fb_label_instance_inc (long label)
if (fb_labels == NULL)
{
- fb_labels = (long *) xmalloc (FB_LABEL_BUMP_BY * sizeof (long));
- fb_label_instances = (long *) xmalloc (FB_LABEL_BUMP_BY * sizeof (long));
+ fb_labels = XNEWVEC (long, FB_LABEL_BUMP_BY);
+ fb_label_instances = XNEWVEC (long, FB_LABEL_BUMP_BY);
fb_label_max = FB_LABEL_BUMP_BY;
fb_label_count = FB_LABEL_SPECIAL;
@@ -1785,10 +1784,8 @@ fb_label_instance_inc (long label)
else if (fb_label_count == fb_label_max)
{
fb_label_max += FB_LABEL_BUMP_BY;
- fb_labels = (long *) xrealloc ((char *) fb_labels,
- fb_label_max * sizeof (long));
- fb_label_instances = (long *) xrealloc ((char *) fb_label_instances,
- fb_label_max * sizeof (long));
+ fb_labels = XRESIZEVEC (long, fb_labels, fb_label_max);
+ fb_label_instances = XRESIZEVEC (long, fb_label_instances, fb_label_max);
} /* if we needed to grow */
fb_labels[fb_label_count] = label;
@@ -3093,7 +3090,7 @@ symbol_relc_make_sym (symbolS * sym)
char *
symbol_relc_make_value (offsetT val)
{
- char * terminal = xmalloc (28); /* Enough for long long. */
+ char * terminal = XNEWVEC (char, 28); /* Enough for long long. */
terminal[0] = '#';
bfd_sprintf_vma (stdoutput, terminal + 1, val);
--
2.1.4
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-25 8:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-24 8:30 [PATCH] use XNEW and related macros more tbsaunde+binutils
2016-04-25 8:41 ` Nick Clifton
-- strict thread matches above, loose matches on Subject: below --
2016-04-03 16:51 tbsaunde+binutils
2016-04-04 0:24 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).