use XNEW and related macros more

Its a bit shorter and simpler than raw xmalloc.

gas/ChangeLog:

2016-05-13  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.
This commit is contained in:
Trevor Saunders 2016-04-06 16:26:46 -04:00
parent 29a2809e42
commit add39d2344
55 changed files with 365 additions and 267 deletions

View file

@ -1,3 +1,137 @@
2016-05-13 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.
2016-05-13 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> 2016-05-13 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* config/obj-coff.c (obj_coff_def): Simplify string copying. * config/obj-coff.c (obj_coff_def): Simplify string copying.

View file

@ -259,7 +259,7 @@ app_push (void)
saved->saved_input = NULL; saved->saved_input = NULL;
else 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); memcpy (saved->saved_input, saved_input, saved_input_len);
saved->saved_input_len = saved_input_len; saved->saved_input_len = saved_input_len;
} }

View file

@ -569,7 +569,7 @@ parse_args (int * pargc, char *** pargv)
old_argv = *pargv; old_argv = *pargv;
/* Initialize a new argv that contains no options. */ /* 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_argv[0] = old_argv[0];
new_argc = 1; new_argc = 1;
new_argv[new_argc] = NULL; 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")); as_fatal (_("bad defsym; format is --defsym name=value"));
*s++ = '\0'; *s++ = '\0';
i = bfd_scan_vma (s, (const char **) NULL, 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->next = defsyms;
n->name = optarg; n->name = optarg;
n->value = i; n->value = i;

View file

@ -811,7 +811,7 @@ make_right_shifted_expr (expressionS * exp,
stmp->bsym->flags |= BSF_RELC; stmp->bsym->flags |= BSF_RELC;
/* Then wrap that in a "symbol expr" for good measure. */ /* 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)); memset (new_exp, 0, sizeof (expressionS));
new_exp->X_op = O_symbol; new_exp->X_op = O_symbol;
new_exp->X_op_symbol = 0; 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; bfd_reloc_code_real_type r_type = fixP->fx_r_type;
arelent *reloc; arelent *reloc;
reloc = (arelent *) xmalloc (sizeof (arelent)); reloc = XNEW (arelent);
#ifdef GAS_CGEN_PCREL_R_TYPE #ifdef GAS_CGEN_PCREL_R_TYPE
if (fixP->fx_pcrel) 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); 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); *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
/* Use fx_offset for these cases. */ /* Use fx_offset for these cases. */

View file

@ -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); INSTR_T Expr_Node_Gen_Reloc (Expr_Node *head, int parent_reloc);
#define MKREF(x) mkexpr (0,x) #define MKREF(x) mkexpr (0,x)
#define ALLOCATE(x) malloc (x)
#define NULL_CODE ((INSTR_T) 0) #define NULL_CODE ((INSTR_T) 0)

View file

@ -4494,7 +4494,7 @@ expr_1: expr_1 STAR expr_1
EXPR_T EXPR_T
mkexpr (int x, SYMBOL_T s) 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; e->value = x;
EXPR_SYMBOL(e) = s; EXPR_SYMBOL(e) = s;
return e; return e;

View file

