From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84101 invoked by alias); 23 Sep 2018 04:08:23 -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 84063 invoked by uid 89); 23 Sep 2018 04:08:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_RP_RNBL,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*RU:sk:gateway, Hx-spam-relays-external:sk:gateway, management X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.144.91) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 23 Sep 2018 04:08:20 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway31.websitewelcome.com (Postfix) with ESMTP id A746E1F64F for ; Sat, 22 Sep 2018 23:08:18 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 3vgwgwhMV8YaU3vgwgRPNl; Sat, 22 Sep 2018 23:08:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=49HAsTvSvVL5cZYb1hrlREp1qHWG30R7O51zXu4voAc=; b=ua4E1ZTb8FZsk6pOSWK3sE3DTb C9kvA2j5RAgmRW0VloRhGs5XfwIVMYz4qHVf7muvsluLmdlvtfZgIwX7p9tJEMTpJlPy4Sc7DqXIV b79G7YX6pmHzVPdHjSUxT8HCn; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:37440 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1g3vgw-002UJa-Ef; Sat, 22 Sep 2018 23:08:18 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/8] Use std::string in mdebugread.c Date: Sun, 23 Sep 2018 04:08:00 -0000 Message-Id: <20180923040814.27941-4-tom@tromey.com> In-Reply-To: <20180923040814.27941-1-tom@tromey.com> References: <20180923040814.27941-1-tom@tromey.com> X-SW-Source: 2018-09/txt/msg00756.txt.bz2 This changes a couple of spots in mdebugread to use std::string rather than manual management. This is simpler, and also avoids shadowing by renaming the variable in question. gdb/ChangeLog 2018-09-22 Tom Tromey * mdebugread.c (parse_partial_symbols): Use std::string. --- gdb/ChangeLog | 4 ++++ gdb/mdebugread.c | 20 ++++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 4c433da99f..d959a09ee7 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -3197,13 +3197,9 @@ parse_partial_symbols (minimal_symbol_reader &reader, case 'f': if (! pst) { - int name_len = p - namestring; - char *name = (char *) xmalloc (name_len + 1); - - memcpy (name, namestring, name_len); - name[name_len] = '\0'; - function_outside_compilation_unit_complaint (name); - xfree (name); + std::string copy (namestring, p); + function_outside_compilation_unit_complaint + (copy.c_str ()); } add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_BLOCK, @@ -3220,13 +3216,9 @@ parse_partial_symbols (minimal_symbol_reader &reader, case 'F': if (! pst) { - int name_len = p - namestring; - char *name = (char *) xmalloc (name_len + 1); - - memcpy (name, namestring, name_len); - name[name_len] = '\0'; - function_outside_compilation_unit_complaint (name); - xfree (name); + std::string copy (namestring, p); + function_outside_compilation_unit_complaint + (copy.c_str ()); } add_psymbol_to_list (namestring, p - namestring, 1, VAR_DOMAIN, LOC_BLOCK, -- 2.17.1