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
>-  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
>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

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

This list observes the Etiquette found at 
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:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe