a reentrant version of getenv