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  <tom@tromey.com>

	* 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.
This commit is contained in:
Tom Tromey
2016-11-08 11:11:55 -07:00
parent c0171de646
commit 6349f452e0
3 changed files with 42 additions and 36 deletions

View File

@@ -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, htab_deleter> htab_up;
extern struct cleanup *make_cleanup_htab_delete (htab_t htab);
struct parser_state;