aboutsummaryrefslogtreecommitdiff
path: root/gdb/completer.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-05-26 07:02:51 -0600
committerTom Tromey <tom@tromey.com>2021-05-26 07:02:51 -0600
commitef5f598ca6483ff965047df7f7e8697a70860527 (patch)
tree3e90ee19b538abef8a247e588efb90d528015775 /gdb/completer.c
parentfe1f847d9a73c090527d2620eb9883185351aea0 (diff)
downloadgdb-ef5f598ca6483ff965047df7f7e8697a70860527.zip
gdb-ef5f598ca6483ff965047df7f7e8697a70860527.tar.gz
gdb-ef5f598ca6483ff965047df7f7e8697a70860527.tar.bz2
Introduce htab_delete_entry
In a bigger series I'm working on, it is convenient to have a libiberty hash table that manages objects allocated with 'new'. To make this simpler, I wrote a small template function to serve as a concise wrapper. Then I realized that this could be reused in a few other places. gdb/ChangeLog 2021-05-26 Tom Tromey <tom@tromey.com> * dwarf2/read.c (allocate_type_unit_groups_table) (handle_DW_AT_stmt_list, allocate_dwo_file_hash_table): Use htab_delete_entry. (free_line_header_voidp): Remove. * completer.c (completion_tracker::completion_hash_entry::deleter): Remove. (completion_tracker::discard_completions): Use htab_delete_entry. * utils.h (htab_delete_entry): New template function.
Diffstat (limited to 'gdb/completer.c')
-rw-r--r--gdb/completer.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/gdb/completer.c b/gdb/completer.c
index 6ad788b..060160f 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -88,14 +88,6 @@ public:
return htab_hash_string (m_name.get ());
}
- /* A static function that can be passed to the htab hash system to be
- used as a callback that deletes an item from the hash. */
- static void deleter (void *arg)
- {
- completion_hash_entry *entry = (completion_hash_entry *) arg;
- delete entry;
- }
-
private:
/* The symbol name stored in this hash entry. */
@@ -1618,10 +1610,11 @@ completion_tracker::discard_completions ()
return entry->hash_name ();
};
- m_entries_hash.reset (htab_create_alloc (INITIAL_COMPLETION_HTAB_SIZE,
- entry_hash_func, entry_eq_func,
- completion_hash_entry::deleter,
- xcalloc, xfree));
+ m_entries_hash.reset
+ (htab_create_alloc (INITIAL_COMPLETION_HTAB_SIZE,
+ entry_hash_func, entry_eq_func,
+ htab_delete_entry<completion_hash_entry>,
+ xcalloc, xfree));
}
/* See completer.h. */