This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]