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: [PATCH v5] C++ify gdb/common/environ.c


On Monday, June 19 2017, Pedro Alves wrote:

> On 06/19/2017 05:19 AM, Sergio Durigan Junior wrote:
>
>> I
>> think it also makes a lot more sense to always initialize the vector
>> with a NULL element, because this means we're correctly dealing with the
>> case where there's no environment variable to be passed to the inferior.
>
> This sentence confuses me, because I don't understand what you mean
> by "correctly" here.  What was incorrect?

What I mean is that the internal state of the vector is correct from the
get-go.  As you said in another message, the environment vector passed
to the exec* family of syscalls should contain at least one element,
NULL.  This means we can make sure that the vector generated by the API
(via the envp method) obeys this rule, or that the internal vector
(m_environ_vector) obeys this rule.  I prefer the second method, because
it leaves everything (internal and external) in a correct state.

I don't have any advanced C++ arguments to base my opinion on, and I am
well aware that this means preallocating things that maybe didn't need
to be allocated, but I still prefer keeping the NULL element there
because it makes more sense to me.

My half-cent to this discussion.

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/


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