]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
use XNEW and related macros more
authorTrevor Saunders <tbsaunde+binutils@tbsaunde.org>
Fri, 1 Apr 2016 13:26:30 +0000 (09:26 -0400)
committerTrevor Saunders <tbsaunde+binutils@tbsaunde.org>
Mon, 4 Apr 2016 00:43:23 +0000 (20:43 -0400)
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.

58 files changed:
gas/ChangeLog
gas/app.c
gas/as.c
gas/config/obj-elf.c
gas/config/tc-aarch64.c
gas/config/tc-arm.c
gas/config/tc-avr.c
gas/config/tc-crx.c
gas/config/tc-d30v.c
gas/config/tc-dlx.c
gas/config/tc-ft32.c
gas/config/tc-h8300.c
gas/config/tc-hppa.c
gas/config/tc-i860.c
gas/config/tc-i960.c
gas/config/tc-ia64.c
gas/config/tc-iq2000.c
gas/config/tc-m32c.c
gas/config/tc-m32r.c
gas/config/tc-m68k.c
gas/config/tc-mcore.c
gas/config/tc-microblaze.c
gas/config/tc-mips.c
gas/config/tc-mmix.c
gas/config/tc-mn10200.c
gas/config/tc-mn10300.c
gas/config/tc-moxie.c
gas/config/tc-msp430.c
gas/config/tc-nds32.c
gas/config/tc-ns32k.c
gas/config/tc-or1k.c
gas/config/tc-pdp11.c
gas/config/tc-pj.c
gas/config/tc-ppc.c
gas/config/tc-rl78.c
gas/config/tc-rx.c
gas/config/tc-s390.c
gas/config/tc-score.c
gas/config/tc-score7.c
gas/config/tc-tic30.c
gas/config/tc-tic4x.c
gas/config/tc-tic54x.c
gas/config/tc-tic6x.c
gas/config/tc-vax.c
gas/config/tc-xc16x.c
gas/config/tc-xtensa.c
gas/config/tc-z80.c
gas/config/tc-z8k.c
gas/depend.c
gas/dwarf2dbg.c
gas/ecoff.c
gas/expr.c
gas/hash.c
gas/input-file.c
gas/listing.c
gas/macro.c
gas/remap.c
gas/symbols.c

index a85506e39b841226f2e0b68cec9db7c799b01f48..e1e6ab5f53e36a000050caf0610293b93fdc6729 100644 (file)
@@ -1,3 +1,126 @@
+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.
+
 2016-04-03  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>
 
        * config/obj-elf.c (obj_elf_vendor_attribute): Use xstrdup.
index f53e7ce4134af9585d46b57ce02ab579e9ac6c86..c59421c059a564edc7a1b132dffc8df7fe1f7eb9 100644 (file)
--- 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;
index cf8e90d743049d6714834eac36d0f55e2623d091..15f53ea462af48c6f899e77c9050c62becb095e1 100644 (file)
--- 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;
index 68290e21cedfbefc6d309d11f8239cfa1d53827d..ea9f7abda85b587c2d9fd688e3a82b55cc033cce 100644 (file)
@@ -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);
 }
index 14b60115103f7012439e186cb1149199efd81a3e..8fb93ee2b6234f5d0d2707728555c63ea23eab71 100644 (file)
@@ -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;
index e0448a8a0b25b8ac80eab093e6ad4e11369a8bc3..99fd6303d7c32b3655be6f89a9df19ab619c8b01 100644 (file)
@@ -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
index 999ffb487153f3572774a1d56a747f3ff33bc1d7..abcbcc77ecea6f52bbf0089b1562d85020c9a76f 100644 (file)
@@ -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)
index 7c8d7ed099b36e536897872951e92b76a57fdd47..7993e728a5b34cda6dacbc5acceaae861a015730 100644 (file)
@@ -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;
index ae870eee5ea80d78172691db41cb04715a05e620..88fc124377a3f410f2221dfc8f4fc769e694416b 100644 (file)
@@ -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);
index a806fe60d63c4cc0b0839d09d80e4345b794cda7..b636cece1a7d64f3b40b2b402be631cba10865d7 100644 (file)
@@ -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;
 
index 56c0a682a6ea57eb45c449d5d14e137ebbddcee4..505d12667fa4da50617ea3542bf444cb96e64199 100644 (file)
@@ -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;
 
