From ef5f598ca6483ff965047df7f7e8697a70860527 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 26 May 2021 07:02:51 -0600 Subject: 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 * 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. --- gdb/utils.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gdb/utils.h') 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_up; +/* A wrapper for 'delete' that can used as a hash table entry deletion + function. */ +template +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. -- cgit v1.1