This is the mail archive of the cygwin mailing list for the Cygwin 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: Help with C clearenv and setenv


On 5/30/2018 4:48 PM, Sam Habiel wrote:
I have code for a database I am porting to Cygwin.

Part of that code is a clearenv() then a couple of setenvs. There is
an ifdef for Cygwin, as it doesn't implement clearenv. It just sets
environ = NULL. Well--that really breaks setenv! It returns a "Bad
Poniter" error (-1).

What is the correct way to clear environment variables in Cygwin?

--Sam


not tested but it seems Cygwin is not the only platform
with problem on environ = NULL

environ = calloc(1, sizeof(*environ))

see
https://github.com/samba-team/samba/blob/master/source3/client/smbspool_krb5_wrapper.c

https://github.com/dovecot/core/blob/master/src/lib/env-util.c


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


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