aboutsummaryrefslogtreecommitdiff
path: root/gdb/xcoffread.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-02-19 13:08:32 +0000
committerAndrew Burgess <aburgess@redhat.com>2022-02-21 11:40:39 +0000
commit9c6c44713f31f7b27bfe6921de378fa69127a048 (patch)
treea92572af687abed7335d56c0dd8942c9d721d5b8 /gdb/xcoffread.c
parentdc5483c989f29fc9c7934965071ae1bb80cff902 (diff)
downloadgdb-9c6c44713f31f7b27bfe6921de378fa69127a048.zip
gdb-9c6c44713f31f7b27bfe6921de378fa69127a048.tar.gz
gdb-9c6c44713f31f7b27bfe6921de378fa69127a048.tar.bz2
gdb: make use of std::string in dbxread.c and xcoffread.c
While taking a look through dbxread.c I spotted a couple of places where making use of std::string would remove the need for manual memory allocation and memcpy. During review Simon pointed out that the same code exists in xcoffread.c, so I've applied the same fix there too. There should be no user visible changes after this commit.
Diffstat (limited to 'gdb/xcoffread.c')
-rw-r--r--gdb/xcoffread.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index d3e9ade..f6db7f9 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2734,13 +2734,8 @@ scan_xcoff_symtab (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 name (namestring, (p - namestring));
+ function_outside_compilation_unit_complaint (name.c_str ());
}
pst->add_psymbol (gdb::string_view (namestring,
p - namestring),
@@ -2758,13 +2753,8 @@ scan_xcoff_symtab (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 name (namestring, (p - namestring));
+ function_outside_compilation_unit_complaint (name.c_str ());
}
/* We need only the minimal symbols for these