@ -77,10 +77,8 @@ stack_init (unsigned long chunk_size,
{ {
stack *st; stack *st;
st = malloc (sizeof (* st)); st = XNEW (stack);
if (!st) st->data = XNEWVEC (char, chunk_size);
return NULL;
st->data = malloc (chunk_size);
if (!st->data) if (!st->data)
{ {
free (st); free (st);
@ -99,8 +97,7 @@ stack_push (stack *st, char *element)
if (st->pointer + st->element_size >= st->size) if (st->pointer + st->element_size >= st->size)
{ {
st->size += st->chunk_size; st->size += st->chunk_size;
if ((st->data = xrealloc (st->data, st->size)) == NULL) st->data = XRESIZEVEC (char, st->data, st->size);
return NULL;
} }
memcpy (st->data + st->pointer, element, st->element_size); memcpy (st->data + st->pointer, element, st->element_size);
st->pointer += st->element_size; st->pointer += st->element_size;
@ -383,7 +380,7 @@ void
coff_obj_symbol_new_hook (symbolS *symbolP) coff_obj_symbol_new_hook (symbolS *symbolP)
{ {
long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type); long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type);
char * s = xmalloc (sz); char * s = XNEWVEC (char, sz);
memset (s, 0, sz); memset (s, 0, sz);
coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s; coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s;
@ -403,10 +400,11 @@ coff_obj_symbol_new_hook (symbolS *symbolP)
void void
coff_obj_symbol_clone_hook (symbolS *newsymP, symbolS *orgsymP) coff_obj_symbol_clone_hook (symbolS *newsymP, symbolS *orgsymP)
{ {
long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type); long elts = OBJ_COFF_MAX_AUXENTRIES + 1;
combined_entry_type * s = xmalloc (sz); 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; coffsymbol (symbol_get_bfdsym (newsymP))->native = s;
SF_SET (newsymP, SF_GET (orgsymP)); SF_SET (newsymP, SF_GET (orgsymP));
@ -423,7 +421,7 @@ int coff_n_line_nos;
static void static void
add_lineno (fragS * frag, addressT offset, int num) 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) if (!current_lineno_sym)
abort (); abort ();
@ -1444,7 +1442,7 @@ coff_frob_symbol (symbolS *symp, int *punt)
/* We need i entries for line numbers, plus 1 for the first /* We need i entries for line numbers, plus 1 for the first
entry which BFD will override, plus 1 for the last zero entry which BFD will override, plus 1 for the last zero
entry (a marker for BFD). */ entry (a marker for BFD). */
l = xmalloc ((i + 2) * sizeof (* l)); l = XNEWVEC (alent, (i + 2));
coffsymbol (symbol_get_bfdsym (symp))->lineno = l; coffsymbol (symbol_get_bfdsym (symp))->lineno = l;
l[i + 1].line_number = 0; l[i + 1].line_number = 0;
l[i + 1].u.sym = NULL; l[i + 1].u.sym = NULL;

View file

@ -959,7 +959,7 @@ obj_elf_section_name (void)
int oldlen = strlen (name); int oldlen = strlen (name);
int substlen = strlen (now_seg->name); int substlen = strlen (now_seg->name);
int newlen = oldlen - 2 + substlen; int newlen = oldlen - 2 + substlen;
char *newname = (char *) xmalloc (newlen + 1); char *newname = XNEWVEC (char, newlen + 1);
int headlen = subst - name; int headlen = subst - name;
memcpy (newname, name, headlen); memcpy (newname, name, headlen);
strcpy (newname + headlen, now_seg->name); 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) if ((i & 127) == 0)
{ {
unsigned int newsize = i + 128; unsigned int newsize = i + 128;
list->head = (asection **) xrealloc (list->head, list->head = XRESIZEVEC (asection *, list->head, newsize);
newsize * sizeof (*list->head)); list->elt_count = XRESIZEVEC (unsigned int, list->elt_count, newsize);
list->elt_count = (unsigned int *)
xrealloc (list->elt_count, newsize * sizeof (*list->elt_count));
} }
list->head[i] = sec; list->head[i] = sec;
list->elt_count[i] = 1; list->elt_count[i] = 1;

View file

@ -86,8 +86,7 @@ evax_symbol_new_hook (symbolS *sym)
{ {
struct evax_private_udata_struct *udata; struct evax_private_udata_struct *udata;
udata = (struct evax_private_udata_struct *) udata = XNEW (struct evax_private_udata_struct);
xmalloc (sizeof (struct evax_private_udata_struct));
udata->bsym = symbol_get_bfdsym (sym); udata->bsym = symbol_get_bfdsym (sym);
udata->enbsym = NULL; udata->enbsym = NULL;

View file

@ -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 indirect, it is promoted to a 'real' one. Fetching the bfd sym
achieves this. */ achieves this. */
symbol_get_bfdsym (sym); symbol_get_bfdsym (sym);
isym = (obj_mach_o_indirect_sym *) isym = XNEW (obj_mach_o_indirect_sym);
xmalloc (sizeof (obj_mach_o_indirect_sym));
/* Just record the data for now, we will validate it when we /* Just record the data for now, we will validate it when we
compute the output in obj_mach_o_set_indirect_symbols. */ compute the output in obj_mach_o_set_indirect_symbols. */

View file

@ -1187,7 +1187,7 @@ insert_reg_alias (char *str, int number, aarch64_reg_type type)
} }
name = xstrdup (str); name = xstrdup (str);
new = xmalloc (sizeof (reg_entry)); new = XNEW (reg_entry);
new->name = name; new->name = name;
new->number = number; new->number = number;
@ -1575,7 +1575,7 @@ find_or_make_literal_pool (int size)
if (pool == NULL) if (pool == NULL)
{ {
/* Create a new pool. */ /* Create a new pool. */
pool = xmalloc (sizeof (*pool)); pool = XNEW (literal_pool);
if (!pool) if (!pool)
return NULL; 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 /* PR 16688: Bignums are held in a single global array. We must
copy and preserve that value now, before it is overwritten. */ 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, memcpy (pool->literals[entry].bignum, generic_bignum,
CHARS_PER_LITTLENUM * exp->X_add_number); CHARS_PER_LITTLENUM * exp->X_add_number);
} }
@ -7505,7 +7506,7 @@ fill_instruction_hash_table (void)
templates *templ, *new_templ; templates *templ, *new_templ;
templ = hash_find (aarch64_ops_hsh, opcode->name); templ = hash_find (aarch64_ops_hsh, opcode->name);
new_templ = (templates *) xmalloc (sizeof (templates)); new_templ = XNEW (templates);
new_templ->opcode = opcode; new_templ->opcode = opcode;
new_templ->next = NULL; new_templ->next = NULL;

View file

@ -1384,7 +1384,7 @@ load_expression (int targreg,
ptr1 = strstr (symname, "..") + 2; ptr1 = strstr (symname, "..") + 2;
if (ptr1 > ptr2) if (ptr1 > ptr2)
ptr1 = symname; ptr1 = symname;
ensymname = (char *) xmalloc (ptr2 - ptr1 + 5); ensymname = XNEWVEC (char, ptr2 - ptr1 + 5);
memcpy (ensymname, ptr1, ptr2 - ptr1); memcpy (ensymname, ptr1, ptr2 - ptr1);
memcpy (ensymname + (ptr2 - ptr1), "..en", 5); memcpy (ensymname + (ptr2 - ptr1), "..en", 5);
@ -2881,7 +2881,7 @@ emit_jsrjmp (const expressionS *tok,
char *ensymname; char *ensymname;
/* Build the entry name as 'NAME..en'. */ /* Build the entry name as 'NAME..en'. */
ensymname = (char *) xmalloc (symlen + 5); ensymname = XNEWVEC (char, symlen + 5);
memcpy (ensymname, symname, symlen); memcpy (ensymname, symname, symlen);
memcpy (ensymname + symlen, "..en", 5); memcpy (ensymname + symlen, "..en", 5);
@ -3733,8 +3733,7 @@ s_alpha_ent (int dummy ATTRIBUTE_UNUSED)
sym = symbol_find_or_make (name); sym = symbol_find_or_make (name);
symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION; symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION;
cur_frame_data = (struct alpha_elf_frame_data *) cur_frame_data = XCNEW (struct alpha_elf_frame_data);
calloc (1, sizeof (*cur_frame_data));
cur_frame_data->func_sym = sym; cur_frame_data->func_sym = sym;
/* Provide sensible defaults. */ /* Provide sensible defaults. */
@ -3789,7 +3788,7 @@ s_alpha_end (int dummy ATTRIBUTE_UNUSED)
if (sym && cur_frame_data) if (sym && cur_frame_data)
{ {
OBJ_SYMFIELD_TYPE *obj = symbol_get_obj (sym); OBJ_SYMFIELD_TYPE *obj = symbol_get_obj (sym);
expressionS *exp = (expressionS *) xmalloc (sizeof (expressionS)); expressionS *exp = XNEW (expressionS);
obj->size = exp; obj->size = exp;
exp->X_op = O_subtract; 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); (FAKE_LABEL_NAME, now_seg, (valueT) frag_now_fix (), frag_now);
/* Create a linkage element. */ /* Create a linkage element. */
linkage_fixup = (struct alpha_linkage_fixups *) linkage_fixup = XNEW (struct alpha_linkage_fixups);
xmalloc (sizeof (struct alpha_linkage_fixups));
linkage_fixup->fixp = fixp; linkage_fixup->fixp = fixp;
linkage_fixup->next = NULL; linkage_fixup->next = NULL;
linkage_fixup->label = alpha_insn_label; linkage_fixup->label = alpha_insn_label;
@ -5439,7 +5437,7 @@ md_begin (void)
if ((slash = strchr (name, '/')) != NULL) if ((slash = strchr (name, '/')) != NULL)
{ {
char *p = (char *) xmalloc (strlen (name)); char *p = XNEWVEC (char, strlen (name));
memcpy (p, name, slash - name); memcpy (p, name, slash - name);
strcpy (p + (slash - name), slash + 1); strcpy (p + (slash - name), slash + 1);
@ -6220,8 +6218,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED,
{ {
arelent *reloc; arelent *reloc;
reloc = (arelent *) xmalloc (sizeof (* reloc)); 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; 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; pname = symbol_get_bfdsym (sym)->name;
} }
udata = (struct evax_private_udata_struct *) udata = XNEW (struct evax_private_udata_struct);
xmalloc (sizeof (struct evax_private_udata_struct));
udata->enbsym = symbol_get_bfdsym (fixp->fx_addsy); udata->enbsym = symbol_get_bfdsym (fixp->fx_addsy);
udata->bsym = symbol_get_bfdsym (fixp->tc_fix_data.info->psym); udata->bsym = symbol_get_bfdsym (fixp->tc_fix_data.info->psym);
udata->origname = (char *)pname; udata->origname = (char *)pname;

View file

@ -700,7 +700,7 @@ arc_insert_opcode (const struct arc_opcode *opcode)
entry = hash_find (arc_opcode_hash, name); entry = hash_find (arc_opcode_hash, name);
if (entry == NULL) if (entry == NULL)
{ {
entry = xmalloc (sizeof (*entry)); entry = XNEW (struct arc_opcode_hash_entry);
entry->count = 0; entry->count = 0;
entry->opcode = NULL; entry->opcode = NULL;
@ -710,9 +710,8 @@ arc_insert_opcode (const struct arc_opcode *opcode)
name, retval); name, retval);
} }
entry->opcode = xrealloc (entry->opcode, entry->opcode = XRESIZEVEC (const struct arc_opcode *, entry->opcode,
sizeof (const struct arc_opcode *) entry->count + 1);
* (entry->count + 1));
if (entry->opcode == NULL) if (entry->opcode == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));
@ -2937,8 +2936,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED,
arelent *reloc; arelent *reloc;
bfd_reloc_code_real_type code; bfd_reloc_code_real_type code;
reloc = (arelent *) xmalloc (sizeof (* reloc)); 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->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where; reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
@ -4471,7 +4470,7 @@ arc_extcorereg (int opertype)
break; break;
case EXT_AUX_REGISTER: case EXT_AUX_REGISTER:
/* Auxiliary register. */ /* Auxiliary register. */
auxr = xmalloc (sizeof (struct arc_aux_reg)); auxr = XNEW (struct arc_aux_reg);
auxr->name = ereg.name; auxr->name = ereg.name;
auxr->cpu = arc_target; auxr->cpu = arc_target;
auxr->subclass = NONE; auxr->subclass = NONE;
@ -4488,8 +4487,8 @@ arc_extcorereg (int opertype)
ereg.number); ereg.number);
ext_condcode.size ++; ext_condcode.size ++;
ext_condcode.arc_ext_condcode = ext_condcode.arc_ext_condcode =
xrealloc (ext_condcode.arc_ext_condcode, XRESIZEVEC (struct arc_flag_operand, ext_condcode.arc_ext_condcode,
(ext_condcode.size + 1) * sizeof (struct arc_flag_operand)); ext_condcode.size + 1);
if (ext_condcode.arc_ext_condcode == NULL) if (ext_condcode.arc_ext_condcode == NULL)
as_fatal (_("Virtual memory exhausted")); as_fatal (_("Virtual memory exhausted"));

View file

@ -811,8 +811,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -528,8 +528,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
&& (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section))) && (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)))
return NULL; 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->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where; reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;
reloc->addend = fixP->fx_offset; reloc->addend = fixP->fx_offset;

View file

@ -3959,9 +3959,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
return 0; return 0;
} }
relP = (arelent *) xmalloc (sizeof (arelent)); relP = XNEW (arelent);
gas_assert (relP != 0); 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->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
relP->address = fixP->fx_frag->fr_address + fixP->fx_where; relP->address = fixP->fx_frag->fr_address + fixP->fx_where;

View file

@ -1765,7 +1765,7 @@ preprocess_reglist (char *param, int *allocated)
while (*paramP++ != '{'); while (*paramP++ != '{');
new_param = (char *)xcalloc (MAX_INST_LEN, sizeof (char)); new_param = XCNEWVEC (char, MAX_INST_LEN);
*allocated = 1; *allocated = 1;
strncpy (new_param, param, paramP - param - 1); strncpy (new_param, param, paramP - param - 1);

View file

@ -1451,8 +1451,8 @@ arelent *
tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp) tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);

View file

