Skip to content

Commit

Permalink
Add UnsetEnv function (#677)
Browse files Browse the repository at this point in the history
* Add unsetenv

* update doxygen file

* use doxygen 1.9.5

* comment out clang options

---------

Co-authored-by: Philip Hyunsu Cho <chohyu01@cs.washington.edu>
  • Loading branch information
rongou and hcho3 committed Aug 8, 2023
1 parent 289e3b1 commit cb7f630
Showing 1 changed file with 15 additions and 0 deletions.
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_

0 comments on commit cb7f630

Please sign in to comment.