Clean up demangle_parse_info

This changes demangle_parse_info to use inline initializers and to
remove some manual memory management.

Approved-By: John Baldwin <jhb@FreeBSD.org>
This commit is contained in:
Tom Tromey 2024-04-10 17:01:13 -06:00
parent d1587e198f
commit ed4eabdf63
2 changed files with 4 additions and 16 deletions

View File

@ -1955,15 +1955,6 @@ cp_comp_to_string (struct demangle_component *result, int estimated_len)
return gdb::unique_xmalloc_ptr<char> (res);
}
/* Constructor for demangle_parse_info. */
demangle_parse_info::demangle_parse_info ()
: info (NULL),
tree (NULL)
{
obstack_init (&obstack);
}
/* Destructor for demangle_parse_info. */
demangle_parse_info::~demangle_parse_info ()
@ -1976,9 +1967,6 @@ demangle_parse_info::~demangle_parse_info ()
free (info);
info = next;
}
/* Free any memory allocated during typedef replacement. */
obstack_free (&obstack, NULL);
}
/* Merge the two parse trees given by DEST and SRC. The parse tree

View File

@ -58,18 +58,18 @@ struct using_direct;
struct demangle_parse_info
{
demangle_parse_info ();
demangle_parse_info () = default;
~demangle_parse_info ();
/* The memory used during the parse. */
struct demangle_info *info;
struct demangle_info *info = nullptr;
/* The result of the parse. */
struct demangle_component *tree;
struct demangle_component *tree = nullptr;
/* Any temporary memory used during typedef replacement. */
struct obstack obstack;
auto_obstack obstack;
};