@ -524,7 +524,7 @@ frv_insert_vliw_insn (bfd_boolean count)
if (current_vliw_chain == NULL) 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_count = 0;
vliw_chain_entry->insn_list = NULL; vliw_chain_entry->insn_list = NULL;
vliw_chain_entry->next = NULL; vliw_chain_entry->next = NULL;
@ -537,7 +537,7 @@ frv_insert_vliw_insn (bfd_boolean count)
previous_vliw_chain->next = vliw_chain_entry; 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->type = VLIW_GENERIC_TYPE;
vliw_insn_list_entry->insn = NULL; vliw_insn_list_entry->insn = NULL;
vliw_insn_list_entry->sym = 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 *prev_insn = NULL;
struct vliw_insn_list *curr_insn = vliw_to_split->insn_list; 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 *double_nop = XNEW (struct vliw_chain);
struct vliw_chain *single_nop = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain)); struct vliw_chain *single_nop = XNEW (struct vliw_chain);
struct vliw_chain *second_part = (struct vliw_chain *) xmalloc (sizeof (struct vliw_chain)); struct vliw_chain *second_part = XNEW (struct vliw_chain);
struct vliw_chain *curr_vliw = vliw_chain_top; struct vliw_chain *curr_vliw = vliw_chain_top;
struct vliw_chain *prev_vliw = NULL; struct vliw_chain *prev_vliw = NULL;

View file

@ -252,8 +252,7 @@ md_begin (void)
nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode); nopcodes = sizeof (h8_opcodes) / sizeof (struct h8_opcode);
h8_instructions = (struct h8_instruction *) h8_instructions = XNEWVEC (struct h8_instruction, nopcodes);
xmalloc (nopcodes * sizeof (struct h8_instruction));
pi = h8_instructions; pi = h8_instructions;
p1 = h8_opcodes; p1 = h8_opcodes;
@ -273,7 +272,7 @@ md_begin (void)
break; break;
/* Strip off any . part when inserting the opcode and only enter /* Strip off any . part when inserting the opcode and only enter
unique codes into the hash table. */ unique codes into the hash table. */
dst = buffer = malloc (strlen (src) + 1); dst = buffer = XNEWVEC (char, strlen (src) + 1);
while (*src) while (*src)
{ {
if (*src == '.') if (*src == '.')

View file

@ -1867,7 +1867,7 @@ i370_macro (char *str, const struct i370_macro *macro)
} }
/* Put the string together. */ /* Put the string together. */
complete = s = xmalloc (len + 1); complete = s = XNEWVEC (char, len + 1);
format = macro->format; format = macro->format;
while (*format != '\0') while (*format != '\0')
{ {
@ -2603,9 +2603,9 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);

View file

@ -2513,7 +2513,7 @@ md_begin (void)
/* Setup for loop. */ /* Setup for loop. */
optab = i386_optab; optab = i386_optab;
core_optab = (templates *) xmalloc (sizeof (templates)); core_optab = XNEW (templates);
core_optab->start = optab; core_optab->start = optab;
while (1) while (1)
@ -2536,7 +2536,7 @@ md_begin (void)
} }
if (optab->name == NULL) if (optab->name == NULL)
break; break;
core_optab = (templates *) xmalloc (sizeof (templates)); core_optab = XNEW (templates);
core_optab->start = optab; core_optab->start = optab;
} }
} }
@ -7607,7 +7607,7 @@ lex_got (enum bfd_reloc_code_real *rel,
/* Allocate and copy string. The trailing NUL shouldn't /* Allocate and copy string. The trailing NUL shouldn't
be necessary, but be safe. */ be necessary, but be safe. */
tmpbuf = (char *) xmalloc (first + second + 2); tmpbuf = XNEWVEC (char, first + second + 2);
memcpy (tmpbuf, input_line_pointer, first); memcpy (tmpbuf, input_line_pointer, first);
if (second != 0 && *past_reloc != ' ') if (second != 0 && *past_reloc != ' ')
/* Replace the relocation token with ' ', so that /* Replace the relocation token with ' ', so that
@ -7715,7 +7715,7 @@ lex_got (enum bfd_reloc_code_real *rel ATTRIBUTE_UNUSED,
/* Allocate and copy string. The trailing NUL shouldn't /* Allocate and copy string. The trailing NUL shouldn't
be necessary, but be safe. */ be necessary, but be safe. */
tmpbuf = (char *) xmalloc (first + second + 2); tmpbuf = XNEWVEC (char, first + second + 2);
memcpy (tmpbuf, input_line_pointer, first); memcpy (tmpbuf, input_line_pointer, first);
if (second != 0 && *past_reloc != ' ') if (second != 0 && *past_reloc != ' ')
/* Replace the relocation token with ' ', so that /* Replace the relocation token with ' ', so that
@ -9797,7 +9797,7 @@ md_parse_option (int c, const char *arg)
char *n, *t; char *n, *t;
const char *s; const char *s;
n = (char *) xmalloc (strlen (i386_comment_chars) + 1); n = XNEWVEC (char, strlen (i386_comment_chars) + 1);
t = n; t = n;
for (s = i386_comment_chars; *s != '\0'; s++) for (s = i386_comment_chars; *s != '\0'; s++)
if (*s != '/') if (*s != '/')
@ -10603,8 +10603,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
code = BFD_RELOC_X86_64_GOTPC64; code = BFD_RELOC_X86_64_GOTPC64;
} }
rel = (arelent *) xmalloc (sizeof (arelent)); rel = XNEW (arelent);
rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where; rel->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -1741,7 +1741,7 @@ static unw_rec_list *
alloc_record (unw_record_type t) alloc_record (unw_record_type t)
{ {
unw_rec_list *ptr; unw_rec_list *ptr;
ptr = xmalloc (sizeof (*ptr)); ptr = XNEW (unw_rec_list);
memset (ptr, 0, sizeof (*ptr)); memset (ptr, 0, sizeof (*ptr));
ptr->slot_number = SLOT_NUM_NOT_SET; ptr->slot_number = SLOT_NUM_NOT_SET;
ptr->r.type = t; ptr->r.type = t;
@ -2650,8 +2650,7 @@ set_imask (unw_rec_list *region,
if (!imask) if (!imask)
{ {
imask_size = (region->r.record.r.rlen * 2 + 7) / 8 + 1; imask_size = (region->r.record.r.rlen * 2 + 7) / 8 + 1;
imask = xmalloc (imask_size); imask = XCNEWVEC (unsigned char, imask_size);
memset (imask, 0, imask_size);
region->r.record.r.imask_size = imask_size; region->r.record.r.imask_size = imask_size;
region->r.record.r.mask.i = imask; region->r.record.r.mask.i = imask;
@ -4110,7 +4109,7 @@ save_prologue_count (unsigned long lbl, unsigned int count)
lpc->prologue_count = count; lpc->prologue_count = count;
else 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->next = unwind.saved_prologue_counts;
new_lpc->label_number = lbl; new_lpc->label_number = lbl;
@ -4262,7 +4261,7 @@ dot_proc (int dummy ATTRIBUTE_UNUSED)
} }
else else
{ {
pending = xmalloc (sizeof (*pending)); pending = XNEW (proc_pending);
pending->sym = sym; pending->sym = sym;
last_pending = last_pending->next = pending; 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)); S_SET_SIZE (sym, frag_now_fix () - S_GET_VALUE (sym));
else else
{ {
symbol_get_obj (sym)->size = symbol_get_obj (sym)->size = XNEW (expressionS);
(expressionS *) xmalloc (sizeof (expressionS));
symbol_get_obj (sym)->size->X_op = O_subtract; symbol_get_obj (sym)->size->X_op = O_subtract;
symbol_get_obj (sym)->size->X_add_symbol symbol_get_obj (sym)->size->X_add_symbol
= symbol_new (FAKE_LABEL_NAME, now_seg, = symbol_new (FAKE_LABEL_NAME, now_seg,
@ -7789,9 +7787,8 @@ ia64_frob_label (struct symbol *sym)
if (md.path == md.maxpaths) if (md.path == md.maxpaths)
{ {
md.maxpaths += 20; md.maxpaths += 20;
md.entry_labels = (const char **) md.entry_labels = XRESIZEVEC (const char *, md.entry_labels,
xrealloc ((void *) md.entry_labels, md.maxpaths);
md.maxpaths * sizeof (char *));
} }
md.entry_labels[md.path++] = S_GET_NAME (sym); 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) if (qp_implieslen == qp_impliestotlen)
{ {
qp_impliestotlen += 20; qp_impliestotlen += 20;
qp_implies = (struct qp_imply *) qp_implies = XRESIZEVEC (struct qp_imply, qp_implies, qp_impliestotlen);
xrealloc ((void *) qp_implies,
qp_impliestotlen * sizeof (struct qp_imply));
} }
if (md.debug_dv) if (md.debug_dv)
fprintf (stderr, " Registering PR%d implies PR%d\n", p1, p2); 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) if (qp_mutexeslen == qp_mutexestotlen)
{ {
qp_mutexestotlen += 20; qp_mutexestotlen += 20;
qp_mutexes = (struct qpmutex *) qp_mutexes = XRESIZEVEC (struct qpmutex, qp_mutexes, qp_mutexestotlen);
xrealloc ((void *) qp_mutexes,
qp_mutexestotlen * sizeof (struct qpmutex));
} }
if (md.debug_dv) if (md.debug_dv)
{ {
@ -10193,9 +10186,7 @@ mark_resource (struct ia64_opcode *idesc ATTRIBUTE_UNUSED,
if (regdepslen == regdepstotlen) if (regdepslen == regdepstotlen)
{ {
regdepstotlen += 20; regdepstotlen += 20;
regdeps = (struct rsrc *) regdeps = XRESIZEVEC (struct rsrc, regdeps, regdepstotlen);
xrealloc ((void *) regdeps,
regdepstotlen * sizeof (struct rsrc));
} }
regdeps[regdepslen] = *spec; regdeps[regdepslen] = *spec;
@ -11837,7 +11828,7 @@ dot_alias (int section)
goto out; goto out;
} }
h = (struct alias *) xmalloc (sizeof (struct alias)); h = XNEW (struct alias);
h->file = as_where (&h->line); h->file = as_where (&h->line);
h->name = name; h->name = name;

View file

@ -613,9 +613,7 @@ md_begin (void)
m68hc11_hash = hash_new (); m68hc11_hash = hash_new ();
/* Get a writable copy of the opcode table and sort it on the names. */ /* Get a writable copy of the opcode table and sort it on the names. */
opcodes = (struct m68hc11_opcode *) xmalloc (m68hc11_num_opcodes * opcodes = XNEWVEC (struct m68hc11_opcode, m68hc11_num_opcodes);
sizeof (struct
m68hc11_opcode));
m68hc11_sorted_opcodes = opcodes; m68hc11_sorted_opcodes = opcodes;
num_opcodes = 0; num_opcodes = 0;
for (i = 0; i < m68hc11_num_opcodes; i++) for (i = 0; i < m68hc11_num_opcodes; i++)
@ -644,8 +642,7 @@ md_begin (void)
qsort (opcodes, num_opcodes, sizeof (struct m68hc11_opcode), qsort (opcodes, num_opcodes, sizeof (struct m68hc11_opcode),
(int (*) (const void*, const void*)) cmp_opcode); (int (*) (const void*, const void*)) cmp_opcode);
opc = (struct m68hc11_opcode_def *) opc = XNEWVEC (struct m68hc11_opcode_def, num_opcodes);
xmalloc (num_opcodes * sizeof (struct m68hc11_opcode_def));
m68hc11_opcode_defs = opc--; m68hc11_opcode_defs = opc--;
/* Insert unique names into hash table. The M6811 instruction set /* 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; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
if (fixp->fx_r_type == 0) if (fixp->fx_r_type == 0)

View file

@ -1334,8 +1334,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
#undef F #undef F
#undef MAP #undef MAP
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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
#ifndef OBJ_ELF #ifndef OBJ_ELF
@ -4786,7 +4786,7 @@ m68k_frob_label (symbolS *sym)
{ {
struct label_line *n; struct label_line *n;
n = (struct label_line *) xmalloc (sizeof *n); n = XNEW (struct label_line);
n->next = labels; n->next = labels;
n->label = sym; n->label = sym;
n->file = as_where (&n->line); n->file = as_where (&n->line);
@ -6102,7 +6102,7 @@ s_save (int ignore ATTRIBUTE_UNUSED)
{ {
struct save_opts *s; struct save_opts *s;
s = (struct save_opts *) xmalloc (sizeof (struct save_opts)); s = XNEW (struct save_opts);
s->abspcadd = m68k_abspcadd; s->abspcadd = m68k_abspcadd;
s->symbols_case_sensitive = symbols_case_sensitive; s->symbols_case_sensitive = symbols_case_sensitive;
s->keep_locals = flag_keep_locals; s->keep_locals = flag_keep_locals;
@ -6222,7 +6222,7 @@ mri_control_label (void)
{ {
char *n; char *n;
n = (char *) xmalloc (20); n = XNEWVEC (char, 20);
sprintf (n, "%smc%d", FAKE_LABEL_NAME, mri_control_index); sprintf (n, "%smc%d", FAKE_LABEL_NAME, mri_control_index);
++mri_control_index; ++mri_control_index;
return n; return n;
@ -6235,7 +6235,7 @@ push_mri_control (enum mri_control_type type)
{ {
struct mri_control_info *n; 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->type = type;
n->else_seen = 0; n->else_seen = 0;
@ -6514,9 +6514,9 @@ build_mri_control_operand (int qual, int cc, char *leftstart, char *leftstop,
if (leftstart != NULL) if (leftstart != NULL)
{ {
buf = (char *) xmalloc (20 buf = XNEWVEC (char, (20
+ (leftstop - leftstart) + (leftstop - leftstart)
+ (rightstop - rightstart)); + (rightstop - rightstart)));
s = buf; s = buf;
*s++ = 'c'; *s++ = 'c';
*s++ = 'm'; *s++ = 'm';
@ -6534,7 +6534,7 @@ build_mri_control_operand (int qual, int cc, char *leftstart, char *leftstop,
free (buf); free (buf);
} }
buf = (char *) xmalloc (20 + strlen (truelab)); buf = XNEWVEC (char, 20 + strlen (truelab));
s = buf; s = buf;
*s++ = 'b'; *s++ = 'b';
*s++ = cc >> 8; *s++ = cc >> 8;
@ -6783,7 +6783,7 @@ s_mri_else (int qual)
mri_control_stack->else_seen = 1; 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[0] = TOLOWER (qual);
q[1] = '\0'; q[1] = '\0';
sprintf (buf, "bra%s %s", q, mri_control_stack->bottom); sprintf (buf, "bra%s %s", q, mri_control_stack->bottom);
@ -6854,7 +6854,7 @@ s_mri_break (int extent)
return; return;
} }
buf = (char *) xmalloc (20 + strlen (n->bottom)); buf = XNEWVEC (char, 20 + strlen (n->bottom));
ex[0] = TOLOWER (extent); ex[0] = TOLOWER (extent);
ex[1] = '\0'; ex[1] = '\0';
sprintf (buf, "bra%s %s", ex, n->bottom); sprintf (buf, "bra%s %s", ex, n->bottom);
@ -6892,7 +6892,7 @@ s_mri_next (int extent)
return; return;
} }
buf = (char *) xmalloc (20 + strlen (n->next)); buf = XNEWVEC (char, 20 + strlen (n->next));
ex[0] = TOLOWER (extent); ex[0] = TOLOWER (extent);
ex[1] = '\0'; ex[1] = '\0';
sprintf (buf, "bra%s %s", ex, n->next); 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. */ /* We have fully parsed the FOR operands. Now build the loop. */
n = push_mri_control (mri_for); 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. */ /* Move init,var. */
s = buf; s = buf;
@ -7300,7 +7300,7 @@ s_mri_endw (int ignore ATTRIBUTE_UNUSED)
return; 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); sprintf (buf, "bra %s", mri_control_stack->next);
mri_assemble (buf); mri_assemble (buf);
free (buf); free (buf);
@ -7581,7 +7581,7 @@ md_parse_option (int c, const char *arg)
char *n, *t; char *n, *t;
const char *s; const char *s;
n = (char *) xmalloc (strlen (m68k_comment_chars) + 1); n = XNEWVEC (char, strlen (m68k_comment_chars) + 1);
t = n; t = n;
for (s = m68k_comment_chars; *s != '\0'; s++) for (s = m68k_comment_chars; *s != '\0'; s++)
if (*s != '|') if (*s != '|')

