Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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<const 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<const char[]>(const_cast<const char*>(str)); |
|
Igor Sheludko
2016/07/25 08:56:44
Same here.
jochen (gone - plz use gerrit)
2016/07/25 09:14:48
done
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |