From c699004a29093c69fc6aeed04bbd838362666676 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Mon, 25 May 2020 11:38:11 -0400 Subject: gdbsupport: Adapt construct_inferior_arguments Allow construct_inferior_arguments to handle zero args and have it return a std::string, similar to how stringify_argv in gdbsupport/common-utils does. Also, add a const qualifier for the second parameter, since it is only read, not written to. The intention is to replace existing uses of stringify_argv by construct_inferior_arguments in a subsequent step, since construct_inferior_arguments properly handles special characters, while stringify_argv doesn't. gdbsupport/ChangeLog: * common-inferior.cc, common-inferior.h (construct_inferior_arguments): Adapt to handle zero args and return a std::string. Adapt call site. Change-Id: I126c4390a1018c7527b0b8fd545252ab8a5a7adc --- gdb/infcmd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'gdb/infcmd.c') diff --git a/gdb/infcmd.c b/gdb/infcmd.c index cf6e540..ffcc364 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -151,12 +151,9 @@ get_inferior_args (void) { if (current_inferior ()->argc != 0) { - char *n; - - n = construct_inferior_arguments (current_inferior ()->argc, - current_inferior ()->argv); - set_inferior_args (n); - xfree (n); + std::string n = construct_inferior_arguments (current_inferior ()->argc, + current_inferior ()->argv); + set_inferior_args (n.c_str ()); } if (current_inferior ()->args == NULL) -- cgit v1.1