View file

@ -6331,7 +6331,7 @@ create_mnemonic_htab (void)
insn_templates **slot = NULL; insn_templates **slot = NULL;
insn_templates *new_entry; insn_templates *new_entry;
new_entry = xmalloc (sizeof (insn_templates)); new_entry = XNEW (insn_templates);
new_entry->template = template; new_entry->template = template;
new_entry->next = NULL; new_entry->next = NULL;
@ -7006,8 +7006,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -2432,8 +2432,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
break; break;
} }
rel = (arelent *) xmalloc (sizeof (arelent)); rel = XNEW (arelent);
rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); rel->sym_ptr_ptr = XNEW (asymbol *);
if (code == BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM) if (code == BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM)
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy); *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_subsy);

View file

@ -2874,9 +2874,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
return NULL; return NULL;
} }
relP = (arelent *) xmalloc (sizeof (arelent)); relP = XNEW (arelent);
gas_assert (relP != 0); gas_assert (relP != 0);
relP->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); relP->sym_ptr_ptr = XNEW (asymbol *);
*relP->sym_ptr_ptr = baddsy; *relP->sym_ptr_ptr = baddsy;
relP->address = fixP->fx_frag->fr_address + fixP->fx_where; relP->address = fixP->fx_frag->fr_address + fixP->fx_where;
@ -4089,8 +4089,7 @@ s_loc (int ignore ATTRIBUTE_UNUSED)
if (section == undefined_section) if (section == undefined_section)
{ {
struct loc_assert_s *next = loc_asserts; struct loc_assert_s *next = loc_asserts;
loc_asserts loc_asserts = XNEW (struct loc_assert_s);
= (struct loc_assert_s *) xmalloc (sizeof (*loc_asserts));
loc_asserts->next = next; loc_asserts->next = next;
loc_asserts->old_seg = now_seg; loc_asserts->old_seg = now_seg;
loc_asserts->loc_sym = esym; loc_asserts->loc_sym = esym;

View file

@ -3709,14 +3709,14 @@ nds32_relax_hint (int mode ATTRIBUTE_UNUSED)
relocs = hash_find (nds32_hint_hash, name); relocs = hash_find (nds32_hint_hash, name);
if (relocs == NULL) if (relocs == NULL)
{ {
relocs = malloc (sizeof (struct nds32_relocs_pattern)); relocs = XNEW (struct nds32_relocs_pattern);
hash_insert (nds32_hint_hash, name, relocs); hash_insert (nds32_hint_hash, name, relocs);
} }
else else
{ {
while (relocs->next) while (relocs->next)
relocs=relocs->next; relocs=relocs->next;
relocs->next = malloc (sizeof (struct nds32_relocs_pattern)); relocs->next = XNEW (struct nds32_relocs_pattern);
relocs = relocs->next; 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 /* It has to build this list because there are maybe more than one
instructions relative to the same instruction. It to connect to instructions relative to the same instruction. It to connect to
next instruction after md_assemble. */ next instruction after md_assemble. */
new = malloc (sizeof (struct nds32_relocs_group)); new = XNEW (struct nds32_relocs_group);
new->pattern = relocs; new->pattern = relocs;
new->next = NULL; new->next = NULL;
group = nds32_relax_hint_current; group = nds32_relax_hint_current;
@ -6602,9 +6602,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
arelent *reloc; arelent *reloc;
bfd_reloc_code_real_type code; 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->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
reloc->address = fixP->fx_frag->fr_address + fixP->fx_where; reloc->address = fixP->fx_frag->fr_address + fixP->fx_where;

View file

@ -1482,7 +1482,7 @@ static nios2_insn_relocS *
nios2_insn_reloc_new (bfd_reloc_code_real_type reloc_type, unsigned int pcrel) nios2_insn_reloc_new (bfd_reloc_code_real_type reloc_type, unsigned int pcrel)
{ {
nios2_insn_relocS *retval; nios2_insn_relocS *retval;
retval = (nios2_insn_relocS *) malloc (sizeof (nios2_insn_relocS)); retval = XNEW (nios2_insn_relocS);
if (retval == NULL) if (retval == NULL)
{ {
as_bad (_("can't create relocation")); as_bad (_("can't create relocation"));
@ -3854,8 +3854,8 @@ nios2_frob_symbol (symbolS *symp)
arelent * arelent *
tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc = (arelent *) xmalloc (sizeof (arelent)); 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -1271,8 +1271,8 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
fixp->fx_subsy = NULL; fixp->fx_subsy = NULL;
} }
reloc[0] = (arelent *) xmalloc (sizeof (arelent)); reloc[0] = XNEW (arelent);
reloc[0]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); reloc[0]->sym_ptr_ptr = XNEW (asymbol *);
* reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); * reloc[0]->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc[0]->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc[0]->address = fixp->fx_frag->fr_address + fixp->fx_where;
reloc[0]->addend = fixp->fx_offset; reloc[0]->addend = fixp->fx_offset;
@ -1284,8 +1284,8 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp)
} }
#define OPX(REL,SYM,ADD) \ #define OPX(REL,SYM,ADD) \
reloc[rp] = (arelent *) xmalloc (sizeof (arelent)); \ reloc[rp] = XNEW (arelent); \
reloc[rp]->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); \ reloc[rp]->sym_ptr_ptr = XNEW (asymbol *); \
reloc[rp]->howto = bfd_reloc_type_lookup (stdoutput, REL); \ reloc[rp]->howto = bfd_reloc_type_lookup (stdoutput, REL); \
reloc[rp]->addend = ADD; \ reloc[rp]->addend = ADD; \
* reloc[rp]->sym_ptr_ptr = SYM; \ * reloc[rp]->sym_ptr_ptr = SYM; \

