Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Lukas Durfina <ldurfina@tachyum.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] gdb: Simplification in charset.c
Date: Thu, 20 Feb 2020 12:10:00 -0000	[thread overview]
Message-ID: <20200220121024.116818-1-ldurfina@tachyum.com> (raw)

Simplification of the code by using std::string.
Explicit memory allocation and releasing is removed.

gdb/Changelog:
2020-02-20 Lukas Durfina <ldurfina@tachyum.com>

       * 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 <ldurfina@tachyum.com>
+
+	* charset.c (find_charset_names): Simplify.
+
 2020-02-19  Tom Tromey  <tom@tromey.com>
 
 	* 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)
-- 
2.17.1


             reply	other threads:[~2020-02-20 12:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 12:10 Lukas Durfina [this message]
2020-02-20 14:54 ` Simon Marchi
2020-02-20 15:01   ` Lukas Durfina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200220121024.116818-1-ldurfina@tachyum.com \
    --to=ldurfina@tachyum.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox