From patchwork Thu Sep 22 17:50:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 15937 Received: (qmail 14937 invoked by alias); 22 Sep 2016 17:51:20 -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 14726 invoked by uid 89); 22 Sep 2016 17:51:18 -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=H*r:4.86_1, H*F:U*tom X-HELO: gproxy10-pub.mail.unifiedlayer.com Received: from gproxy10-pub.mail.unifiedlayer.com (HELO gproxy10-pub.mail.unifiedlayer.com) (69.89.20.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Thu, 22 Sep 2016 17:51:08 +0000 Received: (qmail 8927 invoked by uid 0); 22 Sep 2016 17:51:06 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy10.mail.unifiedlayer.com with SMTP; 22 Sep 2016 17:51:06 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id mhr21t0012f2jeq01hr52b; Thu, 22 Sep 2016 11:51:05 -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=NDmkIkTCrRtSUSVVWsQA:9 a=PoFcczfD35Bi4qvJ:21 a=TYQjXf6z23BNbEf6:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-16-151-161.hlrn.qwest.net ([174.16.151.161]:51340 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_1) (envelope-from ) id 1bn89F-0001Dg-OV; Thu, 22 Sep 2016 11:51:01 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 4/5] Use std::vector in objfiles.c Date: Thu, 22 Sep 2016 11:50:55 -0600 Message-Id: <1474566656-15389-5-git-send-email-tom@tromey.com> In-Reply-To: <1474566656-15389-1-git-send-email-tom@tromey.com> References: <1474566656-15389-1-git-send-email-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1bn89F-0001Dg-OV X-Source-Sender: 174-16-151-161.hlrn.qwest.net (bapiya.Home) [174.16.151.161]:51340 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This patch changes a spot in objfiles.c to use a std::vector, removing a cleanup. 2016-09-22 Tom Tromey * objfiles.c: Include . (objfile_relocate): Use std::vector. --- gdb/ChangeLog | 5 +++++ gdb/objfiles.c | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 670406d..92e79c3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2016-09-22 Tom Tromey + * objfiles.c: Include . + (objfile_relocate): Use std::vector. + +2016-09-22 Tom Tromey + * rust-lang.c: Include and . (rust_evaluate_funcall): Use std::vector, std::string. (rust_evaluate_subexp): Use std::string. diff --git a/gdb/objfiles.c b/gdb/objfiles.c index f022d10..bf594a1 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -53,6 +53,8 @@ #include "gdb_bfd.h" #include "btrace.h" +#include + /* Keep a registry of per-objfile data-pointers required by other GDB modules. */ @@ -943,7 +945,7 @@ objfile_relocate (struct objfile *objfile, debug_objfile = objfile_separate_debug_iterate (objfile, debug_objfile)) { struct section_addr_info *objfile_addrs; - struct section_offsets *new_debug_offsets; + std::vector new_debug_offsets; struct cleanup *my_cleanups; objfile_addrs = build_section_addr_info_from_objfile (objfile); @@ -956,15 +958,13 @@ objfile_relocate (struct objfile *objfile, gdb_assert (debug_objfile->num_sections == gdb_bfd_count_sections (debug_objfile->obfd)); - new_debug_offsets = - ((struct section_offsets *) - xmalloc (SIZEOF_N_SECTION_OFFSETS (debug_objfile->num_sections))); - make_cleanup (xfree, new_debug_offsets); - relative_addr_info_to_section_offsets (new_debug_offsets, + new_debug_offsets + .reserve (SIZEOF_N_SECTION_OFFSETS (debug_objfile->num_sections)); + relative_addr_info_to_section_offsets (new_debug_offsets.data (), debug_objfile->num_sections, objfile_addrs); - changed |= objfile_relocate1 (debug_objfile, new_debug_offsets); + changed |= objfile_relocate1 (debug_objfile, new_debug_offsets.data ()); do_cleanups (my_cleanups); }