index edca456c5ce4a2be7942415d664c9debd96c0257..5100f0d8bbb00a9612ea1b237b0e127fc9f0e91c 100644 (file)
@@ -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;
index 82d33c2b7f0f96c161b18141529d06dddbebb235..6bf1bba5c4572cf928dbe52d8ffd89ebc1dec0bc 100644 (file)
@@ -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
index 85855e995db18f5619ce5bcfcfda2f203e7b02ea..858d81e9983e8cdddb8c93cbb53a1b5518d55100 100644 (file)
@@ -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;
index 1335da107caa13b7d4c73dd226b2309e537dd9b4..59ef760af318b349792f162b2a1a37e09190d3d7 100644 (file)
@@ -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;
index 8da09e0d58bcfc8b9b3aaf63e6c4baae9350b612..2d10e8ae4f3320baba1cf52a3352600be1bac3c4 100644 (file)
@@ -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;
index f1f7945c59d11c6f98986dfbaa2a040caf682fbd..f150e19d028805563f9ac25ff676c98343854e08 100644 (file)
@@ -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;
index 0219d9bd8e389b6ebf7b579421266b1334537ece..70f0aebd6e1dfd7628c15cbadeea8fc5be63002b 100644 (file)
@@ -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);
index 126ab9c2de4c25b4065520fc40428317b2fbe227..f77c1f180bfd3c8bbaba76e357726f031fac081e 100644 (file)
@@ -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;
 
index f1488459177a47ba2bc53457fefc83f00420dd34..50e910bbe674b7f706d6385f7d8cbb443419be3d 100644 (file)
@@ -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,10 +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));
-  if (!m68k_sorted_opcodes)
-    as_fatal (_("Internal Error:  Can't allocate m68k_sorted_opcodes of size %d"),
-             m68k_numopcodes * ((int) sizeof (* m68k_sorted_opcodes)));
+  m68k_sorted_opcodes = XNEWVEC (const struct m68k_opcode *, m68k_numopcodes);
 
   for (i = m68k_numopcodes; i--;)
     m68k_sorted_opcodes[i] = m68k_opcodes + i;
index 67d1ea8e29d355788b6513358b4a8376dc0b1205..f8b934dca63fe8fc3ff9bb10c30eb36ac4445a08 100644 (file)
@@ -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!  */
index e720ee82d63e26c030ab3cf61026b2e91e917aea..ceb4365c4e01b76914dec6c31f91700eea591217 100644 (file)
@@ -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);
index ca1098b7c17fb1d3566577247f59aa0b049a967a..b596b8bb0b1f91a8a798833a3dce309be8c7de4a 100644 (file)
@@ -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;
index d6992b480878fb683e3524e6eb9511ede71f725b..d3d971de8ee663dbca6cb8eef96d4fc58cb4c4b2 100644 (file)
@@ -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;
index 2cdfa68fa0fb9f20221df6502ec1d81d9d56b899..1831b9fd1c59be0d87a9cc446935a75065171038 100644 (file)
@@ -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;
index 9a5d3bed5dcb6f78185b4b7b23286f79a1eb5966..52c37e18a7b08331b281dd57cfe2fb42368d501d 100644 (file)
@@ -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;
     }
index 24c9aec05aaab0a209092e8cfc0456f1d5d85feb..9201cb58262e97ae1969b073b315c25ffdef9ba5 100644 (file)
@@ -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;
 
index 3621fdb42add0e357bdb13cc3f891a7dbab53433..817ab452cac37c32e1f6206c32d55a9efd32ce96 100644 (file)
@@ -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;
 
index 897561d7e0f19f2f45a66527f73703719eb59ed5..4e6561602174fbea60df3590cf6b92eddad80f09 100644 (file)
@@ -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;
index 0af829f947a1a1fc3f3241fe6c82f99e37fa45c6..86a1de77ebbec1b3cf41403c0f3f9dc8eb516503 100644 (file)
@@ -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)
index 10fd2de7363ed754277e6f1401ff1c5dd6ba1ffb..383c613789328e21ffc3cbd23bd03ad05e19639c 100644 (file)
@@ -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;
 
index 529df4f0140ed8cffe3c1905eb772fb4a7b8038a..f6cf0251dc2634bb3ae5f5c6f935cb4d6cea9545 100644 (file)
@@ -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;
 
index 6a947fabe64986b3224afa7f86e2ccf2bbc28b31..37fd4814977f8a66b3f07333baee2ba847a88912 100644 (file)
@@ -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;
 
