aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.h
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/utils.h
parentfe1f847d9a73c090527d2620eb9883185351aea0 (diff)
downloadfsf-binutils-gdb-ef5f598ca6483ff965047df7f7e8697a70860527.zip
fsf-binutils-gdb-ef5f598ca6483ff965047df7f7e8697a70860527.tar.gz
fsf-binutils-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/utils.h')
-rw-r--r--gdb/utils.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/gdb/utils.h b/gdb/utils.h
index 94d37c5..f05e662 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -306,6 +306,15 @@ struct htab_deleter
/* A unique_ptr wrapper for htab_t. */
typedef std::unique_ptr<htab, htab_deleter> htab_up;
+/* A wrapper for 'delete' that can used as a hash table entry deletion
+ function. */
+template<typename T>
+void
+htab_delete_entry (void *ptr)
+{
+ delete (T *) ptr;
+}
+
extern void init_page_info (void);
/* Temporarily set BATCH_FLAG and the associated unlimited terminal size.