Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: base/process/launch_mac.cc

Issue 2911533002: Use std::vector in process launch code. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/process/launch_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/launch_mac.cc
diff --git a/base/process/launch_mac.cc b/base/process/launch_mac.cc
index 3732bc1ecc50e596ad47c353850776d062746bee..ca706b5553ff7ecd8b9c9c9dc798a0ced5dc515f 100644
--- a/base/process/launch_mac.cc
+++ b/base/process/launch_mac.cc
@@ -140,11 +140,11 @@ Process LaunchProcessPosixSpawn(const std::vector<std::string>& argv,
file_actions.Inherit(STDERR_FILENO);
}
- std::unique_ptr<char* []> argv_cstr(new char*[argv.size() + 1]);
- for (size_t i = 0; i < argv.size(); i++) {
- argv_cstr[i] = const_cast<char*>(argv[i].c_str());
- }
- argv_cstr[argv.size()] = nullptr;
+ std::vector<char*> argv_cstr;
+ argv_cstr.reserve(argv.size() + 1);
+ for (const auto& arg : argv)
+ argv_cstr.push_back(const_cast<char*>(arg.c_str()));
+ argv_cstr.push_back(nullptr);
std::unique_ptr<char* []> owned_environ;
char** new_environ = options.clear_environ ? nullptr : *_NSGetEnviron();
« no previous file with comments | « no previous file | base/process/launch_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698