From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 5/9] Use htab_up in linespec.c
Date: Sat, 18 Jul 2020 11:29:11 -0600 [thread overview]
Message-ID: <20200718172915.6811-6-tom@tromey.com> (raw)
In-Reply-To: <20200718172915.6811-1-tom@tromey.com>
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-07-18 Tom Tromey <tom@tromey.com>
* linespec.c (class decode_compound_collector)
<~decode_compound_collector>: Default.
<m_unique_syms>: Now htab_up.
(decode_compound_collector::operator ()): Update.
(class symtab_collector) <~symtab_collector>: Default.
<m_symtab_table>: Now htab_up.
(symtab_collector::operator ()): Update.
---
gdb/ChangeLog | 10 ++++++++++
gdb/linespec.c | 30 +++++++++++-------------------
2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 4a634e3aff9..57a6283a2d6 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3449,17 +3449,13 @@ 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);
- }
+ ~decode_compound_collector () = default;
/* Return all symbols collected. */
std::vector<block_symbol> release_symbols ()
@@ -3473,7 +3469,7 @@ class decode_compound_collector
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<block_symbol> m_symbols;
@@ -3496,7 +3492,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;
@@ -3726,16 +3722,12 @@ 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);
- }
+ ~symtab_collector () = default;
/* Callable as a symbol_found_callback_ftype callback. */
bool operator () (symtab *sym);
@@ -3751,7 +3743,7 @@ class symtab_collector
std::vector<symtab *> m_symtabs;
/* This is used to ensure the symtabs are unique. */
- htab_t m_symtab_table;
+ htab_up m_symtab_table;
};
bool
@@ -3759,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;
--
2.17.2
next prev parent reply other threads:[~2020-07-18 17:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-18 17:29 [PATCH 0/9] Use htab_up in more places Tom Tromey
2020-07-18 17:29 ` [PATCH 1/9] Use htab_up in auto-load.c Tom Tromey
2020-07-20 1:38 ` Simon Marchi
2020-09-17 17:48 ` Tom Tromey
2020-07-18 17:29 ` [PATCH 2/9] Use htab_up in breakpoint.c Tom Tromey
2020-07-18 17:29 ` [PATCH 3/9] Use htab_up in completion_tracker Tom Tromey
2020-07-18 17:29 ` [PATCH 4/9] Use htab_up in filename_seen_cache Tom Tromey
2020-07-20 1:41 ` Simon Marchi
2020-07-18 17:29 ` Tom Tromey [this message]
2020-07-20 1:47 ` [PATCH 5/9] Use htab_up in linespec.c Simon Marchi
2020-07-21 0:55 ` Tom Tromey
2020-07-18 17:29 ` [PATCH 6/9] Use htab_up in target-descriptions.c Tom Tromey
2020-07-18 17:29 ` [PATCH 7/9] Use htab_up in typedef_hash_table Tom Tromey
2020-07-18 17:29 ` [PATCH 8/9] Use htab_up in type copying Tom Tromey
2020-09-18 17:32 ` Andrew Burgess
2020-09-18 18:03 ` Tom Tromey
2020-09-18 18:20 ` Andrew Burgess
2020-07-18 17:29 ` [PATCH 9/9] Use htab_up in dwarf2/read.c Tom Tromey
2020-09-17 17:58 ` [PATCH 0/9] Use htab_up in more places Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200718172915.6811-6-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).