aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-09-17 11:47:50 -0600
committerTom Tromey <tom@tromey.com>2020-09-17 11:58:56 -0600
commitfa9b11648c07ecb02a9c038304d646a5c652a5e7 (patch)
tree30f830d568e56b9b315c23d7055adb4e32a4f287 /gdb
parenteb53f10555eb56c43212659acbc2014f6d416a32 (diff)
downloadgdb-fa9b11648c07ecb02a9c038304d646a5c652a5e7.zip
gdb-fa9b11648c07ecb02a9c038304d646a5c652a5e7.tar.gz
gdb-fa9b11648c07ecb02a9c038304d646a5c652a5e7.tar.bz2
Use htab_up in typedef_hash_table
This changes typedef_hash_table to use htab_up rather than explicit calls to htab_delete. gdb/ChangeLog 2020-09-17 Tom Tromey <tom@tromey.com> * typeprint.h (class typedef_hash_table) <~typedef_hash_table>: Remove. <m_table>: Now htab_up. * typeprint.c (typedef_hash_table::recursively_update) (typedef_hash_table::add_template_parameters) (typedef_hash_table::typedef_hash_table): Update. (typedef_hash_table::~typedef_hash_table): Remove. (typedef_hash_table::typedef_hash_table) (typedef_hash_table::find_global_typedef) (typedef_hash_table::find_typedef): Update.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/typeprint.c29
-rw-r--r--gdb/typeprint.h4
3 files changed, 25 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1d0c024..375fa33 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
2020-09-17 Tom Tromey <tom@tromey.com>
+ * typeprint.h (class typedef_hash_table) <~typedef_hash_table>:
+ Remove.
+ <m_table>: Now htab_up.
+ * typeprint.c (typedef_hash_table::recursively_update)
+ (typedef_hash_table::add_template_parameters)
+ (typedef_hash_table::typedef_hash_table): Update.
+ (typedef_hash_table::~typedef_hash_table): Remove.
+ (typedef_hash_table::typedef_hash_table)
+ (typedef_hash_table::find_global_typedef)
+ (typedef_hash_table::find_typedef): Update.
+
+2020-09-17 Tom Tromey <tom@tromey.com>
+
* target-descriptions.c (tdesc_use_registers): Use htab_up.
2020-09-17 Tom Tromey <tom@tromey.com>
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index f9e73fe..82ca425 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -209,7 +209,7 @@ typedef_hash_table::recursively_update (struct type *t)
struct decl_field *tdef = &TYPE_TYPEDEF_FIELD (t, i);
void **slot;
- slot = htab_find_slot (m_table, tdef, INSERT);
+ slot = htab_find_slot (m_table.get (), tdef, INSERT);
/* Only add a given typedef name once. Really this shouldn't
happen; but it is safe enough to do the updates breadth-first
and thus use the most specific typedef. */
@@ -242,7 +242,7 @@ typedef_hash_table::add_template_parameters (struct type *t)
tf->name = TYPE_TEMPLATE_ARGUMENT (t, i)->linkage_name ();
tf->type = SYMBOL_TYPE (TYPE_TEMPLATE_ARGUMENT (t, i));
- slot = htab_find_slot (m_table, tf, INSERT);
+ slot = htab_find_slot (m_table.get (), tf, INSERT);
if (*slot == NULL)
*slot = tf;
}
@@ -251,16 +251,9 @@ typedef_hash_table::add_template_parameters (struct type *t)
/* See typeprint.h. */
typedef_hash_table::typedef_hash_table ()
+ : m_table (htab_create_alloc (10, hash_typedef_field, eq_typedef_field,
+ NULL, xcalloc, xfree))
{
- m_table = htab_create_alloc (10, hash_typedef_field, eq_typedef_field,
- NULL, xcalloc, xfree);
-}
-
-/* Free a typedef field table. */
-
-typedef_hash_table::~typedef_hash_table ()
-{
- htab_delete (m_table);
}
/* Helper function for typedef_hash_table::copy. */
@@ -282,10 +275,10 @@ copy_typedef_hash_element (void **slot, void *nt)
typedef_hash_table::typedef_hash_table (const typedef_hash_table &table)
{
- m_table = htab_create_alloc (10, hash_typedef_field, eq_typedef_field,
- NULL, xcalloc, xfree);
- htab_traverse_noresize (table.m_table, copy_typedef_hash_element,
- m_table);
+ m_table.reset (htab_create_alloc (10, hash_typedef_field, eq_typedef_field,
+ NULL, xcalloc, xfree));
+ htab_traverse_noresize (table.m_table.get (), copy_typedef_hash_element,
+ m_table.get ());
}
/* Look up the type T in the global typedef hash. If it is found,
@@ -307,7 +300,7 @@ typedef_hash_table::find_global_typedef (const struct type_print_options *flags,
tf.name = NULL;
tf.type = t;
- slot = htab_find_slot (flags->global_typedefs->m_table, &tf, INSERT);
+ slot = htab_find_slot (flags->global_typedefs->m_table.get (), &tf, INSERT);
if (*slot != NULL)
{
new_tf = (struct decl_field *) *slot;
@@ -346,8 +339,8 @@ typedef_hash_table::find_typedef (const struct type_print_options *flags,
tf.name = NULL;
tf.type = t;
- found = (struct decl_field *) htab_find (flags->local_typedefs->m_table,
- &tf);
+ htab_t table = flags->local_typedefs->m_table.get ();
+ found = (struct decl_field *) htab_find (table, &tf);
if (found != NULL)
return found->name;
diff --git a/gdb/typeprint.h b/gdb/typeprint.h
index bd643da..8936b9a 100644
--- a/gdb/typeprint.h
+++ b/gdb/typeprint.h
@@ -116,8 +116,6 @@ public:
/* Create a new typedef-lookup hash table. */
typedef_hash_table ();
- ~typedef_hash_table ();
-
/* Copy a typedef hash. */
typedef_hash_table (const typedef_hash_table &);
@@ -144,7 +142,7 @@ private:
/* The actual hash table. */
- htab_t m_table;
+ htab_up m_table;
/* Storage for typedef_field objects that must be synthesized. */
auto_obstack m_storage;