View file

@ -301,7 +301,7 @@ rx_include (int ignore)
} }
current_filename = as_where (NULL); 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 /* Check the filename. If [@]..FILE[@] is found then replace
this with the current assembler source filename, stripped this with the current assembler source filename, stripped
@ -359,7 +359,7 @@ rx_include (int ignore)
if (env && strlen (env) > len) if (env && strlen (env) > len)
len = strlen (env); len = strlen (env);
path = (char *) xmalloc (strlen (f) + len + 5); path = XNEWVEC (char, strlen (f) + len + 5);
if (current_filename != NULL) if (current_filename != NULL)
{ {

View file

@ -4424,8 +4424,8 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
arelent *rel; arelent *rel;
bfd_reloc_code_real_type r_type; bfd_reloc_code_real_type r_type;
rel = (arelent *) xmalloc (sizeof (arelent)); rel = XNEW (arelent);
rel->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); rel->sym_ptr_ptr = XNEW (asymbol *);
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); *rel->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
rel->address = fixp->fx_frag->fr_address + fixp->fx_where; rel->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -439,7 +439,7 @@ shmedia_frob_section_type (asection *sec)
sec_elf_data = sh64_elf_section_data (sec)->sh64_info; sec_elf_data = sh64_elf_section_data (sec)->sh64_info;
if (sec_elf_data == NULL) 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; sh64_elf_section_data (sec)->sh64_info = sec_elf_data;
} }

View file

@ -3685,10 +3685,10 @@ tc_gen_reloc (asection *section, fixS *fixp)
arelent *reloc; arelent *reloc;
bfd_reloc_code_real_type code; bfd_reloc_code_real_type code;
relocs[0] = reloc = (arelent *) xmalloc (sizeof (arelent)); relocs[0] = reloc = XNEW (arelent);
relocs[1] = NULL; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; 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. */ on the same location. */
if (code == BFD_RELOC_SPARC_OLO10) if (code == BFD_RELOC_SPARC_OLO10)
{ {
relocs[1] = reloc = (arelent *) xmalloc (sizeof (arelent)); relocs[1] = reloc = XNEW (arelent);
relocs[2] = NULL; relocs[2] = NULL;
reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); reloc->sym_ptr_ptr = XNEW (asymbol *);
*reloc->sym_ptr_ptr *reloc->sym_ptr_ptr
= symbol_get_bfdsym (section_symbol (absolute_section)); = symbol_get_bfdsym (section_symbol (absolute_section));
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -863,8 +863,8 @@ arelent *
tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp) tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc; arelent *reloc;
reloc = (arelent *) xmalloc (sizeof (arelent)); reloc = XNEW (arelent);
reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); reloc->sym_ptr_ptr = XNEW (asymbol *);
if (fixp->fx_addsy) if (fixp->fx_addsy)
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
else if (fixp->fx_subsy) else if (fixp->fx_subsy)

View file

@ -201,7 +201,7 @@ static tic6x_unwind_info *tic6x_get_unwind (void)
if (unwind) if (unwind)
return 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; seg_info (now_seg)->tc_segment_info_data.unwind = unwind;
memset (unwind, 0, sizeof (*unwind)); memset (unwind, 0, sizeof (*unwind));
return unwind; return unwind;
@ -4642,7 +4642,7 @@ tic6x_start_unwind_section (const segT text_seg, int idx)
prefix_len = strlen (prefix); prefix_len = strlen (prefix);
text_len = strlen (text_name); text_len = strlen (text_name);
sec_name_len = prefix_len + text_len; 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, prefix_len);
memcpy (sec_name + prefix_len, text_name, text_len); memcpy (sec_name + prefix_len, text_name, text_len);
sec_name[prefix_len + text_len] = '\0'; sec_name[prefix_len + text_len] = '\0';

View file

