diff options
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r-- | Source/cmSystemTools.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9f0ea3d..fe6cfa6 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1177,3 +1177,27 @@ std::string cmSystemTools::RelativePath(const char* local, const char* remote) relativePath += relativeSplit[i]; return relativePath; } +class cmDeletingCharVector : public std::vector<char*> +{ +public: + ~cmDeletingCharVector() + { + for(std::vector<char*>::iterator i = this->begin(); + i != this->end(); ++i) + { + delete *i; + } + } +}; + + +bool cmSystemTools::PutEnv(const char* value) +{ + static cmDeletingCharVector localEnvironment; + char* envVar = new char[strlen(value)+1]; + strcpy(envVar, value); + putenv(envVar); + // save the pointer in the static vector so that it can + // be deleted on exit + localEnvironment.push_back(envVar); +} |