Skip to content

Commit b9fc005

Browse files
committed
Turns out I was making this too complicated
Signed-off-by: Michael Carroll <mjcarroll@intrinsic.ai>
1 parent 0d549f8 commit b9fc005

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/Environment.cc

+4-13
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,12 @@ EnvironmentMap env()
144144
_inp.substr(_inp.find('=') + 1));
145145
};
146146

147+
char **currentEnv = nullptr;
147148
#ifdef _WIN32
148-
LPCH currentEnv = GetEnvironmentStrings();
149-
if (currentEnv == nullptr)
150-
return {};
151-
152-
LPCH env_var = currentEnv;
153-
while (*env_var != '\0')
154-
{
155-
ret.emplace(split(env_var));
156-
env_var += strlen(env_var) + 1;
157-
}
158-
FreeEnvironmentStrings(currentEnv);
149+
currentEnv = *__p__environ();
159150
#else
160-
char **currentEnv = environ;
151+
currentEnv = environ;
152+
#endif
161153
// In the case that clearenv() was just called
162154
// currentEnv will be nullptr
163155
if (currentEnv == nullptr)
@@ -167,7 +159,6 @@ EnvironmentMap env()
167159
{
168160
ret.emplace(split(*currentEnv));
169161
}
170-
#endif
171162
return ret;
172163
}
173164

0 commit comments

Comments
 (0)