Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!uflorida!haven!adm!xadmx!Leisner.Henr@xerox.com From: Leisner.Henr@xerox.com (marty) Newsgroups: comp.unix.wizards Subject: RE: bug in putenv()! Message-ID: <18436@adm.BRL.MIL> Date: 22 Feb 89 18:46:19 GMT Sender: news@adm.BRL.MIL Lines: 26 According to Christopher J. Calabrese >> If putenv always malloc'd space, it would start eating up some serious memory in something like the shell, where you might change the value of an environment variable several hundred times in a particularly large script (please don't ask for examples, you get the general idea :-) I don't agree -- putenv could detect whether an equivalent environment string already exists. If putenv always does a malloc/strcpy, whenever a string is overwritten it could free or realloc the storage. I had a version which works sorta this way on Ms/Dos (actually the whole environment array was one malloced block ). A version of putenv on a masscomp I'm looking at right now appears to work the same way (it uses realloc on successive calls to putenv after the first malloc [hmmm -- maybe someone else had the same idea ;-) ]). I find having to allocate static storage for putenv to be kinda strange -- I guess it's another portability bugaboo. marty ARPA: leisner.henr@xerox.com GV: leisner.henr NS: martin leisner:wbst139:xerox UUCP: hplabs!arisia!leisner