public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Use std::string in main_info Date: Fri, 10 Feb 2023 17:09:36 +0000 (GMT) [thread overview] Message-ID: <20230210170936.F12B33858414@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=25eb2931f6f19d5ef48d240774bab488f6d52bf1 commit 25eb2931f6f19d5ef48d240774bab488f6d52bf1 Author: Tom Tromey <tom@tromey.com> Date: Fri Dec 30 11:23:43 2022 -0700 Use std::string in main_info This changes main_info to use std::string. It removes some manual memory management. Diff: --- gdb/symtab.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 9d6ee388ca2..bd73c521b1a 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -104,16 +104,9 @@ static struct block_symbol struct main_info { - main_info () = default; - - ~main_info () - { - xfree (name_of_main); - } - /* Name of "main". */ - char *name_of_main = nullptr; + std::string name_of_main; /* Language of "main". */ @@ -6172,15 +6165,14 @@ set_main_name (const char *name, enum language lang) { struct main_info *info = get_main_info (); - if (info->name_of_main != NULL) + if (!info->name_of_main.empty ()) { - xfree (info->name_of_main); - info->name_of_main = NULL; + info->name_of_main.clear (); info->language_of_main = language_unknown; } if (name != NULL) { - info->name_of_main = xstrdup (name); + info->name_of_main = name; info->language_of_main = lang; } } @@ -6287,10 +6279,10 @@ main_name () { struct main_info *info = get_main_info (); - if (info->name_of_main == NULL) + if (info->name_of_main.empty ()) find_main_name (); - return info->name_of_main; + return info->name_of_main.c_str (); } /* Return the language of the main function. If it is not known, @@ -6301,7 +6293,7 @@ main_language (void) { struct main_info *info = get_main_info (); - if (info->name_of_main == NULL) + if (info->name_of_main.empty ()) find_main_name (); return info->language_of_main;
reply other threads:[~2023-02-10 17:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230210170936.F12B33858414@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).