Skip to content

Commit 30fa6de

Browse files
Revert "use getenv_s instead of getenv for Windows. (ros2#499)" (ros2#504) (ros2#505)
This reverts commit 46ab4d4. (cherry picked from commit 3a4beda) Co-authored-by: Chris Lalancette <clalancette@gmail.com>
1 parent 7a75d72 commit 30fa6de

1 file changed

Lines changed: 1 addition & 20 deletions

File tree

src/env.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,8 @@ rcutils_get_env(const char * env_name, const char ** env_value)
8181
return "argument env_value is null";
8282
}
8383

84-
#ifdef _WIN32
85-
size_t requiredSize = 0;
86-
char *buffer = NULL;
87-
if (getenv_s(&requiredSize, NULL, 0, env_name) == 0 && requiredSize > 0) {
88-
buffer = (char *)malloc(requiredSize * sizeof(char));
89-
if (buffer != NULL) {
90-
if (getenv_s(&requiredSize, buffer, requiredSize, env_name) == 0) {
91-
*env_value = buffer;
92-
} else {
93-
free(buffer);
94-
*env_value = NULL;
95-
}
96-
} else {
97-
*env_value = NULL;
98-
}
99-
} else {
100-
*env_value = NULL;
101-
}
102-
#else
84+
// TODO(Suyash458): getenv is deprecated on Windows; consider using getenv_s instead
10385
*env_value = getenv(env_name);
104-
#endif
10586

10687
if (NULL == *env_value) {
10788
*env_value = "";

0 commit comments

Comments
 (0)