From patchwork Thu Oct 13 21:10:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 16487 Received: (qmail 2332 invoked by alias); 13 Oct 2016 21:11:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 2133 invoked by uid 89); 13 Oct 2016 21:11:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=obfd, symcount, 10247, 1024, 7 X-HELO: gproxy4-pub.mail.unifiedlayer.com Received: from gproxy4-pub.mail.unifiedlayer.com (HELO gproxy4-pub.mail.unifiedlayer.com) (69.89.23.142) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Thu, 13 Oct 2016 21:11:07 +0000 Received: (qmail 27089 invoked by uid 0); 13 Oct 2016 21:11:05 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy4.mail.unifiedlayer.com with SMTP; 13 Oct 2016 21:11:05 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id v9AP1t00M2f2jeq019ASum; Thu, 13 Oct 2016 15:10:26 -0600 X-Authority-Analysis: v=2.1 cv=IecUBwaa c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=CH0kA5CcgfcA:10 a=zstS-IiYAAAA:8 a=mQ4VAuxrAnY1VuYJCYEA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-16-143-211.hlrn.qwest.net ([174.16.143.211]:42448 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bunGg-00011Z-UK; Thu, 13 Oct 2016 15:10:23 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 11/17] Use gdb::unique_ptr in elf_read_minimal_symbols Date: Thu, 13 Oct 2016 15:10:06 -0600 Message-Id: <1476393012-29987-12-git-send-email-tom@tromey.com> In-Reply-To: <1476393012-29987-1-git-send-email-tom@tromey.com> References: <1476393012-29987-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1bunGg-00011Z-UK X-Source-Sender: 174-16-143-211.hlrn.qwest.net (bapiya.Home) [174.16.143.211]:42448 X-Source-Auth: tom+tromey.com X-Email-Count: 12 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This changes elf_read_minimal_symbols to use gdb::unique_ptr rather than an explicit allocation. This removes a cleanup. 2016-09-26 Tom Tromey * elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr. --- gdb/ChangeLog | 4 ++++ gdb/elfread.c | 11 +++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0d5f425..ea777f6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2016-09-26 Tom Tromey + * elfread.c (elf_read_minimal_symbols): Use gdb::unique_ptr. + +2016-09-26 Tom Tromey + * cli/cli-dump.c (dump_memory_to_file): Use gdb::unique_ptr. (restore_binary_file): Likewise. diff --git a/gdb/elfread.c b/gdb/elfread.c index 56fac28..485e55d 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1024,7 +1024,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, const struct elfinfo *ei) { bfd *synth_abfd, *abfd = objfile->obfd; - struct cleanup *back_to; long symcount = 0, dynsymcount = 0, synthcount, storage_needed; asymbol **symbol_table = NULL, **dyn_symbol_table = NULL; asymbol *synthsyms; @@ -1053,7 +1052,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, } minimal_symbol_reader reader (objfile); - back_to = make_cleanup (null_cleanup, NULL); /* Allocate struct to keep track of the symfile. */ dbx = XCNEW (struct dbx_symfile_info); @@ -1135,16 +1133,14 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, &synthsyms); if (synthcount > 0) { - asymbol **synth_symbol_table; long i; - make_cleanup (xfree, synthsyms); - synth_symbol_table = XNEWVEC (asymbol *, synthcount); + gdb::unique_ptr + synth_symbol_table (new asymbol *[synthcount]); for (i = 0; i < synthcount; i++) synth_symbol_table[i] = synthsyms + i; - make_cleanup (xfree, synth_symbol_table); elf_symtab_read (reader, objfile, ST_SYNTHETIC, synthcount, - synth_symbol_table, 1); + synth_symbol_table.get (), 1); } /* Install any minimal symbols that have been collected as the current @@ -1154,7 +1150,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, which will do this. */ reader.install (); - do_cleanups (back_to); if (symtab_create_debug) fprintf_unfiltered (gdb_stdlog, "Done reading minimal symbols.\n");