From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113289 invoked by alias); 23 May 2018 04:59:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 113115 invoked by uid 89); 23 May 2018 04:59:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=management X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.145.119) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 May 2018 04:59:00 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway32.websitewelcome.com (Postfix) with ESMTP id E64EDC4BE2 for ; Tue, 22 May 2018 23:58:58 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id LLrWfrogoPvAdLLrWf7FEh; Tue, 22 May 2018 23:58:58 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:56108 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fLLrW-003S5D-MV; Tue, 22 May 2018 23:58:58 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 02/42] Change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr Date: Wed, 23 May 2018 04:59:00 -0000 Message-Id: <20180523045851.11660-3-tom@tromey.com> In-Reply-To: <20180523045851.11660-1-tom@tromey.com> References: <20180523045851.11660-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fLLrW-003S5D-MV X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:56108 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-05/txt/msg00576.txt.bz2 This change buildsym_compunit::comp_dir to be a unique_xmalloc_ptr. This is just a small cleanup to remove some manual memory management. gdb/ChangeLog 2018-05-22 Tom Tromey * buildsym.c (~buildsym_compunit): Update. (struct buildsym_compunit) : Now a unique_xmalloc_ptr. (start_subfile, patch_subfile_names) (end_symtab_with_blockvector): Update. --- gdb/ChangeLog | 7 +++++++ gdb/buildsym.c | 11 +++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 9863e4ea1e..b747a082b5 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -126,7 +126,6 @@ struct buildsym_compunit xfree (subfile->line_vector); xfree (subfile); } - xfree (comp_dir); } /* The objfile we're reading debug info from. */ @@ -142,7 +141,7 @@ struct buildsym_compunit struct subfile *main_subfile = nullptr; /* E.g., DW_AT_comp_dir if DWARF. Space for this is malloc'd. */ - char *comp_dir; + gdb::unique_xmalloc_ptr comp_dir; /* Space for this is not malloc'd, and is assumed to have at least the same lifetime as objfile. */ @@ -703,7 +702,7 @@ start_subfile (const char *name) gdb_assert (buildsym_compunit != NULL); - subfile_dirname = buildsym_compunit->comp_dir; + subfile_dirname = buildsym_compunit->comp_dir.get (); /* See if this subfile is already registered. */ @@ -824,7 +823,7 @@ patch_subfile_names (struct subfile *subfile, const char *name) && subfile->name != NULL && IS_DIR_SEPARATOR (subfile->name[strlen (subfile->name) - 1])) { - buildsym_compunit->comp_dir = subfile->name; + buildsym_compunit->comp_dir.reset (subfile->name); subfile->name = xstrdup (name); set_last_source_file (name); @@ -1410,10 +1409,10 @@ end_symtab_with_blockvector (struct block *static_block, if (buildsym_compunit->comp_dir != NULL) { /* Reallocate the dirname on the symbol obstack. */ + const char *comp_dir = buildsym_compunit->comp_dir.get (); COMPUNIT_DIRNAME (cu) = (const char *) obstack_copy0 (&objfile->objfile_obstack, - buildsym_compunit->comp_dir, - strlen (buildsym_compunit->comp_dir)); + comp_dir, strlen (comp_dir)); } /* Save the debug format string (if any) in the symtab. */ -- 2.13.6