This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v6] C++ify gdb/common/environ.c
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Simon Marchi <simon dot marchi at polymtl dot ca>, Pedro Alves <palves at redhat dot com>
- Date: Mon, 19 Jun 2017 00:51:22 -0400
- Subject: Re: [PATCH v6] C++ify gdb/common/environ.c
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E916D3299
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E916D3299
- References: <20170413040455.23996-1-sergiodj@redhat.com> <20170619043531.32394-1-sergiodj@redhat.com>
On Monday, June 19 2017, I wrote:
> [...]
> -struct gdb_environ *
> -make_environ (void)
> +gdb_environ &
> +gdb_environ::operator= (gdb_environ &&e)
> {
> - struct gdb_environ *e;
> -
> - e = XNEW (struct gdb_environ);
> -
> - e->allocated = 10;
> - e->vector = (char **) xmalloc ((e->allocated + 1) * sizeof (char *));
> - e->vector[0] = 0;
> - return e;
> -}
> -
> -/* Free an environment and all the strings in it. */
> -
> -void
> -free_environ (struct gdb_environ *e)
> -{
> - char **vector = e->vector;
> -
> - while (*vector)
> - xfree (*vector++);
> -
> - xfree (e->vector);
> - xfree (e);
> + clear ();
> + m_environ_vector = std::move (e.m_environ_vector);
> + return *this;
> }
I should probably do an m_environ_vector.clear () before doing the
std::move, because the vector will contain the NULL element. I'll make
sure to do this before I push the patch.
Thanks,
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/