Re: HEADS UP: getenv() and family API change

From: Andrey Chernov <ache_at_nagual.pp.ru>
Date: Wed, 11 Jul 2007 02:46:19 +0400
On Wed, Jul 11, 2007 at 07:36:02AM +1000, Peter Jeremy wrote:
> On 2007-Jul-10 19:41:48 +0400, Andrey Chernov <ache_at_nagual.pp.ru> wrote:
> >To say strictly, copying somewhere is not neccessary since this way works 
> >too:
> >
> >static char *s = "PATH=/bin";
> >
> >putenv(s);
> 
> I thought the C compiler was still free to place the string into RO
> memory and/or coalesce it with other strings in that case.
> 
> Wouldn't the following be clearer (s is forced to be writable):
> 
> static char s[] = "PATH=/bin";
> 
> putenv(s);

This two are the same, since there is no "const", so compiler can't put 
static char *s
into RO memory.

-- 
http://ache.pp.ru/

Received on Tue Jul 10 2007 - 20:46:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:14 UTC