Web lists-archives.com

Re: [Mingw-users] setenv()




Keith Marshall to Anton Shepelev:

>>As  I  can  tell, the variable buf is a local one,
>>whereas according to the putenv  man  entry,  "The
>>string  pointed  to  by string becomes part of the
>>environment, so altering the  string  changes  the
>>environment."
>
>-  From  you reference to "man entry", may I deduce
>that this relates to some  non-Windows  implementa-
>tion of putenv()?  Linux' glibc perhaps?

Yes, it is glibc.

>>Does  the Microsoft implementation copy the string
>>passed?
>
>Yes.  Given MS-DOS' organization of the environment
>as a contiguous sequence of NUL separated name=val-
>ue C strings, terminated by a single zero-length  C
>string, that would have been a practical necessity.
>Of course, there's no guarantee that  Windows'  has
>adopted   that  MS-DOS  environment  organizational
>legacy, but the printf() statements, which I  added
>to  the  sample  implementation,  confirm  that the
>pointer returned by getenv() bears no  relationship
>to  the  original  address  of the string passed to
>putenv();

Thanks -- that is interesing.  The result  would  be
the  same  if getenv() returned a copy of the string
as a safety measure.

-- 
Please, do not send replies to the list to my e-mail.


------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe