about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-06-09T08·50+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-06-09T08·54+0200
commit7c4501886d01bfc0c3681201e194cdddfad8595a (patch)
tree2ad788c820b1c1c4b3f724ed7add4de7a0a17210 /src/libutil
parentf2b67fbf2ab7de68ee2e7c12ea090c8190e9546f (diff)
Use std::vector::data()
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc11
-rw-r--r--src/libutil/util.hh2
2 files changed, 6 insertions, 7 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 5cda9a0677b5..903b97100b93 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -927,10 +927,10 @@ pid_t startProcess(std::function<void()> fun, const ProcessOptions & options)
 }
 
 
-std::vector<const char *> stringsToCharPtrs(const Strings & ss)
+std::vector<char *> stringsToCharPtrs(const Strings & ss)
 {
-    std::vector<const char *> res;
-    for (auto & s : ss) res.push_back(s.c_str());
+    std::vector<char *> res;
+    for (auto & s : ss) res.push_back((char *) s.c_str());
     res.push_back(0);
     return res;
 }
@@ -957,12 +957,11 @@ string runProgram(Path program, bool searchPath, const Strings & args,
 
         Strings args_(args);
         args_.push_front(program);
-        auto cargs = stringsToCharPtrs(args_);
 
         if (searchPath)
-            execvp(program.c_str(), (char * *) &cargs[0]);
+            execvp(program.c_str(), stringsToCharPtrs(args_).data());
         else
-            execv(program.c_str(), (char * *) &cargs[0]);
+            execv(program.c_str(), stringsToCharPtrs(args_).data());
 
         throw SysError(format("executing ‘%1%’") % program);
     });
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 7d20351eec2e..6e20a22d9da8 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -295,7 +295,7 @@ MakeError(ExecError, Error)
 /* Convert a list of strings to a null-terminated vector of char
    *'s. The result must not be accessed beyond the lifetime of the
    list of strings. */
-std::vector<const char *> stringsToCharPtrs(const Strings & ss);
+std::vector<char *> stringsToCharPtrs(const Strings & ss);
 
 /* Close all file descriptors except stdin, stdout, stderr, and those
    listed in the given set.  Good practice in child processes. */