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

Unified Diff: src/flags.cc

Issue 1737023: Turn some usages of NewArray with DeleteArray in the same scope into ScopedVector or SmartPointer. (Closed)
Patch Set: Disabling implicit constructors Created 10 years, 8 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 | « src/debug-agent.cc ('k') | src/log.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/flags.cc
diff --git a/src/flags.cc b/src/flags.cc
index d444c976fbbc9c6ca723ccf06cb28cb1401a1644..bbe6bb720e573779fd5f2a44940876c52c9e90ab 100644
--- a/src/flags.cc
+++ b/src/flags.cc
@@ -470,12 +470,12 @@ static char* SkipBlackSpace(char* p) {
// static
int FlagList::SetFlagsFromString(const char* str, int len) {
// make a 0-terminated copy of str
- char* copy0 = NewArray<char>(len + 1);
- memcpy(copy0, str, len);
+ ScopedVector<char> copy0(len + 1);
+ memcpy(copy0.start(), str, len);
copy0[len] = '\0';
// strip leading white space
- char* copy = SkipWhiteSpace(copy0);
+ char* copy = SkipWhiteSpace(copy0.start());
// count the number of 'arguments'
int argc = 1; // be compatible with SetFlagsFromCommandLine()
@@ -485,7 +485,7 @@ int FlagList::SetFlagsFromString(const char* str, int len) {
}
// allocate argument array
- char** argv = NewArray<char*>(argc);
+ ScopedVector<char*> argv(argc);
// split the flags string into arguments
argc = 1; // be compatible with SetFlagsFromCommandLine()
@@ -497,11 +497,7 @@ int FlagList::SetFlagsFromString(const char* str, int len) {
}
// set the flags
- int result = SetFlagsFromCommandLine(&argc, argv, false);
-
- // cleanup
- DeleteArray(argv);
- DeleteArray(copy0);
+ int result = SetFlagsFromCommandLine(&argc, argv.start(), false);
return result;
}
« no previous file with comments | « src/debug-agent.cc ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698