Date: Tue, 10 Jul 2007 19:41:48 +0400 From: Andrey Chernov <ache@nagual.pp.ru> To: "Sean C. Farley" <scf@freebsd.org> Cc: Dirk Meyer <dirk.meyer@dinoex.sub.org>, freebsd-current@freebsd.org Subject: Re: HEADS UP: getenv() and family API change Message-ID: <20070710154148.GA22873@nagual.pp.ru> In-Reply-To: <20070709145418.T52164@thor.farley.org> References: <20070703182400.Q1449@baba.farley.org> <Xuu8UV3Bay@dmeyer.dinoex.sub.org> <20070709145418.T52164@thor.farley.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jul 09, 2007 at 03:07:42PM -0500, Sean C. Farley wrote:
> On Sun, 8 Jul 2007, Dirk Meyer wrote:
>
>> Hallo Sean C. Farley,
>>
>>> Changes in moving to POSIX from historic BSD API:
>>> b. putenv takes a char * instead of const char *.
>>> c. putenv no longer makes a copy of the input string.
>>
>> Can you give more details?
>>
>> An application will break in using this:
>> putenv("PATH=/bin")
>>
>> now taking a char *, this will break with gcc42.
>
> True. As Andrey said, you should pass a copy of a const string into
> putenv(). putenv() is designed to allow changing a value at any time by
> manipulating the string. This is why I really wish the Open Group would
To say strictly, copying somewhere is not neccessary since this way works
too:
static char *s = "PATH=/bin";
putenv(s);
(don't forget static)
--
http://ache.pp.ru/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070710154148.GA22873>
