From: Tom Tromey Date: Wed, 17 Sep 2025 20:31:09 +0000 (-0600) Subject: Use std::unique_ptr in compunit_symtab X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61a98786bfe58801995ee750887bc9e983ad983d;p=thirdparty%2Fbinutils-gdb.git Use std::unique_ptr in compunit_symtab Now that compunit_symtab can have a destructor, it can use std::unique_ptr rather than an explicit 'delete'. Approved-By: Simon Marchi --- diff --git a/gdb/symtab.c b/gdb/symtab.c index 3d8583cf76f..e24b31c528d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -428,7 +428,8 @@ void compunit_symtab::set_call_site_htab (call_site_htab_t &&call_site_htab) { gdb_assert (m_call_site_htab == nullptr); - m_call_site_htab = new call_site_htab_t (std::move (call_site_htab)); + m_call_site_htab + = std::make_unique (std::move (call_site_htab)); } /* See symtab.h. */ @@ -513,7 +514,6 @@ compunit_symtab::compunit_symtab (struct objfile *objfile, compunit_symtab::~compunit_symtab () { this->forget_cached_source_info (); - delete m_call_site_htab; } /* The relocated address of the minimal symbol, using the section diff --git a/gdb/symtab.h b/gdb/symtab.h index 20131ffd9e6..64028bf271f 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2006,7 +2006,7 @@ struct compunit_symtab : intrusive_list_node unsigned int m_epilogue_unwind_valid : 1; /* struct call_site entries for this compilation unit or NULL. */ - call_site_htab_t *m_call_site_htab = nullptr; + std::unique_ptr m_call_site_htab; /* The macro table for this symtab. Like the blockvector, this is shared between different symtabs in a given compilation unit.