This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 59/67] Constify some commands in infcmd.c
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Thu, 21 Sep 2017 10:56:41 +0100
- Subject: Re: [RFA 59/67] Constify some commands in infcmd.c
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 91920356D9
- References: <20170921051023.19023-1-tom@tromey.com> <20170921051023.19023-60-tom@tromey.com>
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