diff options
author | Andrew Burgess <aburgess@redhat.com> | 2021-11-08 14:58:46 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2021-11-16 17:45:45 +0000 |
commit | 8579fd136a614985bd27f20539c7bb7c5a51287d (patch) | |
tree | fb84850409a44e13e832cbadc9025d40c1d33d9f /gdb/cli/cli-cmds.c | |
parent | 2bb7589ddf61e163f2e414e7033fad56ea17e784 (diff) | |
download | binutils-8579fd136a614985bd27f20539c7bb7c5a51287d.zip binutils-8579fd136a614985bd27f20539c7bb7c5a51287d.tar.gz binutils-8579fd136a614985bd27f20539c7bb7c5a51287d.tar.bz2 |
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.
Diffstat (limited to 'gdb/cli/cli-cmds.c')
-rw-r--r-- | gdb/cli/cli-cmds.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 138a146..3fe4794 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -943,7 +943,6 @@ edit_command (const char *arg, int from_tty) struct symtab_and_line sal; struct symbol *sym; const char *editor; - char *p; const char *fn; /* Pull in the current default source line if necessary. */ @@ -1032,9 +1031,9 @@ edit_command (const char *arg, int from_tty) /* Quote the file name, in case it has whitespace or other special characters. */ - p = xstrprintf ("%s +%d \"%s\"", editor, sal.line, fn); - shell_escape (p, from_tty); - xfree (p); + gdb::unique_xmalloc_ptr<char> p + = xstrprintf ("%s +%d \"%s\"", editor, sal.line, fn); + shell_escape (p.get (), from_tty); } /* The options for the "pipe" command. */ @@ -2730,7 +2729,7 @@ Usage: source [-s] [-v] FILE\n\ -v: each command in FILE is echoed as it is executed.\n\ \n\ Note that the file \"%s\" is read automatically in this way\n\ -when GDB is started."), GDBINIT); +when GDB is started."), GDBINIT).release (); c = add_cmd ("source", class_support, source_command, source_help_text, &cmdlist); set_cmd_completer (c, filename_completer); |