diff options
author | Tom Tromey <tom@tromey.com> | 2022-12-30 11:23:43 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-02-10 09:57:34 -0700 |
commit | 25eb2931f6f19d5ef48d240774bab488f6d52bf1 (patch) | |
tree | 311fbb0411783a3afc3341b3453c1636c76b07c8 /gdb/symtab.c | |
parent | 632652850db23bfec2499febe03c9ac4aa0b8dce (diff) | |
download | binutils-25eb2931f6f19d5ef48d240774bab488f6d52bf1.zip binutils-25eb2931f6f19d5ef48d240774bab488f6d52bf1.tar.gz binutils-25eb2931f6f19d5ef48d240774bab488f6d52bf1.tar.bz2 |
Use std::string in main_info
This changes main_info to use std::string. It removes some manual
memory management.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index 9d6ee38..bd73c52 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; |