From: Tom Tromey Date: Fri, 20 Jan 2023 14:12:02 +0000 (-0700) Subject: Use 'new' for block and global_block X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44bb9f9e7a7adc13f0b944ed76ddc459d5bb21f7;p=binutils-gdb.git Use 'new' for block and global_block This changes block and global_block to add initializers, and then to use 'new' for allocation. --- diff --git a/gdb/block.c b/gdb/block.c index 0870793dcd4..8f15cdf23f8 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -389,9 +389,7 @@ block::global_block () const struct block * allocate_block (struct obstack *obstack) { - struct block *bl = OBSTACK_ZALLOC (obstack, struct block); - - return bl; + return new (obstack) struct block; } /* Allocate a global block. */ @@ -399,7 +397,7 @@ allocate_block (struct obstack *obstack) struct block * allocate_global_block (struct obstack *obstack) { - struct global_block *bl = OBSTACK_ZALLOC (obstack, struct global_block); + struct global_block *bl = new (obstack) struct global_block; return &bl->block; } diff --git a/gdb/block.h b/gdb/block.h index 6ccf3766d8f..9a60140581d 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -105,7 +105,7 @@ struct blockranges This implies that within the body of one function the blocks appear in the order of a depth-first tree walk. */ -struct block +struct block : public allocate_on_obstack { /* Return this block's start address. */ CORE_ADDR start () const @@ -273,13 +273,13 @@ struct block /* Addresses in the executable code that are in this block. */ - CORE_ADDR m_start; - CORE_ADDR m_end; + CORE_ADDR m_start = 0; + CORE_ADDR m_end = 0; /* The symbol that names this block, if the block is the body of a function (real or inlined); otherwise, zero. */ - struct symbol *m_function; + struct symbol *m_function = nullptr; /* The `struct block' for the containing block, or 0 if none. @@ -287,22 +287,22 @@ struct block case of C) is the STATIC_BLOCK. The superblock of the STATIC_BLOCK is the GLOBAL_BLOCK. */ - const struct block *m_superblock; + const struct block *m_superblock = nullptr; /* This is used to store the symbols in the block. */ - struct multidictionary *m_multidict; + struct multidictionary *m_multidict = nullptr; /* Contains information about namespace-related info relevant to this block: using directives and the current namespace scope. */ - struct block_namespace_info *m_namespace_info; + struct block_namespace_info *m_namespace_info = nullptr; /* Address ranges for blocks with non-contiguous ranges. If this is NULL, then there is only one range which is specified by startaddr and endaddr above. */ - struct blockranges *m_ranges; + struct blockranges *m_ranges = nullptr; private: @@ -314,7 +314,7 @@ private: /* The global block is singled out so that we can provide a back-link to the compunit symtab. */ -struct global_block +struct global_block : public allocate_on_obstack { /* The block. */ @@ -322,7 +322,7 @@ struct global_block /* This holds a pointer to the compunit symtab holding this block. */ - struct compunit_symtab *compunit_symtab; + struct compunit_symtab *compunit_symtab = nullptr; }; struct blockvector