Re: [RFA 59/67] Constify some commands in infcmd.c

Pedro Alves
2017-09-21T09:56:46Z

On 09/21/2017 06:10 AM, Tom Tromey wrote:
> @@ -2230,21 +2222,20 @@ set_environment_command (char *arg, int from_tty)
> while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
> p--;
>
> - var = savestring (arg, p - arg);
> + std::string var (arg, p - arg);
> if (nullset)
> {
> printf_filtered (_("Setting environment variable "
> "\"%s\" to null value.\n"),
> - var);
> - current_inferior ()->environment.set (var, "");
> + var.c_str ());
> + current_inferior ()->environment.set (var.c_str (), "");
> }
> else
> - current_inferior ()->environment.set (var, val);
> - xfree (var);
> + current_inferior ()->environment.set (var.c_str (), val);
> }

Nice, this fixes a potential leak. OK.

Thanks,
Pedro Alves