mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 18:08:24 +08: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:
@ -551,7 +551,7 @@ skip_language_trampoline (struct frame_info *frame, CORE_ADDR pc)
|
||||
more flexible demangler for the languages that need it.
|
||||
FIXME: Sometimes the demangler is invoked when we don't know the
|
||||
language, so we can't use this everywhere. */
|
||||
char *
|
||||
gdb::unique_xmalloc_ptr<char>
|
||||
language_demangle (const struct language_defn *current_language,
|
||||
const char *mangled, int options)
|
||||
{
|
||||
@ -771,7 +771,8 @@ public:
|
||||
|
||||
/* See language.h. */
|
||||
|
||||
char *demangle_symbol (const char *mangled, int options) const override
|
||||
gdb::unique_xmalloc_ptr<char> demangle_symbol (const char *mangled,
|
||||
int options) const override
|
||||
{
|
||||
/* The auto language just uses the C++ demangler. */
|
||||
return gdb_demangle (mangled, options);
|
||||
|
Reference in New Issue
Block a user