From 6349f452e01ddb7a1e64b8a63c93a9c9abc95725 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 8 Nov 2016 11:11:55 -0700 Subject: Introduce htab_up and use gdbpy_enter in py-framefilter.c This introduces a new "htab_up" typedef, which is a std::unique_ptr that can call htab_delete. Then it changes some code in py-framefilter.c to use both gdbpy_enter and the new htab_up. 2017-01-10 Tom Tromey * utils.h (htab_deleter): New struct. (htab_up): New typedef. * python/py-framefilter.c (gdbpy_apply_frame_filter): Use gdbpy_enter, gdbpy_ref, htab_up. --- gdb/utils.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gdb/utils.h') diff --git a/gdb/utils.h b/gdb/utils.h index 351814e..d7ae9cc 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -100,6 +100,18 @@ extern struct cleanup *make_cleanup_free_so (struct so_list *so); extern struct cleanup *make_cleanup_restore_current_language (void); +/* A deleter for a hash table. */ +struct htab_deleter +{ + void operator() (htab *ptr) const + { + htab_delete (ptr); + } +}; + +/* A unique_ptr wrapper for htab_t. */ +typedef std::unique_ptr htab_up; + extern struct cleanup *make_cleanup_htab_delete (htab_t htab); struct parser_state; -- cgit v1.1