proxygen
Stdlib.cpp File Reference
#include <folly/portability/Stdlib.h>
#include <string>
#include <vector>

Go to the source code of this file.

Functions

int clearenv ()
 

Function Documentation

int clearenv ( )

Definition at line 150 of file Stdlib.cpp.

References data, gmock_leak_test::environ, s, and string.

Referenced by folly::experimental::EnvironmentState::setAsCurrentEnvironment().

150  {
151  std::vector<std::string> data;
152  for (auto it = environ; it && *it; ++it) {
153  std::string entry(*it);
154  auto equalsPosition = entry.find('=');
155  if (equalsPosition == std::string::npos || equalsPosition == 0) {
156  // It's either a drive setting (if on Windows), or something clowny is
157  // going on in the environment.
158  continue;
159  } else {
160  data.emplace_back(entry.substr(0, equalsPosition));
161  }
162  }
163 
164  for (auto s : data) {
165  if (unsetenv(s.c_str()) != 0)
166  return -1;
167  }
168 
169  return 0;
170 }
const char * string
Definition: Conv.cpp:212
static set< string > s
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43