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

Unified Diff: src/counters.cc

Issue 2349593004: Revert of [Tracing] Remove unnecessary memory allocation in runtime call stats. (Closed)
Patch Set: Created 4 years, 3 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 | « src/counters.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/counters.cc
diff --git a/src/counters.cc b/src/counters.cc
index 1e76c0763b6fbd62bdf8818a000c5233089a4e16..84568ac351fc696db2638d106f9d3b3fa02c9c41 100644
--- a/src/counters.cc
+++ b/src/counters.cc
@@ -393,8 +393,15 @@
FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
#undef DUMP_COUNTER
buffer_ << "\"END\":[]}";
+ const std::string& buffer_str = buffer_.str();
+ size_t length = buffer_str.size();
+ if (length > len_) {
+ buffer_c_str_.reset(new char[length + 1]);
+ len_ = length;
+ }
+ strncpy(buffer_c_str_.get(), buffer_str.c_str(), length + 1);
in_use_ = false;
- return buffer_.str().c_str();
+ return buffer_c_str_.get();
}
} // namespace internal
« no previous file with comments | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698