From ed4eabdf63b426cd850daa5bcdd0858edfdee15a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 10 Apr 2024 17:01:13 -0600 Subject: [PATCH] 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 --- gdb/cp-name-parser.y | 12 ------------ gdb/cp-support.h | 8 ++++---- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 782005387d6..e4534cea208 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -1955,15 +1955,6 @@ cp_comp_to_string (struct demangle_component *result, int estimated_len) return gdb::unique_xmalloc_ptr (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 diff --git a/gdb/cp-support.h b/gdb/cp-support.h index 4015126154b..d0bedcd7b80 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -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; };