From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70245 invoked by alias); 4 Apr 2016 00:24:55 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 70226 invoked by uid 89); 4 Apr 2016 00:24:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL,BAYES_80,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 spammy=sk:allocat, asc, appc, XNEW X-HELO: mail-pa0-f42.google.com Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 04 Apr 2016 00:24:40 +0000 Received: by mail-pa0-f42.google.com with SMTP id tt10so131643635pab.3 for ; Sun, 03 Apr 2016 17:24:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=b77Z30UQdd+GkTUtB5+1pXWo2oqHDr1vgxTEZgyyv7Y=; b=XWI/xoOHCcwfAOJ/KRS8i9Oz8CeIrY/6G+/pZqqQcsOiVYuCE/6sVtrYt12ryTyGm8 jgAYZRluEDqYj8frY5jNuTE9Z0aGJ7ZXNkaH/KFb8Qv5Y/26UVtqwD4+hdmAZy9Gsp/U YLPzTQhzvke/xzaXJDi1fhMQyqCoahSi+SmpD3u75JGG5h/7YkElisuH9dTolXD0+Bor 6TJSjQfbhefUm2NWOIsn2eYn14VB1qS1+Y5RFKXC96ELcIOch5djcKWIn+tvkPZCXucF iQgaFBx/EqRbfhciw36HRjbAKNfIVPLAEddXlQRDJyasMM3kqGBoNBikV8yK1dV6teRo Ui+g== X-Gm-Message-State: AD7BkJIW63OsduUBPAwCmQXwKMSlEHk9MTzRP41mWR7wkMLfh/t1jW33xSS6uI4JjroGWA== X-Received: by 10.66.178.238 with SMTP id db14mr48995123pac.157.1459729478757; Sun, 03 Apr 2016 17:24:38 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id p74sm34740545pfj.22.2016.04.03.17.24.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Apr 2016 17:24:37 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id D70B6EA0153; Mon, 4 Apr 2016 09:54:33 +0930 (ACST) Date: Mon, 04 Apr 2016 00:24:00 -0000 From: Alan Modra To: tbsaunde+binutils@tbsaunde.org Cc: binutils@sourceware.org Subject: Re: [PATCH] use XNEW and related macros more Message-ID: <20160404002433.GO27246@bubble.grove.modra.org> References: <1459702561-15836-1-git-send-email-tbsaunde+binutils@tbsaunde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1459702561-15836-1-git-send-email-tbsaunde+binutils@tbsaunde.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00039.txt.bz2 On Sun, Apr 03, 2016 at 12:56:01PM -0400, tbsaunde+binutils@tbsaunde.org wrote: > * app.c (app_push): use XNEW macro. > * as.c: Likewise. > * config/obj-elf.c (obj_elf_change_section): Likewise. > (elf_copy_symbol_attributes): Likewise. > (obj_elf_size): Likewise. > (build_group_lists): Likewise. > * config/tc-aarch64.c (add_operand_error_record): Likewise. > (md_assemble): Likewise. > (tc_gen_reloc): Likewise. > (get_upper_str): Likewise. > (aarch64_parse_features): Likewise. > * config/tc-arm.c (insert_reg_alias): Likewise. > (insert_neon_reg_alias): Likewise. > (find_or_make_literal_pool): Likewise. > (s_arm_elf_cons): Likewise. > (add_unwind_opcode): Likewise. > (arm_parse_extension): Likewise. > * config/tc-avr.c (create_record_for_frag): Likewise. > * config/tc-crx.c: Likewise. > * config/tc-d30v.c: Likewise. > * config/tc-dlx.c (s_proc): Likewise. > * config/tc-ft32.c: Likewise. > * config/tc-h8300.c: Likewise. > * config/tc-hppa.c (pa_proc): Likewise. > (create_new_space): Likewise. > (create_new_subspace): Likewise. > * config/tc-i860.c: Likewise. > * config/tc-i960.c: Likewise. > * config/tc-ia64.c: Likewise. > * config/tc-iq2000.c (iq2000_add_macro): Likewise. > (iq2000_record_hi16): Likewise. > * config/tc-m32c.c (m32c_indirect_operand): Likewise. > * config/tc-m32r.c (debug_sym): Likewise. > (m32r_record_hi16): Likewise. > * config/tc-m68k.c (m68k_ip): Likewise. > (md_begin): Likewise. > * config/tc-mcore.c: Likewise. > * config/tc-microblaze.c (check_got): Likewise. > * config/tc-mips.c (append_insn): Likewise. > (s_mipsset): Likewise. > (mips_record_label): Likewise. > (s_mips_end): Likewise. > * config/tc-mmix.c (mmix_frob_file): Likewise. > * config/tc-mn10200.c: Likewise. > * config/tc-mn10300.c: Likewise. > * config/tc-moxie.c: Likewise. > * config/tc-msp430.c: Likewise. > * config/tc-nds32.c (nds32_elf_save_pseudo_pattern): Likewise. > * config/tc-ns32k.c: Likewise. > * config/tc-or1k.c: Likewise. > * config/tc-pdp11.c: Likewise. > * config/tc-pj.c (fake_opcode): Likewise. > * config/tc-ppc.c (ppc_apuinfo_section_add): Likewise. > (ppc_macro): Likewise. > (ppc_dwsect): Likewise. > (ppc_machine): Likewise. > * config/tc-rl78.c (rl78_frag_init): Likewise. > * config/tc-rx.c (rx_frag_init): Likewise. > * config/tc-s390.c (s390_lit_suffix): Likewise. > (s390_machine): Likewise. > (s390_machinemode): Likewise. > * config/tc-score.c (s3_insert_reg): Likewise. > (s3_gen_reloc): Likewise. > * config/tc-score7.c (s7_insert_reg): Likewise. > (s7_gen_reloc): Likewise. > * config/tc-tic30.c (tic30_operand): Likewise. > * config/tc-tic4x.c (tic4x_inst_make): Likewise. > * config/tc-tic54x.c (stag_add_field): Likewise. > (tic54x_struct): Likewise. > (tic54x_space): Likewise. > (tic54x_field): Likewise. > (tic54x_mlib): Likewise. > (subsym_substitute): Likewise. > * config/tc-tic6x.c (tic6x_frob_label): Likewise. > * config/tc-vax.c: Likewise. > * config/tc-xc16x.c: Likewise. > * config/tc-xtensa.c (xtensa_add_insn_label): Likewise. > (directive_push): Likewise. > (xtensa_begin_directive): Likewise. > (tokenize_arguments): Likewise. > (xtensa_add_literal_sym): Likewise. > (new_resource_table): Likewise. > (resize_resource_table): Likewise. > (emit_single_op): Likewise. > (xtensa_create_trampoline_frag): Likewise. > (xtensa_maybe_create_literal_pool_frag): Likewise. > (xtensa_add_config_info): Likewise. > (xtensa_realloc_fixup_cache): Likewise. > (add_subseg_info): Likewise. > (cache_literal_section): Likewise. > (add_xt_block_frags): Likewise. > (add_xt_prop_frags): Likewise. > (init_op_placement_info_table): Likewise. > (build_section_rename): Likewise. > * config/tc-z80.c: Likewise. > * config/tc-z8k.c: Likewise. > * depend.c (register_dependency): Likewise. > * dwarf2dbg.c (get_line_subseg): Likewise. > (dwarf2_gen_line_info_1): Likewise. > (get_filenum): Likewise. > * ecoff.c (allocate_scope): Likewise. > (allocate_vlinks): Likewise. > (allocate_shash): Likewise. > (allocate_thash): Likewise. > (allocate_tag): Likewise. > (allocate_forward): Likewise. > (allocate_thead): Likewise. > (allocate_lineno_list): Likewise. > * expr.c (make_expr_symbol): Likewise. > * hash.c (hash_new_sized): Likewise. > * input-file.c (input_file_push): Likewise. > * listing.c (file_info): Likewise. > (listing_newline): Likewise. > * macro.c (new_formal): Likewise. > (define_macro): Likewise. > * remap.c (add_debug_prefix_map): Likewise. > * symbols.c (symbol_find_noref): Likewise. > (define_dollar_label): Likewise. > (fb_label_instance_inc): Likewise. > (symbol_relc_make_value): Likewise. OK with a couple of tweaks. Nice to see the extraneous checks on xmalloc disappear in tc-aarch64.c and elsewhere, and replacement of malloc in tc-dlx.c. > --- a/gas/config/tc-hppa.c > +++ b/gas/config/tc-hppa.c > @@ -1388,8 +1388,8 @@ tc_gen_reloc (asection *section, fixS *fixp) > for (n_relocs = 0; codes[n_relocs]; n_relocs++) > ; > > - relocs = xmalloc (sizeof (arelent *) * n_relocs + 1); > - reloc = xmalloc (sizeof (arelent) * n_relocs); > + relocs = XNEWVEC (arelent *, n_relocs + 1); > + reloc = XNEWVEC (arelent, n_relocs); > for (i = 0; i < n_relocs; i++) > relocs[i] = &reloc[i]; > Also, nice catch here. > diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c > index f148845..9f18b17 100644 > --- a/gas/config/tc-m68k.c > +++ b/gas/config/tc-m68k.c > @@ -4599,7 +4599,7 @@ md_begin (void) > /* First sort the opcode table into alphabetical order to seperate > the order that the assembler wants to see the opcodes from the > order that the disassembler wants to see them. */ > - m68k_sorted_opcodes = xmalloc (m68k_numopcodes * sizeof (* m68k_sorted_opcodes)); > + m68k_sorted_opcodes = XNEWVEC (const struct m68k_opcode *, m68k_numopcodes); > if (!m68k_sorted_opcodes) > as_fatal (_("Internal Error: Can't allocate m68k_sorted_opcodes of size %d"), > m68k_numopcodes * ((int) sizeof (* m68k_sorted_opcodes))); While you're at it, please delete this useless check on xmalloc return value. > @@ -7456,7 +7454,7 @@ xtensa_create_trampoline_frag (bfd_boolean needs_jump_around) > trampoline_buf = xtensa_insnbuf_alloc (xtensa_default_isa); > trampoline_slotbuf = xtensa_insnbuf_alloc (xtensa_default_isa); > } > - tf = (struct trampoline_frag *)xmalloc(sizeof (struct trampoline_frag)); > + tf = XNEW(struct trampoline_frag); > tf->next = ts->trampoline_list.next; > ts->trampoline_list.next = tf; > tf->needs_jump_around = needs_jump_around; Formatting. > @@ -7621,7 +7619,7 @@ xtensa_maybe_create_literal_pool_frag (bfd_boolean create, > fragP = frag_now; > } > > - lpf = (struct litpool_frag *)xmalloc(sizeof (struct litpool_frag)); > + lpf = XNEW(struct litpool_frag); > /* Insert at tail of circular list. */ > lpf->addr = 0; > lps->frag_list.prev->next = lpf; and here. -- Alan Modra Australia Development Lab, IBM