From b270e6f9e09814c82e198859f218b37118eaf098 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 19 Aug 2017 22:26:20 -0600 Subject: Change install_breakpoint to take a std::unique_ptr This changes install_breakpoint to take a std::unique_ptr rvalue-ref argument. This makes it clear that install_breakpoint takes ownership of the pointer, and prevents bugs like the one fixed by the previous patch. ChangeLog 2017-08-22 Tom Tromey * breakpoint.h (install_breakpoint): Update. * breakpoint.c (add_solib_catchpoint): Update. (install_breakpoint): Change argument to a std::unique_ptr. (create_fork_vfork_event_catchpoint): Use std::unique_ptr. (create_breakpoint_sal, create_breakpoint): Update. (watch_command_1, catch_exec_command_1) (strace_marker_create_breakpoints_sal): Use std::unique_ptr. (add_to_breakpoint_chain): Change argument to a std::unique_ptr. Return the breakpoint. (set_raw_breakpoint_without_location, set_raw_breakpoint) (new_single_step_breakpoint): Update. * break-catch-throw.c (handle_gnu_v3_exceptions): Use std::unique_ptr. * break-catch-syscall.c (create_syscall_event_catchpoint): Use std::unique_ptr. * break-catch-sig.c (create_signal_catchpoint): Use std::unique_ptr. * ada-lang.c (create_ada_exception_catchpoint): Use std::unique_ptr. --- gdb/break-catch-syscall.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gdb/break-catch-syscall.c') diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 701645e9bc2..1be29bea629 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -370,14 +370,13 @@ static void create_syscall_event_catchpoint (int tempflag, std::vector &&filter, const struct breakpoint_ops *ops) { - struct syscall_catchpoint *c; struct gdbarch *gdbarch = get_current_arch (); - c = new syscall_catchpoint (); - init_catchpoint (c, gdbarch, tempflag, NULL, ops); + std::unique_ptr c (new syscall_catchpoint ()); + init_catchpoint (c.get (), gdbarch, tempflag, NULL, ops); c->syscalls_to_be_caught = std::move (filter); - install_breakpoint (0, c, 1); + install_breakpoint (0, std::move (c), 1); } /* Splits the argument using space as delimiter. */ -- cgit v1.2.1