From patchwork Tue Sep 27 04:08:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 16047 Received: (qmail 85173 invoked by alias); 27 Sep 2016 04:41:27 -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 84695 invoked by uid 89); 27 Sep 2016 04:41:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=H*r:4.86_1, H*F:U*tom, xfree, reader 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; Tue, 27 Sep 2016 04:41:15 +0000 Received: (qmail 803 invoked by uid 0); 27 Sep 2016 04:41:14 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy4.mail.unifiedlayer.com with SMTP; 27 Sep 2016 04:41:14 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id oUhB1t00D2f2jeq01UhEQu; Mon, 26 Sep 2016 22:41:14 -0600 X-Authority-Analysis: v=2.1 cv=Hq7lRSjS 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=GW1xBdLrtEIA:10 a=zstS-IiYAAAA:8 a=0VJFdCUJ44vDvIniMikA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 71-218-192-86.hlrn.qwest.net ([71.218.192.86]:56110 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bojhW-0006Nj-OM; Mon, 26 Sep 2016 22:09:02 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 16/22] Use std::vector in elf_read_minimal_symbols Date: Mon, 26 Sep 2016 22:08:44 -0600 Message-Id: <1474949330-4307-17-git-send-email-tom@tromey.com> In-Reply-To: <1474949330-4307-1-git-send-email-tom@tromey.com> References: <1474949330-4307-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1bojhW-0006Nj-OM X-Source-Sender: 71-218-192-86.hlrn.qwest.net (bapiya.Home) [71.218.192.86]:56110 X-Source-Auth: tom+tromey.com X-Email-Count: 23 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This changes elf_read_minimal_symbols to use std::vector rather than an explicit allocation. This removes a cleanup. 2016-09-26 Tom Tromey * elfread.c (elf_read_minimal_symbols): Use std::vector. --- gdb/ChangeLog | 4 ++++ gdb/elfread.c | 11 +++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3744387..770a96f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2016-09-26 Tom Tromey + * elfread.c (elf_read_minimal_symbols): Use std::vector. + +2016-09-26 Tom Tromey + * machoread.c (macho_symfile_read_all_oso): Use std::string. 2016-09-26 Tom Tromey diff --git a/gdb/elfread.c b/gdb/elfread.c index 09ac507..ad38bfe 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -47,6 +47,7 @@ #include "build-id.h" #include "location.h" #include "auxv.h" +#include extern void _initialize_elfread (void); @@ -1024,7 +1025,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 +1053,6 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, } scoped_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 +1134,13 @@ 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); + std::vector synth_symbol_table (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.data (), 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");