Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UnsetEnv function #677

Merged
merged 5 commits into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions include/dmlc/parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ template<typename ValueType>
inline void SetEnv(const char *key,
ValueType value);

/*!
* \brief Unset environment variable.
* \param key the name of environment variable.
*/
inline void UnsetEnv(const char *key);

/*! \brief internal namespace for parameter manangement */
namespace parameter {
// forward declare ParamManager
Expand Down Expand Up @@ -1149,5 +1155,14 @@ inline void SetEnv(const char *key,
setenv(key, e.GetStringValue(&value).c_str(), 1);
#endif // _WIN32
}

// implement UnsetEnv
inline void UnsetEnv(const char *key) {
#ifdef _WIN32
_putenv_s(key, "");
#else
unsetenv(key);
#endif // _WIN32
}
} // namespace dmlc
#endif // DMLC_PARAMETER_H_
Loading