You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/07/11 01:39:17 UTC

[31/50] mesos git commit: Added `map` explict cast to `Envp`.

Added `map<string, string>` explict cast to `Envp`.

This is needed for implementations that expect a `map<string, string>`
over a `char **`.

Review: https://reviews.apache.org/r/60327/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/92ab3286
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/92ab3286
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/92ab3286

Branch: refs/heads/master
Commit: 92ab3286e6332a96019d8058acf946b768ddbde9
Parents: eac6cf4
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Mon Jul 10 14:26:22 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:36 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/raw/environment.hpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/92ab3286/3rdparty/stout/include/stout/os/raw/environment.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/raw/environment.hpp b/3rdparty/stout/include/stout/os/raw/environment.hpp
index c7f889f..51c93f5 100644
--- a/3rdparty/stout/include/stout/os/raw/environment.hpp
+++ b/3rdparty/stout/include/stout/os/raw/environment.hpp
@@ -121,10 +121,12 @@ class Envp
 public:
   Envp(Envp&& that)
     : envp(that.envp),
-      size(that.size)
+      size(that.size),
+      environment(that.environment)
   {
     that.envp = nullptr;
     that.size = 0;
+    that.environment = std::map<std::string, std::string>();
   }
 
   template <typename Map>
@@ -137,6 +139,7 @@ public:
     size_t index = 0;
 
     for (auto it = map.begin(); it != map.end(); ++it) {
+      environment[stringify(it->first)] = stringify(it->second);
       std::string entry = stringify(it->first) + "=" + stringify(it->second);
       envp[index] = new char[entry.size() + 1];
       ::memcpy(envp[index], entry.c_str(), entry.size() + 1);
@@ -157,6 +160,7 @@ public:
     foreachpair (const std::string& key,
                  const JSON::Value& value,
                  object.values) {
+      environment[key] = stringify(value.as<JSON::String>().value);
       std::string entry = key + "=" + value.as<JSON::String>().value;
       envp[index] = new char[entry.size() + 1];
       ::memcpy(envp[index], entry.c_str(), entry.size() + 1);
@@ -183,12 +187,18 @@ public:
     return envp;
   }
 
+  operator std::map<std::string, std::string>()
+  {
+    return environment;
+  }
+
 private:
   Envp(const Envp&) = delete;
   Envp& operator=(const Envp&) = delete;
 
   char **envp;
   size_t size;
+  std::map<std::string, std::string> environment;
 };
 
 } // namespace raw {