OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/counters.h" | 5 #include "src/counters.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 | 8 |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 #define DUMP_COUNTER(name) \ | 386 #define DUMP_COUNTER(name) \ |
387 if (this->API_##name.count > 0) this->API_##name.Dump(buffer_); | 387 if (this->API_##name.count > 0) this->API_##name.Dump(buffer_); |
388 FOR_EACH_API_COUNTER(DUMP_COUNTER) | 388 FOR_EACH_API_COUNTER(DUMP_COUNTER) |
389 #undef DUMP_COUNTER | 389 #undef DUMP_COUNTER |
390 | 390 |
391 #define DUMP_COUNTER(name) \ | 391 #define DUMP_COUNTER(name) \ |
392 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_); | 392 if (this->Handler_##name.count > 0) this->Handler_##name.Dump(buffer_); |
393 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) | 393 FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER) |
394 #undef DUMP_COUNTER | 394 #undef DUMP_COUNTER |
395 buffer_ << "\"END\":[]}"; | 395 buffer_ << "\"END\":[]}"; |
| 396 const std::string& buffer_str = buffer_.str(); |
| 397 size_t length = buffer_str.size(); |
| 398 if (length > len_) { |
| 399 buffer_c_str_.reset(new char[length + 1]); |
| 400 len_ = length; |
| 401 } |
| 402 strncpy(buffer_c_str_.get(), buffer_str.c_str(), length + 1); |
396 in_use_ = false; | 403 in_use_ = false; |
397 return buffer_.str().c_str(); | 404 return buffer_c_str_.get(); |
398 } | 405 } |
399 | 406 |
400 } // namespace internal | 407 } // namespace internal |
401 } // namespace v8 | 408 } // namespace v8 |
OLD | NEW |