C++-ify skip.c
authorTom Tromey <tom@tromey.com>
Sat, 5 Aug 2017 22:40:56 +0000 (16:40 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 9 Aug 2017 18:32:06 +0000 (12:32 -0600)
commit42fa2e0e1b7b135ab30f2f78074c3bfffa04d0cc
treef70f2f955f5a331bec0f8ffd02858908c96cbf99
parentcc4a945a2687184c7cd4a0572e02965829517408
C++-ify skip.c

I happened to notice that skiplist_entry, in skip.c, contains a
gdb::optional<compiled_regex> -- but that this object's destructor is
never run.  This can result in a memory leak.

This patch fixes the bug by applying a bit more C++: changing this
code to use new and delete, and std::unique_ptr; and removing cleanups
in the process.

Built and regression tested on x86-64 Fedora 25.

ChangeLog
2017-08-09  Tom Tromey  <tom@tromey.com>

* skip.c (skiplist_entry): New constructor.
(skiplist_entry::enabled, skiplist_entry::function_is_regexp)
(skiplist_entry::file_is_glob): Now bool.
(skiplist_entry::file, skiplist_entry::function): Now
std::string.
(make_skip_entry): Return a unique_ptr.  Use new.
(free_skiplist_entry, free_skiplist_entry_cleanup)
(make_free_skiplist_entry_cleanup): Remove.
(skip_command, skip_disable_command, add_skiplist_entry)
(skip_form_bytes, compile_skip_regexp, skip_command, skip_info)
(skip_file_p, skip_gfile_p, skip_function_p, skip_rfunction_p)
(function_name_is_marked_for_skip): Update.
(skip_delete_command): Update.  Use delete.
gdb/ChangeLog
gdb/skip.c