Help with C clearenv and setenv

Eliot Moss moss@cs.umass.edu
Thu May 31 13:22:00 GMT 2018


On 5/30/2018 11:56 PM, Marco Atzeri wrote:
 > On 5/30/2018 4:48 PM, Sam Habiel wrote:

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

Indeed, this does not surprise me since environ is supposed
to be a pointer to an array of char *, whose last entry is
NULL.  So the above line is the one needed.  It *might*
also work to do something like:

char *dummy = NULL;
environ = &dummy;

This avoids an allocation call.

-- Eliot Moss

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



More information about the Cygwin mailing list