From fd90ace4c1e77c94e90d2942cebe84e9a2019c0f Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Fri, 16 Feb 2018 16:20:58 +0000 Subject: New class allocate_on_obstack This patch adds a new class allocate_on_obstack, and let dwarf2_per_objfile inherit it, so that dwarf2_per_objfile is automatically allocated on obstack, and "delete dwarf2_per_objfile" doesn't de-allocate any space. gdb: 2018-02-16 Yao Qi * block.c (block_namespace_info): Inherit allocate_on_obstack. (block_initialize_namespace): Use new. * dwarf2read.c (dwarf2_per_objfile): Inherit allocate_on_obstack. (dwarf2_free_objfile): Use delete. * gdbtypes.c (type_pair): Inherit allocate_on_obstack. (copy_type_recursive): Use new. * gdb_obstack.h (allocate_on_obstack): New. --- gdb/block.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'gdb/block.c') diff --git a/gdb/block.c b/gdb/block.c index 57da7ba..f26d169 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -31,10 +31,10 @@ C++ files, namely using declarations and the current namespace in scope. */ -struct block_namespace_info +struct block_namespace_info : public allocate_on_obstack { - const char *scope; - struct using_direct *using_decl; + const char *scope = nullptr; + struct using_direct *using_decl = nullptr; }; static void block_initialize_namespace (struct block *block, @@ -350,11 +350,7 @@ static void block_initialize_namespace (struct block *block, struct obstack *obstack) { if (BLOCK_NAMESPACE (block) == NULL) - { - BLOCK_NAMESPACE (block) = XOBNEW (obstack, struct block_namespace_info); - BLOCK_NAMESPACE (block)->scope = NULL; - BLOCK_NAMESPACE (block)->using_decl = NULL; - } + BLOCK_NAMESPACE (block) = new (obstack) struct block_namespace_info (); } /* Return the static block associated to BLOCK. Return NULL if block -- cgit v1.1