Chromium Code Reviews| Index: base/allocator/allocated_type_profiler_tcmalloc.cc |
| diff --git a/base/allocator/allocated_type_profiler_tcmalloc.cc b/base/allocator/allocated_type_profiler_tcmalloc.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..82e58554c3ad84917f01d16381d0bd7609c7ddc5 |
| --- /dev/null |
| +++ b/base/allocator/allocated_type_profiler_tcmalloc.cc |
| @@ -0,0 +1,38 @@ |
| +// Copyright 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 "base/allocator/allocated_type_profiler_tcmalloc.h" |
| + |
| +#if defined(PROFILING_ALLOCATED_TYPE) |
| + |
| +#include <gperftools/allocated_type_map.h> |
| +#include <gperftools/heap-profiler.h> |
| + |
| +#include "base/allocator/allocated_type_profiler_control.h" |
| + |
| +namespace base { |
| +namespace allocated_type_profiler { |
| + |
| +void* NewInterceptForTCMalloc(void* ptr, |
| + size_t size, |
| + const std::type_info& type) { |
| + if (IsProfilingAllocatedType() && IsHeapProfilerRunning()) { |
| + InsertAllocatedType(ptr, size, type); |
| + } |
|
jar (doing other things)
2012/08/27 17:17:13
nit: curlies not needed here, and on line 31.
Dai Mikurube (NOT FULLTIME)
2012/08/28 09:04:57
Done.
|
| + return ptr; |
| +} |
| + |
| +void* DeleteInterceptForTCMalloc(void* ptr, |
| + size_t size, |
| + const std::type_info& type) { |
| + if (IsProfilingAllocatedType() && IsHeapProfilerRunning()) { |
| + EraseAllocatedType(ptr); |
| + } |
| + return ptr; |
| +} |
| + |
| +} // namespace allocated_type_profiler |
| +} // namespace base |
| + |
| +#endif // defined(PROFILING_ALLOCATED_TYPE) |