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

Unified Diff: src/api.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 | « no previous file | src/builtins.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 85c21fb178c9f945fb690d99c6096fece7cf4405..8d16a8daa1363f3dec9f0080ec1e349781b4feed 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2185,10 +2185,10 @@ Local<String> v8::Object::ObjectProtoToString() {
int postfix_len = i::StrLength(postfix);
int buf_len = prefix_len + str_len + postfix_len;
- char* buf = i::NewArray<char>(buf_len);
+ i::ScopedVector<char> buf(buf_len);
// Write prefix.
- char* ptr = buf;
+ char* ptr = buf.start();
memcpy(ptr, prefix, prefix_len * v8::internal::kCharSize);
ptr += prefix_len;
@@ -2200,8 +2200,7 @@ Local<String> v8::Object::ObjectProtoToString() {
memcpy(ptr, postfix, postfix_len * v8::internal::kCharSize);
// Copy the buffer into a heap-allocated string and return it.
- Local<String> result = v8::String::New(buf, buf_len);
- i::DeleteArray(buf);
+ Local<String> result = v8::String::New(buf.start(), buf_len);
return result;
}
}
« no previous file with comments | « no previous file | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698