Make cp_comp_to_string return a gdb::unique_xmalloc_ptr<char>
To help avoid issues like the one fixed by e88e8651cf
("Fix memory
leak in cp-support.c").
gdb/ChangeLog:
2017-08-09 Pedro Alves <palves@redhat.com>
* cp-name-parser.y (cp_comp_to_string): Return a
gdb::unique_xmalloc_ptr<char>.
* cp-support.c (replace_typedefs_qualified_name)
(replace_typedefs): Adjust to use gdb::unique_xmalloc_ptr<char>.
(cp_canonicalize_string_full): Use op= instead of explicit
convertion.
(cp_class_name_from_physname, method_name_from_physname)
(cp_func_name, cp_remove_params): Adjust to use
gdb::unique_xmalloc_ptr<char>.
* cp-support.h (cp_comp_to_string): Return a
gdb::unique_xmalloc_ptr<char>.
* python/py-type.c (typy_lookup_type): Adjust to use
gdb::unique_xmalloc_ptr<char>.
This commit is contained in:
parent
b33404388e
commit
29592bde87
5 changed files with 55 additions and 45 deletions
|
@ -761,7 +761,6 @@ typy_lookup_type (struct demangle_component *demangled,
|
|||
const struct block *block)
|
||||
{
|
||||
struct type *type, *rtype = NULL;
|
||||
char *type_name = NULL;
|
||||
enum demangle_component_type demangled_type;
|
||||
|
||||
/* Save the type: typy_lookup_type() may (indirectly) overwrite
|
||||
|
@ -816,11 +815,8 @@ typy_lookup_type (struct demangle_component *demangled,
|
|||
return rtype;
|
||||
|
||||
/* We don't have a type, so lookup the type. */
|
||||
type_name = cp_comp_to_string (demangled, 10);
|
||||
type = typy_lookup_typename (type_name, block);
|
||||
xfree (type_name);
|
||||
|
||||
return type;
|
||||
gdb::unique_xmalloc_ptr<char> type_name = cp_comp_to_string (demangled, 10);
|
||||
return typy_lookup_typename (type_name.get (), block);
|
||||
}
|
||||
|
||||
/* This is a helper function for typy_template_argument that is used
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue