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

Unified Diff: base/allocator/new_delete_type_tcmalloc.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_tcmalloc.cc
diff --git a/base/allocator/new_delete_type_tcmalloc.cc b/base/allocator/new_delete_type_tcmalloc.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1c9539b643feb1561d45349146e883c13fe6847f
--- /dev/null
+++ b/base/allocator/new_delete_type_tcmalloc.cc
@@ -0,0 +1,32 @@
+// 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 <gperftools/allocated_type_map.h>
+
+void* operator new(size_t size, const std::type_info& t) {
+ void* address = ::operator new(size);
+ InsertAllocatedType(address, t);
+ return address;
+}
+
+void operator delete(void* address, const std::type_info &t) {
+ // We can make sure that LookupAllocatedType is working.
+ // const std::type_info* allocated_type = LookupAllocatedType(address);
+ EraseAllocatedType(address);
+ ::operator delete(address);
+}
+
+void* operator new[](size_t size, const std::type_info& t) {
+ void* address = ::operator new(size);
+ InsertAllocatedType(address, t);
+ return address;
+}
+
+void operator delete[](void* address, const std::type_info &t) {
+ // We can make sure that LookupAllocatedType is working.
+ // const std::type_info* allocated_type = LookupAllocatedType(address);
+ EraseAllocatedType(address);
+ ::operator delete(address);
+}
« no previous file with comments | « base/allocator/new_delete_type_log.cc ('k') | build/common.gypi » ('j') | build/common.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698