Removed unused os::ExecEnv. Review: https://reviews.apache.org/r/35563
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4b39a668 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4b39a668 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4b39a668 Branch: refs/heads/master Commit: 4b39a668ab273ae75a79db5b4f62424c7cd69d51 Parents: 4510560 Author: Benjamin Hindman <[email protected]> Authored: Sun Jun 14 11:16:38 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Wed Jun 24 17:27:24 2015 -0700 ---------------------------------------------------------------------- .../3rdparty/stout/include/Makefile.am | 1 - .../3rdparty/stout/include/stout/os/execenv.hpp | 98 -------------------- 2 files changed, 99 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/4b39a668/3rdparty/libprocess/3rdparty/stout/include/Makefile.am ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am index cb53180..ff6fb28 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am +++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am @@ -39,7 +39,6 @@ nobase_include_HEADERS = \ stout/option.hpp \ stout/os.hpp \ stout/os/close.hpp \ - stout/os/execenv.hpp \ stout/os/exists.hpp \ stout/os/fcntl.hpp \ stout/os/fork.hpp \ http://git-wip-us.apache.org/repos/asf/mesos/blob/4b39a668/3rdparty/libprocess/3rdparty/stout/include/stout/os/execenv.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/execenv.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/execenv.hpp deleted file mode 100644 index 1dd6c90..0000000 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/execenv.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef __STOUT_OS_ENVP_HPP__ -#define __STOUT_OS_ENVP_HPP__ - -#include <map> - -#include <stout/hashmap.hpp> -#include <stout/os.hpp> - -namespace os { - -// Used to build an environment suitable for execle() -class ExecEnv -{ -public: - explicit ExecEnv(const std::map<std::string, std::string>& environment); - ~ExecEnv(); - - ExecEnv(const ExecEnv&); - - char** operator () () const { return envp; } - -private: - // Not default constructable and not assignable. - ExecEnv(); - ExecEnv& operator = (const ExecEnv&); - - char** envp; - size_t size; -}; - - -inline ExecEnv::ExecEnv(const std::map<std::string, std::string>& _environment) - : envp(NULL), - size(0) -{ - // Merge passed environment with OS environment, overriding where necessary. - hashmap<std::string, std::string> environment = os::environment(); - - foreachpair (const std::string& key, const std::string& value, _environment) { - environment[key] = value; - } - - size = environment.size(); - - // Convert environment to internal representation. - // Add 1 to the size for a NULL terminator. - envp = new char*[size + 1]; - int index = 0; - foreachpair (const std::string& key, const std::string& value, environment) { - std::string entry = key + "=" + value; - envp[index] = new char[entry.size() + 1]; - strncpy(envp[index], entry.c_str(), entry.size() + 1); - ++index; - } - - envp[index] = NULL; -} - - -inline ExecEnv::~ExecEnv() -{ - for (size_t i = 0; i < size; ++i) { - delete[] envp[i]; - } - delete[] envp; - envp = NULL; -} - - -inline ExecEnv::ExecEnv(const ExecEnv& other) -{ - size = other.size; - - envp = new char*[size + 1]; - for (size_t i = 0; i < size; ++i) { - envp[i] = new char[strlen(other.envp[i]) + 1]; - strncpy(envp[i], other.envp[i], strlen(other.envp[i]) + 1); - } - - envp[size] = NULL; -} - -} // namespace os { - -#endif // __STOUT_OS_ENVP_HPP__
