diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-02-19 13:08:32 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-02-21 11:40:39 +0000 |
commit | 9c6c44713f31f7b27bfe6921de378fa69127a048 (patch) | |
tree | a92572af687abed7335d56c0dd8942c9d721d5b8 /gdb/dbxread.c | |
parent | dc5483c989f29fc9c7934965071ae1bb80cff902 (diff) | |
download | binutils-9c6c44713f31f7b27bfe6921de378fa69127a048.zip binutils-9c6c44713f31f7b27bfe6921de378fa69127a048.tar.gz binutils-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/dbxread.c')
-rw-r--r-- | gdb/dbxread.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 911d518..ddda5df 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -1603,13 +1603,8 @@ read_dbx_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 ()); } /* Kludges for ELF/STABS with Sun ACC. */ last_function_name = namestring; @@ -1663,13 +1658,8 @@ read_dbx_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 ()); } /* Kludges for ELF/STABS with Sun ACC. */ last_function_name = namestring; |