@ -1735,8 +1735,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -1515,8 +1515,8 @@ tc_gen_reloc (asection *sec ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -3337,8 +3337,8 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
{ {
arelent *reloc; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -112,9 +112,9 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
arelent *reloc; arelent *reloc;
bfd_reloc_code_real_type code; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -298,8 +298,7 @@ md_begin (void)
/* Create a local copy of our opcode table /* Create a local copy of our opcode table
including an extra line for NULL termination. */ including an extra line for NULL termination. */
xgate_op_table = (struct xgate_opcode *) xgate_op_table = XNEWVEC (struct xgate_opcode, xgate_num_opcodes);
xmalloc ((xgate_num_opcodes) * sizeof (struct xgate_opcode));
memset (xgate_op_table, 0, memset (xgate_op_table, 0,
sizeof(struct xgate_opcode) * (xgate_num_opcodes)); sizeof(struct xgate_opcode) * (xgate_num_opcodes));
@ -322,8 +321,7 @@ md_begin (void)
prev_op_name = xgate_opcode_ptr->name; prev_op_name = xgate_opcode_ptr->name;
} }
op_handles = (struct xgate_opcode_handle *) op_handles = XNEWVEC (struct xgate_opcode_handle, number_of_op_handles);
xmalloc (sizeof(struct xgate_opcode_handle) * (number_of_op_handles));
/* Insert unique opcode names into hash table, aliasing duplicates. */ /* Insert unique opcode names into hash table, aliasing duplicates. */
xgate_hash = hash_new (); xgate_hash = hash_new ();
@ -616,8 +614,8 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp)
{ {
arelent * reloc; 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->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;

View file

@ -2424,7 +2424,7 @@ xtensa_translate_old_userreg_ops (char **popname)
/* Translate the opcode. */ /* Translate the opcode. */
sr_name = xtensa_sysreg_name (isa, sr); 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 ? "_" : ""), sprintf (new_opname, "%s%cur.%s", (has_underbar ? "_" : ""),
opname[0], sr_name); opname[0], sr_name);
free (*popname); free (*popname);
@ -6147,9 +6147,9 @@ new_resource_table (void *data,
rt->opcode_unit_use = ouuf; rt->opcode_unit_use = ouuf;
rt->opcode_unit_stage = ousf; 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++) 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; return rt;
} }
@ -6183,7 +6183,7 @@ resize_resource_table (resource_table *rt, int cycles)
for (i = 0; i < old_cycles; i++) for (i = 0; i < old_cycles; i++)
rt->units[i] = XRESIZEVEC (unsigned char, rt->units[i], rt->num_units); rt->units[i] = XRESIZEVEC (unsigned char, rt->units[i], rt->num_units);
for (i = old_cycles; i < cycles; i++) 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) if (ts == NULL)
{ {
ts = (struct trampoline_seg *)xcalloc(sizeof (struct trampoline_seg), 1); ts = XCNEW(struct trampoline_seg);
ts->next = trampoline_seg_list.next; ts->next = trampoline_seg_list.next;
trampoline_seg_list.next = ts; trampoline_seg_list.next = ts;
ts->seg = now_seg; ts->seg = now_seg;
@ -7549,7 +7549,7 @@ xtensa_maybe_create_literal_pool_frag (bfd_boolean create,
if (lps == NULL) if (lps == NULL)
{ {
lps = (struct litpool_seg *)xcalloc (sizeof (struct litpool_seg), 1); lps = XCNEW (struct litpool_seg);
lps->next = litpool_seg_list.next; lps->next = litpool_seg_list.next;
litpool_seg_list.next = lps; litpool_seg_list.next = lps;
lps->seg = now_seg; lps->seg = now_seg;
@ -11564,7 +11564,7 @@ cache_literal_section (bfd_boolean use_abs_literals)
|| strncmp (text_name, ".text", 5) == 0)) || strncmp (text_name, ".text", 5) == 0))
len -= 5; len -= 5;
name = xmalloc (len + strlen (base_name) + 1); name = XNEWVEC (char, len + strlen (base_name) + 1);
if (strncmp (text_name, ".text", 5) == 0) if (strncmp (text_name, ".text", 5) == 0)
{ {
strcpy (name, base_name); strcpy (name, base_name);

View file

@ -522,7 +522,7 @@ append_transition (TransitionTable *tt,
TransitionRule *t, TransitionRule *t,
transition_cmp_fn cmp) transition_cmp_fn cmp)
{ {
TransitionList *tl = (TransitionList *) xmalloc (sizeof (TransitionList)); TransitionList *tl = XNEW (TransitionList);
TransitionList *prev; TransitionList *prev;
TransitionList **t_p; TransitionList **t_p;
gas_assert (tt != NULL); gas_assert (tt != NULL);
@ -554,8 +554,7 @@ append_transition (TransitionTable *tt,
static void static void
append_condition (TransitionRule *tr, Precondition *cond) append_condition (TransitionRule *tr, Precondition *cond)
{ {
PreconditionList *pl = PreconditionList *pl = XNEW (PreconditionList);
(PreconditionList *) xmalloc (sizeof (PreconditionList));
PreconditionList *prev = tr->conditions; PreconditionList *prev = tr->conditions;
PreconditionList *nxt; PreconditionList *nxt;
@ -582,7 +581,7 @@ append_value_condition (TransitionRule *tr,
unsigned op1, unsigned op1,
unsigned op2) unsigned op2)
{ {
Precondition *cond = (Precondition *) xmalloc (sizeof (Precondition)); Precondition *cond = XNEW (Precondition);
cond->cmp = cmp; cond->cmp = cmp;
cond->op_num = op1; cond->op_num = op1;
@ -598,7 +597,7 @@ append_constant_value_condition (TransitionRule *tr,
unsigned op1, unsigned op1,
unsigned cnst) unsigned cnst)
{ {
Precondition *cond = (Precondition *) xmalloc (sizeof (Precondition)); Precondition *cond = XNEW (Precondition);
cond->cmp = cmp; cond->cmp = cmp;
cond->op_num = op1; cond->op_num = op1;
@ -654,7 +653,7 @@ append_op (BuildInstr *bi, BuildOp *b_op)
static void static void
append_literal_op (BuildInstr *bi, unsigned op1, unsigned src_op) 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->op_num = op1;
b_op->typ = OP_LITERAL; b_op->typ = OP_LITERAL;
@ -667,7 +666,7 @@ append_literal_op (BuildInstr *bi, unsigned op1, unsigned src_op)
static void static void
append_label_op (BuildInstr *bi, unsigned op1) 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->op_num = op1;
b_op->typ = OP_LABEL; b_op->typ = OP_LABEL;
@ -680,7 +679,7 @@ append_label_op (BuildInstr *bi, unsigned op1)
static void static void
append_constant_op (BuildInstr *bi, unsigned op1, unsigned cnst) 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->op_num = op1;
b_op->typ = OP_CONSTANT; b_op->typ = OP_CONSTANT;
@ -693,7 +692,7 @@ append_constant_op (BuildInstr *bi, unsigned op1, unsigned cnst)
static void static void
append_field_op (BuildInstr *bi, unsigned op1, unsigned src_op) 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->op_num = op1;
b_op->typ = OP_OPERAND; b_op->typ = OP_OPERAND;
@ -711,7 +710,7 @@ append_user_fn_field_op (BuildInstr *bi,
OpType typ, OpType typ,
unsigned src_op) unsigned src_op)
{ {
BuildOp *b_op = (BuildOp *) xmalloc (sizeof (BuildOp)); BuildOp *b_op = XNEW (BuildOp);
b_op->op_num = op1; b_op->op_num = op1;
b_op->typ = typ; b_op->typ = typ;
@ -819,7 +818,7 @@ enter_opname_n (const char *name, int len)
&& strncmp (op->opname, name, len) == 0) && strncmp (op->opname, name, len) == 0)
return op->opname; return op->opname;
} }
op = (opname_e *) xmalloc (sizeof (opname_e)); op = XNEW (opname_e);
op->opname = xmemdup0 (name, len); op->opname = xmemdup0 (name, len);
return op->opname; return op->opname;
} }
@ -835,7 +834,7 @@ enter_opname (const char *name)
if (strcmp (op->opname, name) == 0) if (strcmp (op->opname, name) == 0)
return op->opname; return op->opname;
} }
op = (opname_e *) xmalloc (sizeof (opname_e)); op = XNEW (opname_e);
op->opname = xstrdup (name); op->opname = xstrdup (name);
return op->opname; return op->opname;
} }
@ -1105,7 +1104,7 @@ split_string (split_rec *rec,
if (rec->count == 0) if (rec->count == 0)
return; return;
rec->vec = (char **) xmalloc (sizeof (char *) * cnt); rec->vec = XNEWVEC (char *, cnt);
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
rec->vec[i] = 0; rec->vec[i] = 0;
@ -1189,7 +1188,7 @@ parse_insn_templ (const char *s, insn_templ *t)
for (i = 0; i < oprec.count; i++) for (i = 0; i < oprec.count; i++)
{ {
const char *opname = oprec.vec[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->next = NULL;
e->operand_name = NULL; e->operand_name = NULL;
e->constant_value = 0; e->constant_value = 0;
@ -1307,7 +1306,7 @@ clone_req_or_option_list (ReqOrOption *req_or_option)
if (req_or_option == NULL) if (req_or_option == NULL)
return 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->option_name = xstrdup (req_or_option->option_name);
new_req_or_option->is_true = req_or_option->is_true; new_req_or_option->is_true = req_or_option->is_true;
new_req_or_option->next = NULL; new_req_or_option->next = NULL;
@ -1324,7 +1323,7 @@ clone_req_option_list (ReqOption *req_option)
if (req_option == NULL) if (req_option == NULL)
return 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->or_option_terms = NULL;
new_req_option->next = NULL; new_req_option->next = NULL;
new_req_option->or_option_terms = new_req_option->or_option_terms =
@ -1368,7 +1367,7 @@ parse_option_cond (const char *s, ReqOption *option)
else else
option_name = xstrdup (option_name); option_name = xstrdup (option_name);
req = (ReqOrOption *) xmalloc (sizeof (ReqOrOption)); req = XNEW (ReqOrOption);
req->option_name = option_name; req->option_name = option_name;
req->is_true = is_true; req->is_true = is_true;
req->next = NULL; req->next = NULL;
@ -1436,7 +1435,7 @@ parse_insn_pattern (const char *in, insn_pattern *insn)
for (i = 1; i < rec.count; i++) 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)) if (!parse_precond (rec.vec[i], cond))
{ {
@ -1455,7 +1454,7 @@ parse_insn_pattern (const char *in, insn_pattern *insn)
{ {
/* Handle the option conditions. */ /* Handle the option conditions. */
ReqOption **r_p; ReqOption **r_p;
ReqOption *req_option = (ReqOption *) xmalloc (sizeof (ReqOption)); ReqOption *req_option = XNEW (ReqOption);
req_option->or_option_terms = NULL; req_option->or_option_terms = NULL;
req_option->next = 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++) 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; e->next = NULL;
@ -1628,7 +1627,7 @@ build_transition (insn_pattern *initial_insn,
return NULL; return NULL;
} }
tr = (TransitionRule *) xmalloc (sizeof (TransitionRule)); tr = XNEW (TransitionRule);
tr->opcode = opcode; tr->opcode = opcode;
tr->conditions = NULL; tr->conditions = NULL;
tr->to_instr = NULL; tr->to_instr = NULL;
@ -1723,7 +1722,7 @@ build_transition (insn_pattern *initial_insn,
const char *fn_name; const char *fn_name;
const char *operand_arg_name; const char *operand_arg_name;
bi = (BuildInstr *) xmalloc (sizeof (BuildInstr)); bi = XNEW (BuildInstr);
append_build_insn (tr, bi); append_build_insn (tr, bi);
bi->opcode = XTENSA_UNDEFINED; bi->opcode = XTENSA_UNDEFINED;
@ -1853,10 +1852,9 @@ build_transition_table (const string_pattern_pair *transitions,
return table; return table;
/* Otherwise, build it now. */ /* Otherwise, build it now. */
table = (TransitionTable *) xmalloc (sizeof (TransitionTable)); table = XNEW (TransitionTable);
table->num_opcodes = num_opcodes; table->num_opcodes = num_opcodes;
table->table = table->table = XNEWVEC (TransitionList *, num_opcodes);
(TransitionList **) xmalloc (sizeof (TransitionTable *) * num_opcodes);
for (i = 0; i < num_opcodes; i++) for (i = 0; i < num_opcodes; i++)
table->table[i] = NULL; table->table[i] = NULL;

View file

@ -434,11 +434,9 @@ struct frch_cfi_data
static struct fde_entry * static struct fde_entry *
alloc_fde_entry (void) alloc_fde_entry (void)
{ {
struct fde_entry *fde = (struct fde_entry *) struct fde_entry *fde = XCNEW (struct fde_entry);
xcalloc (1, sizeof (struct fde_entry));
frchain_now->frch_cfi_data = (struct frch_cfi_data *) frchain_now->frch_cfi_data = XCNEW (struct frch_cfi_data);
xcalloc (1, sizeof (struct frch_cfi_data));
frchain_now->frch_cfi_data->cur_fde_data = fde; frchain_now->frch_cfi_data->cur_fde_data = fde;
*last_fde_data = fde; *last_fde_data = fde;
last_fde_data = &fde->next; last_fde_data = &fde->next;
@ -467,8 +465,7 @@ static struct fde_entry *last_fde;
static struct cfi_insn_data * static struct cfi_insn_data *
alloc_cfi_insn_data (void) alloc_cfi_insn_data (void)
{ {
struct cfi_insn_data *insn = (struct cfi_insn_data *) struct cfi_insn_data *insn = XCNEW (struct cfi_insn_data);
xcalloc (1, sizeof (struct cfi_insn_data));
struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data; struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data;
*cur_fde_data->last = insn; *cur_fde_data->last = insn;
@ -662,7 +659,7 @@ cfi_add_CFA_remember_state (void)
cfi_add_CFA_insn (DW_CFA_remember_state); 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->cfa_offset = frchain_now->frch_cfi_data->cur_cfa_offset;
p->next = frchain_now->frch_cfi_data->cfa_save_stack; p->next = frchain_now->frch_cfi_data->cfa_save_stack;
frchain_now->frch_cfi_data->cfa_save_stack = p; frchain_now->frch_cfi_data->cfa_save_stack = p;
@ -947,7 +944,7 @@ dot_cfi_escape (int ignored ATTRIBUTE_UNUSED)
tail = &head; tail = &head;
do do
{ {
e = (struct cfi_escape_data *) xmalloc (sizeof (*e)); e = XNEW (struct cfi_escape_data);
do_parse_cons_expression (&e->exp, 1); do_parse_cons_expression (&e->exp, 1);
*tail = e; *tail = e;
tail = &e->next; tail = &e->next;
@ -1387,7 +1384,7 @@ dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED)
num_ops = 0; num_ops = 0;
do do
{ {
e = (struct cfi_escape_data *) xmalloc (sizeof (*e)); e = XNEW (struct cfi_escape_data);
do_parse_cons_expression (&e->exp, 1); do_parse_cons_expression (&e->exp, 1);
*tail = e; *tail = e;
tail = &e->next; tail = &e->next;
@ -1409,7 +1406,7 @@ dot_cfi_fde_data (int ignored ATTRIBUTE_UNUSED)
num_ops = 3; num_ops = 3;
last_fde->eh_data_size = num_ops; 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; num_ops = 0;
while (head) while (head)
{ {
@ -2093,7 +2090,7 @@ select_cie_for_fde (struct fde_entry *fde, bfd_boolean eh_frame,
fail:; fail:;
} }
cie = (struct cie_entry *) xmalloc (sizeof (struct cie_entry)); cie = XNEW (struct cie_entry);
cie->next = cie_root; cie->next = cie_root;
cie_root = cie; cie_root = cie;
SET_CUR_SEG (cie, CUR_SEG (fde)); SET_CUR_SEG (cie, CUR_SEG (fde));

View file

@ -639,7 +639,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
{ {
size_t dir_len = strlen (dirs[files[filenum].dir]); size_t dir_len = strlen (dirs[files[filenum].dir]);
size_t file_len = strlen (files[filenum].filename); 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); memcpy (cp, dirs[files[filenum].dir], dir_len);
INSERT_DIR_SEPARATOR (cp, dir_len); INSERT_DIR_SEPARATOR (cp, dir_len);

View file

@ -3610,7 +3610,7 @@ ecoff_add_bytes (char **buf,
if (need < PAGE_SIZE) if (need < PAGE_SIZE)
need = PAGE_SIZE; need = PAGE_SIZE;
want = (*bufend - *buf) + need; want = (*bufend - *buf) + need;
*buf = (char *) xrealloc (*buf, want); *buf = XRESIZEVEC (char, *buf, want);
*bufend = *buf + want; *bufend = *buf + want;
return *buf + at; return *buf + at;
} }
@ -4691,7 +4691,7 @@ ecoff_build_debug (HDRR *hdr,
/* Build the symbolic information. */ /* Build the symbolic information. */
offset = 0; offset = 0;
buf = (char *) xmalloc (PAGE_SIZE); buf = XNEWVEC (char, PAGE_SIZE);
bufend = buf + PAGE_SIZE; bufend = buf + PAGE_SIZE;
/* Build the line number information. */ /* Build the line number information. */

View file

@ -139,7 +139,7 @@ input_scrub_push (char *saved_position)
{ {
struct input_save *saved; struct input_save *saved;
saved = (struct input_save *) xmalloc (sizeof *saved); saved = XNEW (struct input_save);
saved->saved_position = saved_position; saved->saved_position = saved_position;
saved->buffer_start = buffer_start; saved->buffer_start = buffer_start;
@ -163,8 +163,8 @@ input_scrub_push (char *saved_position)
buffer_length = input_file_buffer_size (); buffer_length = input_file_buffer_size ();
sb_index = -1; sb_index = -1;
buffer_start = (char *) xmalloc ((BEFORE_SIZE + buffer_length buffer_start = XNEWVEC (char, (BEFORE_SIZE + buffer_length
+ buffer_length + AFTER_SIZE + 1)); + buffer_length + AFTER_SIZE + 1));
memcpy (buffer_start, BEFORE_STRING, (int) BEFORE_SIZE); memcpy (buffer_start, BEFORE_STRING, (int) BEFORE_SIZE);
return saved; return saved;
@ -208,8 +208,8 @@ input_scrub_begin (void)
buffer_length = input_file_buffer_size (); buffer_length = input_file_buffer_size ();
buffer_start = (char *) xmalloc ((BEFORE_SIZE + buffer_length buffer_start = XNEWVEC (char, (BEFORE_SIZE + buffer_length
+ buffer_length + AFTER_SIZE + 1)); + buffer_length + AFTER_SIZE + 1));
memcpy (buffer_start, BEFORE_STRING, (int) BEFORE_SIZE); memcpy (buffer_start, BEFORE_STRING, (int) BEFORE_SIZE);
/* Line number things. */ /* Line number things. */
@ -389,10 +389,10 @@ input_scrub_next_buffer (char **bufp)
partial_size = limit - (buffer_start + BEFORE_SIZE); partial_size = limit - (buffer_start + BEFORE_SIZE);
buffer_length += input_file_buffer_size (); buffer_length += input_file_buffer_size ();
buffer_start = (char *) xrealloc (buffer_start, buffer_start = XRESIZEVEC (char, buffer_start,
(BEFORE_SIZE (BEFORE_SIZE
+ 2 * buffer_length + 2 * buffer_length
+ AFTER_SIZE + 1)); + AFTER_SIZE + 1));
} }
/* Tell the listing we've finished the file. */ /* Tell the listing we've finished the file. */

View file

@ -299,7 +299,7 @@ append_insns_as_macros (void)
{ {
struct ITBL_OPCODE_STRUCT *new_opcodes, *o; struct ITBL_OPCODE_STRUCT *new_opcodes, *o;
struct itbl_entry *e, **es; struct itbl_entry *e, **es;
int n, size, new_size, new_num_opcodes; int n, size, new_num_opcodes;
#ifdef USE_MACROS #ifdef USE_MACROS
int id; int id;
#endif #endif
@ -320,12 +320,9 @@ append_insns_as_macros (void)
ASSERT (size >= 0); ASSERT (size >= 0);
DBG (("I get=%d\n", size / sizeof (ITBL_OPCODES[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, /* FIXME since ITBL_OPCODES culd be a static table,
we can't realloc or delete the old memory. */ 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) if (!new_opcodes)
{ {
printf (_("Unable to allocate memory for new instructions\n")); 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; struct itbl_entry *e, **es;
if (!name) if (!name)
return 0; return 0;
e = (struct itbl_entry *) malloc (sizeof (struct itbl_entry)); e = XNEW (struct itbl_entry);
if (e) if (e)
{ {
memset (e, 0, sizeof (struct itbl_entry)); memset (e, 0, sizeof (struct itbl_entry));
@ -875,7 +872,7 @@ alloc_field (e_type type, int sbit, int ebit,
unsigned long flags) unsigned long flags)
{ {
struct itbl_field *f; struct itbl_field *f;
f = (struct itbl_field *) malloc (sizeof (struct itbl_field)); f = XNEW (struct itbl_field);
if (f) if (f)
{ {
memset (f, 0, sizeof (struct itbl_field)); memset (f, 0, sizeof (struct itbl_field));

View file

@ -347,7 +347,7 @@ listing_newline (char *ps)
if (strcmp (file, _("{standard input}")) == 0 if (strcmp (file, _("{standard input}")) == 0
&& input_line_pointer != NULL) && input_line_pointer != NULL)
{ {
char *copy; char *copy, *src, *dest;
int len; int len;
int seen_quote = 0; int seen_quote = 0;
int seen_slash = 0; int seen_slash = 0;
@ -367,25 +367,22 @@ listing_newline (char *ps)
len = copy - input_line_pointer + 1; len = copy - input_line_pointer + 1;
copy = (char *) xmalloc (len); copy = XNEWVEC (char, len);
if (copy != NULL) src = input_line_pointer;
dest = copy;
while (--len)
{ {
char *src = input_line_pointer; unsigned char c = *src++;
char *dest = copy;
while (--len) /* Omit control characters in the listing. */
{ if (!ISCNTRL (c))
unsigned char c = *src++; *dest++ = c;
/* Omit control characters in the listing. */
if (!ISCNTRL (c))
*dest++ = c;
}
*dest = 0;
} }
*dest = 0;
new_i->line_contents = copy; new_i->line_contents = copy;
} }
else else
@ -1200,8 +1197,8 @@ listing_listing (char *name ATTRIBUTE_UNUSED)
int show_listing = 1; int show_listing = 1;
unsigned int width; unsigned int width;
buffer = (char *) xmalloc (listing_rhs_width); buffer = XNEWVEC (char, listing_rhs_width);
data_buffer = (char *) xmalloc (MAX_BYTES); data_buffer = XNEWVEC (char, MAX_BYTES);
eject = 1; eject = 1;
list = head->next; list = head->next;

View file

@ -404,7 +404,7 @@ get_any_string (size_t idx, sb *in, sb *out)
} }
else else
{ {
char *br_buf = (char *) xmalloc (1); char *br_buf = XNEWVEC (char, 1);
char *in_br = br_buf; char *in_br = br_buf;
*in_br = '\0'; *in_br = '\0';
@ -438,7 +438,7 @@ get_any_string (size_t idx, sb *in, sb *out)
--in_br; --in_br;
else else
{ {
br_buf = (char *) xmalloc (strlen (in_br) + 2); br_buf = XNEWVEC (char, strlen (in_br) + 2);
strcpy (br_buf + 1, in_br); strcpy (br_buf + 1, in_br);
free (in_br); free (in_br);
in_br = br_buf; in_br = br_buf;
@ -1287,7 +1287,7 @@ delete_macro (const char *name)
macro_entry *macro; macro_entry *macro;
len = strlen (name); len = strlen (name);
copy = (char *) xmalloc (len + 1); copy = XNEWVEC (char, len + 1);
for (i = 0; i < len; ++i) for (i = 0; i < len; ++i)
copy[i] = TOLOWER (name[i]); copy[i] = TOLOWER (name[i]);
copy[i] = '\0'; copy[i] = '\0';

View file

@ -533,7 +533,7 @@ generate_asm_file (int type, const char *file)
/* Allocate enough space for the file name (possibly extended with /* Allocate enough space for the file name (possibly extended with
doubled up backslashes), the symbol name, and the other characters doubled up backslashes), the symbol name, and the other characters
that make up a stabs file directive. */ 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++ = '"'; *bufp++ = '"';
@ -629,13 +629,13 @@ stabs_generate_asm_lineno (void)
if (in_dot_func_p) 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, sprintf (buf, "%d,0,%d,%s-%s\n", N_SLINE, lineno,
sym, current_function_label); sym, current_function_label);
} }
else else
{ {
buf = (char *) xmalloc (100); buf = XNEWVEC (char, 100);
sprintf (buf, "%d,0,%d,%s\n", N_SLINE, lineno, sym); sprintf (buf, "%d,0,%d,%s\n", N_SLINE, lineno, sym);
} }
input_line_pointer = buf; input_line_pointer = buf;

View file

@ -63,7 +63,7 @@ subseg_change (segT seg, int subseg)
if (! seginfo) if (! seginfo)
{ {
seginfo = (segment_info_type *) xcalloc (1, sizeof (*seginfo)); seginfo = XCNEW (segment_info_type);
seginfo->bfd_section = seg; seginfo->bfd_section = seg;
bfd_set_section_userdata (stdoutput, seg, seginfo); bfd_set_section_userdata (stdoutput, seg, seginfo);
} }
@ -165,7 +165,7 @@ subseg_get (const char *segname, int force_new)
if (! seginfo) if (! seginfo)
{ {
secptr->output_section = secptr; secptr->output_section = secptr;
seginfo = (segment_info_type *) xcalloc (1, sizeof (*seginfo)); seginfo = XCNEW (segment_info_type);
seginfo->bfd_section = secptr; seginfo->bfd_section = secptr;
bfd_set_section_userdata (stdoutput, secptr, seginfo); bfd_set_section_userdata (stdoutput, secptr, seginfo);
} }

View file

@ -1639,7 +1639,7 @@ define_dollar_label (long label)
{ {
dollar_labels = XNEWVEC (long, DOLLAR_LABEL_BUMP_BY); dollar_labels = XNEWVEC (long, DOLLAR_LABEL_BUMP_BY);
dollar_label_instances = 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_max = DOLLAR_LABEL_BUMP_BY;
dollar_label_count = 0; dollar_label_count = 0;
} }
@ -1649,7 +1649,8 @@ define_dollar_label (long label)
dollar_labels = XRESIZEVEC (long, dollar_labels, dollar_label_max); dollar_labels = XRESIZEVEC (long, dollar_labels, dollar_label_max);
dollar_label_instances = XRESIZEVEC (long, dollar_label_instances, dollar_label_instances = XRESIZEVEC (long, dollar_label_instances,
dollar_label_max); 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 */ } /* if we needed to grow */
dollar_labels[dollar_label_count] = label; dollar_labels[dollar_label_count] = label;
@ -3075,11 +3076,11 @@ symbol_relc_make_sym (symbolS * sym)
sname_len = strlen (sname); sname_len = strlen (sname);
typetag = symbol_section_p (sym) ? 'S' : 's'; typetag = symbol_section_p (sym) ? 'S' : 's';
terminal = xmalloc (1 /* S or s */ terminal = XNEWVEC (char, (1 /* S or s */
+ 8 /* sname_len in decimal */ + 8 /* sname_len in decimal */
+ 1 /* _ spacer */ + 1 /* _ spacer */
+ sname_len /* name itself */ + sname_len /* name itself */
+ 1 /* \0 */ ); + 1 /* \0 */ ));
sprintf (terminal, "%c%d:%s", typetag, sname_len, sname); sprintf (terminal, "%c%d:%s", typetag, sname_len, sname);
return terminal; return terminal;

View file

@ -1234,7 +1234,7 @@ write_relocs (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
rp = &r->next; rp = &r->next;
} }
relocs = (arelent **) xcalloc (n, sizeof (arelent *)); relocs = XCNEWVEC (arelent *, n);
n = 0; n = 0;
r = my_reloc_list; r = my_reloc_list;