mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 01:28:46 +00:00
Use unique_xmalloc_ptr<char> when demangling
I noticed that some methods in language_defn could use unique_xmalloc_ptr<char> rather than a plain 'char *'. This patch implements this change, fixing up the fallout and changing gdb_demangle to also return this type. In one spot, std::string is used to simplify some related code, and in another, an auto_obstack is used to avoid manual management. Regression tested on x86-64 Fedora 34.
This commit is contained in:
@@ -644,17 +644,14 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
|
||||
possible paths to the method based on the adjustment. */
|
||||
if (physname)
|
||||
{
|
||||
char *demangled_name = gdb_demangle (physname,
|
||||
DMGL_ANSI | DMGL_PARAMS);
|
||||
gdb::unique_xmalloc_ptr<char> demangled_name
|
||||
= gdb_demangle (physname, DMGL_ANSI | DMGL_PARAMS);
|
||||
|
||||
fprintf_filtered (stream, "&virtual ");
|
||||
if (demangled_name == NULL)
|
||||
fputs_filtered (physname, stream);
|
||||
else
|
||||
{
|
||||
fputs_filtered (demangled_name, stream);
|
||||
xfree (demangled_name);
|
||||
}
|
||||
fputs_filtered (demangled_name.get (), stream);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user