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

Side by Side Diff: src/string-stream.cc

Issue 2173403002: Replace SmartArrayPointer<T> with unique_ptr<T[]> (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 4 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 | « src/string-stream.h ('k') | src/wasm/decoder.h » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/string-stream.h" 5 #include "src/string-stream.h"
6 6
7 #include <memory>
8
7 #include "src/handles-inl.h" 9 #include "src/handles-inl.h"
8 #include "src/prototype.h" 10 #include "src/prototype.h"
9 11
10 namespace v8 { 12 namespace v8 {
11 namespace internal { 13 namespace internal {
12 14
13 static const int kMentionedObjectCacheMaxSize = 256; 15 static const int kMentionedObjectCacheMaxSize = 256;
14 16
15 char* HeapStringAllocator::allocate(unsigned bytes) { 17 char* HeapStringAllocator::allocate(unsigned bytes) {
16 space_ = NewArray<char>(bytes); 18 space_ = NewArray<char>(bytes);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 244 }
243 245
244 246
245 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, 247 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1,
246 FmtElm arg2, FmtElm arg3, FmtElm arg4) { 248 FmtElm arg2, FmtElm arg3, FmtElm arg4) {
247 const char argc = 5; 249 const char argc = 5;
248 FmtElm argv[argc] = { arg0, arg1, arg2, arg3, arg4 }; 250 FmtElm argv[argc] = { arg0, arg1, arg2, arg3, arg4 };
249 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); 251 Add(CStrVector(format), Vector<FmtElm>(argv, argc));
250 } 252 }
251 253
252 254 std::unique_ptr<char[]> StringStream::ToCString() const {
253 base::SmartArrayPointer<const char> StringStream::ToCString() const {
254 char* str = NewArray<char>(length_ + 1); 255 char* str = NewArray<char>(length_ + 1);
255 MemCopy(str, buffer_, length_); 256 MemCopy(str, buffer_, length_);
256 str[length_] = '\0'; 257 str[length_] = '\0';
257 return base::SmartArrayPointer<const char>(str); 258 return std::unique_ptr<char[]>(str);
258 } 259 }
259 260
260 261
261 void StringStream::Log(Isolate* isolate) { 262 void StringStream::Log(Isolate* isolate) {
262 LOG(isolate, StringEvent("StackDump", buffer_)); 263 LOG(isolate, StringEvent("StackDump", buffer_));
263 } 264 }
264 265
265 266
266 void StringStream::OutputToFile(FILE* out) { 267 void StringStream::OutputToFile(FILE* out) {
267 // Dump the output to stdout, but make sure to break it up into 268 // Dump the output to stdout, but make sure to break it up into
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 MemCopy(new_space, space_, *bytes); 579 MemCopy(new_space, space_, *bytes);
579 *bytes = new_bytes; 580 *bytes = new_bytes;
580 DeleteArray(space_); 581 DeleteArray(space_);
581 space_ = new_space; 582 space_ = new_space;
582 return new_space; 583 return new_space;
583 } 584 }
584 585
585 586
586 } // namespace internal 587 } // namespace internal
587 } // namespace v8 588 } // namespace v8
OLDNEW
« no previous file with comments | « src/string-stream.h ('k') | src/wasm/decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698