From patchwork Thu Feb 20 12:10:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ldurfina@tachyum.com X-Patchwork-Id: 38253 Received: (qmail 109735 invoked by alias); 20 Feb 2020 12:10:41 -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 109715 invoked by uid 89); 20 Feb 2020 12:10:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=releasing X-HELO: mail.tachyum.com Received: from Unknown (HELO mail.tachyum.com) (66.160.133.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Feb 2020 12:10:39 +0000 Received: by mail.tachyum.com (Postfix, from userid 1001) id 2D8EE8D6; Wed, 19 Feb 2020 20:10:32 -0800 (PST) Received: from THQ-EX2016.tachyum.com (unknown [10.7.1.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.tachyum.com (Postfix) with ESMTPS id BDFDF8BB for ; Wed, 19 Feb 2020 20:10:31 -0800 (PST) Received: from tachyum-sk-server.tachyum.com (10.7.241.13) by THQ-EX2016.tachyum.com (10.7.1.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Thu, 20 Feb 2020 04:10:36 -0800 From: Lukas Durfina To: Subject: [PATCH] gdb: Simplification in charset.c Date: Thu, 20 Feb 2020 13:10:24 +0100 Message-ID: <20200220121024.116818-1-ldurfina@tachyum.com> MIME-Version: 1.0 Simplification of the code by using std::string. Explicit memory allocation and releasing is removed. gdb/Changelog: 2020-02-20 Lukas Durfina * charset.c (find_charset_names): Simplify. --- gdb/ChangeLog | 4 ++++ gdb/charset.c | 10 +++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e3f7e9f828..f5de45b992 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2020-02-20 Lukas Durfina + + * charset.c (find_charset_names): Simplify. + 2020-02-19 Tom Tromey * symtab.c (general_symbol_info::compute_and_set_names): Use diff --git a/gdb/charset.c b/gdb/charset.c index 4e459c2b45..ffdc663f8b 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -804,7 +804,7 @@ find_charset_names (void) int fail = 1; int flags; gdb_environ iconv_env = gdb_environ::from_host_environ (); - char *iconv_program; + std::string iconv_program = "iconv"; /* Older iconvs, e.g. 2.2.2, don't omit the intro text if stdout is not a tty. We need to recognize it and ignore it. This text is @@ -818,13 +818,10 @@ find_charset_names (void) { std::string iconv_dir = relocate_gdb_directory (ICONV_BIN, ICONV_BIN_RELOCATABLE); - iconv_program - = concat (iconv_dir.c_str(), SLASH_STRING, "iconv", (char *) NULL); + iconv_program = iconv_dir + SLASH_STRING + "iconv"; } -#else - iconv_program = xstrdup ("iconv"); #endif - args[0] = iconv_program; + args[0] = iconv_program.c_str(); args[1] = "-l"; args[2] = NULL; flags = PEX_STDERR_TO_STDOUT; @@ -906,7 +903,6 @@ find_charset_names (void) } - xfree (iconv_program); pex_free (child); if (fail)