mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-02 19:46:09 +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:
10
gdb/d-lang.c
10
gdb/d-lang.c
@ -51,7 +51,7 @@ d_main_name (void)
|
||||
|
||||
/* Implements the la_demangle language_defn routine for language D. */
|
||||
|
||||
char *
|
||||
gdb::unique_xmalloc_ptr<char>
|
||||
d_demangle (const char *symbol, int options)
|
||||
{
|
||||
return gdb_demangle (symbol, options | DMGL_DLANG);
|
||||
@ -126,8 +126,9 @@ public:
|
||||
}
|
||||
|
||||
/* See language.h. */
|
||||
bool sniff_from_mangled_name (const char *mangled,
|
||||
char **demangled) const override
|
||||
bool sniff_from_mangled_name
|
||||
(const char *mangled,
|
||||
gdb::unique_xmalloc_ptr<char> *demangled) const override
|
||||
{
|
||||
*demangled = d_demangle (mangled, 0);
|
||||
return *demangled != NULL;
|
||||
@ -135,7 +136,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
|
||||
{
|
||||
return d_demangle (mangled, options);
|
||||
}
|
||||
|
Reference in New Issue
Block a user