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

Side by Side 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, 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/builtins.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 } else { 2178 } else {
2179 const char* prefix = "[object "; 2179 const char* prefix = "[object ";
2180 Local<String> str = Utils::ToLocal(class_name); 2180 Local<String> str = Utils::ToLocal(class_name);
2181 const char* postfix = "]"; 2181 const char* postfix = "]";
2182 2182
2183 int prefix_len = i::StrLength(prefix); 2183 int prefix_len = i::StrLength(prefix);
2184 int str_len = str->Length(); 2184 int str_len = str->Length();
2185 int postfix_len = i::StrLength(postfix); 2185 int postfix_len = i::StrLength(postfix);
2186 2186
2187 int buf_len = prefix_len + str_len + postfix_len; 2187 int buf_len = prefix_len + str_len + postfix_len;
2188 char* buf = i::NewArray<char>(buf_len); 2188 i::ScopedVector<char> buf(buf_len);
2189 2189
2190 // Write prefix. 2190 // Write prefix.
2191 char* ptr = buf; 2191 char* ptr = buf.start();
2192 memcpy(ptr, prefix, prefix_len * v8::internal::kCharSize); 2192 memcpy(ptr, prefix, prefix_len * v8::internal::kCharSize);
2193 ptr += prefix_len; 2193 ptr += prefix_len;
2194 2194
2195 // Write real content. 2195 // Write real content.
2196 str->WriteAscii(ptr, 0, str_len); 2196 str->WriteAscii(ptr, 0, str_len);
2197 ptr += str_len; 2197 ptr += str_len;
2198 2198
2199 // Write postfix. 2199 // Write postfix.
2200 memcpy(ptr, postfix, postfix_len * v8::internal::kCharSize); 2200 memcpy(ptr, postfix, postfix_len * v8::internal::kCharSize);
2201 2201
2202 // Copy the buffer into a heap-allocated string and return it. 2202 // Copy the buffer into a heap-allocated string and return it.
2203 Local<String> result = v8::String::New(buf, buf_len); 2203 Local<String> result = v8::String::New(buf.start(), buf_len);
2204 i::DeleteArray(buf);
2205 return result; 2204 return result;
2206 } 2205 }
2207 } 2206 }
2208 } 2207 }
2209 2208
2210 2209
2211 bool v8::Object::Delete(v8::Handle<String> key) { 2210 bool v8::Object::Delete(v8::Handle<String> key) {
2212 ON_BAILOUT("v8::Object::Delete()", return false); 2211 ON_BAILOUT("v8::Object::Delete()", return false);
2213 ENTER_V8; 2212 ENTER_V8;
2214 HandleScope scope; 2213 HandleScope scope;
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after
4240 4239
4241 4240
4242 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4241 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4243 HandleScopeImplementer* thread_local = 4242 HandleScopeImplementer* thread_local =
4244 reinterpret_cast<HandleScopeImplementer*>(storage); 4243 reinterpret_cast<HandleScopeImplementer*>(storage);
4245 thread_local->IterateThis(v); 4244 thread_local->IterateThis(v);
4246 return storage + ArchiveSpacePerThread(); 4245 return storage + ArchiveSpacePerThread();
4247 } 4246 }
4248 4247
4249 } } // namespace v8::internal 4248 } } // namespace v8::internal
OLDNEW
« 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