| 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);
|
| +}
|
|
|