I have found a new function to add to the list of
nonportable functions: `putenv'. The DJGPP C Library
refrence says under `putenv':
... that most implementations will not allow you to free the string you pass
...
Most of the time, `putenv' essently boils down to
environ[free_position] = str
Which that note makes perfect sense: `environ' is declared
as
extern char **environ;
and `putenv' is declared as
int putenv(const char *str)
Which is why they invented strcpy(). `free'ing the string
would make the next access probably cause the `malloc'
arena to be corrupted, causing a spectacular and gratitous
segmentation fault. If the string is not `strcpy'd into
a safe location, than said call to `putenv' is
nonportable. A good replacement for a broken putenv() is
(assuming that `putenv' is defined as `rpl_putenv'):
#undef putenv
int
rpl_putenv(s)
char *s;
{
char *t;
strcpy(t, s);
return putenv(t);
}
Samuel Lauber
--
_____________________________________________________________
Web-based SMS services available at http://www.operamail.com.
From your mailbox to local or overseas cell phones.
Powered by Outblaze