From: Tom Tromey Date: Thu, 17 Sep 2020 17:47:50 +0000 (-0600) Subject: Use htab_up in linespec.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7a8a5d47c37832da7203f5c54d41623c2f065b22;p=binutils-gdb.git Use htab_up in linespec.c This changes linespec.c to use htab_up rather than explicit calls to htab_delete. Note that a use still exists in this file, because linespec_state hasn't been converted to have a real destructor. gdb/ChangeLog 2020-09-17 Tom Tromey * linespec.c (class decode_compound_collector) <~decode_compound_collector>: Remove. : Now htab_up. (decode_compound_collector::operator ()): Update. (class symtab_collector) <~symtab_collector>: Remove. : Now htab_up. (symtab_collector::operator ()): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c61626b6764..837e1a4090c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2020-09-17 Tom Tromey + + * linespec.c (class decode_compound_collector) + <~decode_compound_collector>: Remove. + : Now htab_up. + (decode_compound_collector::operator ()): Update. + (class symtab_collector) <~symtab_collector>: Remove. + : Now htab_up. + (symtab_collector::operator ()): Update. + 2020-09-17 Tom Tromey * filename-seen-cache.c (filename_seen_cache::filename_seen_cache) diff --git a/gdb/linespec.c b/gdb/linespec.c index 686992ea8ae..b05b8ad89a8 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3453,16 +3453,10 @@ class decode_compound_collector { public: decode_compound_collector () + : m_unique_syms (htab_create_alloc (1, htab_hash_pointer, + htab_eq_pointer, NULL, + xcalloc, xfree)) { - m_unique_syms = htab_create_alloc (1, htab_hash_pointer, - htab_eq_pointer, NULL, - xcalloc, xfree); - } - - ~decode_compound_collector () - { - if (m_unique_syms != NULL) - htab_delete (m_unique_syms); } /* Return all symbols collected. */ @@ -3477,7 +3471,7 @@ public: private: /* A hash table of all symbols we found. We use this to avoid adding any symbol more than once. */ - htab_t m_unique_syms; + htab_up m_unique_syms; /* The result vector. */ std::vector m_symbols; @@ -3500,7 +3494,7 @@ decode_compound_collector::operator () (block_symbol *bsym) && t->code () != TYPE_CODE_NAMESPACE) return true; /* Continue iterating. */ - slot = htab_find_slot (m_unique_syms, sym, INSERT); + slot = htab_find_slot (m_unique_syms.get (), sym, INSERT); if (!*slot) { *slot = sym; @@ -3730,15 +3724,9 @@ class symtab_collector { public: symtab_collector () + : m_symtab_table (htab_create (1, htab_hash_pointer, htab_eq_pointer, + NULL)) { - m_symtab_table = htab_create (1, htab_hash_pointer, htab_eq_pointer, - NULL); - } - - ~symtab_collector () - { - if (m_symtab_table != NULL) - htab_delete (m_symtab_table); } /* Callable as a symbol_found_callback_ftype callback. */ @@ -3755,7 +3743,7 @@ private: std::vector m_symtabs; /* This is used to ensure the symtabs are unique. */ - htab_t m_symtab_table; + htab_up m_symtab_table; }; bool @@ -3763,7 +3751,7 @@ symtab_collector::operator () (struct symtab *symtab) { void **slot; - slot = htab_find_slot (m_symtab_table, symtab, INSERT); + slot = htab_find_slot (m_symtab_table.get (), symtab, INSERT); if (!*slot) { *slot = symtab;