index 23a84a78f6ee20cf0da85f2ed5e7d818121657c3..1d2c57f0293b1debaca194a7cfbe7ec5a6a9c933 100644 (file)
@@ -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);
index 0ecdb15a8bffd623896b47fd226b17d0f02c120f..0739d341a5cd5cf693d980eb3fea9c098231509c 100644 (file)
@@ -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
index 435d046acb194a60fac9de81fc3daa20fba4f9e2..e0af5b5162131b67d41a49737d32f27c1881e524 100644 (file)
@@ -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;
index e2677f72673fff6743bd3b8fa380c852acc894e8..098debc8d2d88baab1715c3138b958f78dfec18c 100644 (file)
@@ -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);
index a509da7c35a5dffab06e2fad487c3a0d84178a23..f96879b3ab1beae1a5a25f4950cde03f9fa8ff00 100644 (file)
@@ -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;
   const 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));
 
index d6a546d36fd1a3a4a06d8843a3a908c4f7a3094a..941467be3bfcaf13317c9df8ed4c7a08ff28f211 100644 (file)
@@ -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;
   const 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));
 
index 10653ed2e847b97ff7b8721e99043c9020d4f3e8..725691c3acaaa40922bae2bd64015896ec2a2ebc 100644 (file)
@@ -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;
index ba0aa38a34c6a95cf87075c034e116cea189e243..97f830c96bbc5e3a1fb5b5130153d3b3113248f8 100644 (file)
@@ -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;
index 8c33df44960331bbac857a22a252d0f4b3715955..5dd772e015ad06be7b8d2b29f5565cdd6f2e46e1 100644 (file)
@@ -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;
index 2135dbf225b3e33de6d89e787bf5e35a77636b5d..ebeafc33e3c0d740d75d048e236c3acbce7bd8bd 100644 (file)
@@ -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;
index 538a9941d583ef90df210c213bcf8cc7e4ed8abd..33ef6e3f0f460f0b0e8f948fdb1aebd8d7c9d8fd 100644 (file)
@@ -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
index 1fb964bc7b5ccbc4cb4ea9de9088352af481b971..49c097051c1205454642ba49e8e9a9f067d7e11c 100644 (file)
@@ -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;
index c00641828ee6afbd256ab481495543ed51c9a915..b7d15823b12fcd3a569a959c78dd00121262f900 100644 (file)
@@ -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;
index 7b1e72ab4698733913ad68d005c2516fddbe697a..dcc74f6ed58a60c310551ebd27926fe143fe87bc 100644 (file)
@@ -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);
index 6a0d596799ea6b632a3ad1ed308226f07ccff8be..265adc6ac24f8304b74c4ca296c518d91641425d 100644 (file)
@@ -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;
index 2dd35a4470c67b0c7011b67a317019607053c3e1..7203e59746f0d11e49340f263712a6c150dbca2f 100644 (file)
@@ -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;
index c719a5a952dd70a880f86ff84b399cc118db4d4e..27b264634bcee2353eb347855c275db562c98da0 100644 (file)
@@ -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));
     }
index 25c3d94bcd0acaaf8e9b138f9d22c40ba3b72508..e7d7ab6cf7b221e926c800086ee127a7950f4c63 100644 (file)
@@ -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
 
index ddf0bc26f602016087c2ae4943b7dea04427e2e0..c6c730ea80e37499252f59c78718ec5629db3701 100644 (file)
@@ -106,7 +106,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;
index 09925f02120612ccef59f7a9a6fb26408cc170f1..655ddfcc5264d6dfad5dd34b98319fafdbc7976a 100644 (file)
@@ -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);
index a3dcd9d2f89c291382368706ce0ee51c65bef223..8b9830f07386b0861008fee2ab50af9de9e59e77 100644 (file)
@@ -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;
index 53e84aba311ce62033e920f58707b2532d0411ca..c90c575a5aff3aec6c8d136b43897ba25367c23c 100644 (file)
@@ -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;
     }
 
index cddf26ab79ea23599d449f5b817f508181aa7907..615bfdae4fdd137a210ed7a8325cffa29f7b16ca 100644 (file)
@@ -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 (&macro->sub);
   sb_new (&name);
   macro->file = file;
index 87eda013289480850812d8c357df76208ee3c79d..2af7a9e87ffdf9d1d94305aa9887e1dc5385feba 100644 (file)
@@ -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;
index c69e400fb83bbfc3adc463d3dfa3a2e92550aed3..642f6d771b40ca45432a189da32ea5f8d907f32e 100644 (file)
@@ -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);