From 8579fd136a614985bd27f20539c7bb7c5a51287d Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Mon, 8 Nov 2021 14:58:46 +0000 Subject: gdb/gdbsupport: make xstrprintf and xstrvprintf return a unique_ptr The motivation is to reduce the number of places where unmanaged pointers are returned from allocation type routines. All of the callers are updated. There should be no user visible changes after this commit. --- gdb/breakpoint.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gdb/breakpoint.c') diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 86dffb4..d98c3a7 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8728,7 +8728,7 @@ static void update_dprintf_command_list (struct breakpoint *b) { const char *dprintf_args = b->extra_string.get (); - char *printf_line = NULL; + gdb::unique_xmalloc_ptr printf_line = nullptr; if (!dprintf_args) return; @@ -8779,7 +8779,7 @@ update_dprintf_command_list (struct breakpoint *b) /* Manufacture a printf sequence. */ struct command_line *printf_cmd_line - = new struct command_line (simple_control, printf_line); + = new struct command_line (simple_control, printf_line.release ()); breakpoint_set_commands (b, counted_command_line (printf_cmd_line, command_lines_deleter ())); } @@ -10798,9 +10798,8 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, w->exp_string_reparse = current_language->watch_location_expression (t, addr); - w->exp_string.reset (xstrprintf ("-location %.*s", - (int) (exp_end - exp_start), - exp_start)); + w->exp_string = xstrprintf ("-location %.*s", + (int) (exp_end - exp_start), exp_start); } else w->exp_string.reset (savestring (exp_start, exp_end - exp_start)); -- cgit v1.1