githwxi/ATS-Postiats — pull request #99 by wdblair (2014-11-24 19:25:57+00:00)
Title: Added a helper function in pats_util.dats

This helper function copies the return string from getenv so that libc cannot trash our pointers to environment variables. For example, emscripten's libc keeps a single buffer to store the string referred to by getenv's return value. When you call getenv again, it frees the previous string and allocates space for a new one.

This is acceptable from the standard's point of view, so we might want to make our own copy of the environment variables we fetch. This approach may cause a memory leak, but we store all pointers
returned from getenv as global variables in patsopt.