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

Unified Diff: base/allocator/new_delete_type_log.cc

Issue 10411047: Type profiler by intercepting 'new' and 'delete' expressions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Support operator delete[]. Created 8 years, 6 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
Index: base/allocator/new_delete_type_log.cc
diff --git a/base/allocator/new_delete_type_log.cc b/base/allocator/new_delete_type_log.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4243ed1a5df52855ca05abd1978a39f8a4b6cde7
--- /dev/null
+++ b/base/allocator/new_delete_type_log.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "new_delete_type.h"
+#include <iostream>
+
+void* operator new(size_t size, const std::type_info& t) {
+ void* address = ::operator new(size);
+ std::cerr << "Allocated "
+ << size
+ << " bytes of \""
+ << t.name()
+ << "\" at "
+ << address
+ << "."
+ << std::endl;
+ return address;
+}
+
+void operator delete(void* address, const std::type_info &t) {
+ ::operator delete(address);
+ std::cerr << "Dellocated an instance of \""
+ << t.name()
+ << "\" at "
+ << address
+ << "."
+ << std::endl;
+}
+
+void* operator new[](size_t size, const std::type_info& t) {
+ void* address = ::operator new(size);
+ std::cerr << "Allocated "
+ << size
+ << " bytes of \""
+ << t.name()
+ << "[]\" at "
+ << address
+ << "."
+ << std::endl;
+ return address;
+}
+
+void operator delete[](void* address, const std::type_info &t) {
+ ::operator delete(address);
+ std::cerr << "Dellocated an instance of \""
+ << t.name()
+ << "[]\" at "
+ << address
+ << "."
+ << std::endl;
+}

Powered by Google App Engine
This is Rietveld 408576698