Chromium Code Reviews| Index: base/allocator/allocated_type_profiler.cc |
| diff --git a/base/allocator/allocated_type_profiler.cc b/base/allocator/allocated_type_profiler.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..acc010c1e292da70f0edbc5c5c05bdb59c809aa6 |
| --- /dev/null |
| +++ b/base/allocator/allocated_type_profiler.cc |
| @@ -0,0 +1,48 @@ |
| +// 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.h" |
| + |
| +#if defined(PROFILING_ALLOCATED_TYPE) |
| + |
| +namespace base { |
| +namespace allocated_type { |
| + |
| +static InterceptFunction* g_new_intercept = NULL; |
| +static InterceptFunction* g_delete_intercept = NULL; |
| + |
| +void SetNewInterceptFunction(InterceptFunction* new_intercept) { |
| + g_new_intercept = new_intercept; |
| +} |
| + |
| +void SetDeleteInterceptFunction(InterceptFunction* delete_intercept) { |
| + g_delete_intercept = delete_intercept; |
| +} |
| + |
| +} // namespace allocated_type |
| +} // namespace base |
| + |
| +void* __op_new_intercept__(void* ptr, |
|
jar (doing other things)
2012/08/23 19:55:25
nit: functions should appear in the same order as
Dai Mikurube (NOT FULLTIME)
2012/08/24 02:47:27
Done. Reordered .h.
|
| + size_t size, |
| + const std::type_info& type) { |
| + base::allocated_type::InterceptFunction* new_intercept = |
| + base::allocated_type::g_new_intercept; |
|
jar (doing other things)
2012/08/23 19:55:25
nit: If you prefixed this definition code with "::
Dai Mikurube (NOT FULLTIME)
2012/08/24 02:47:27
Sorry, I didn't understand what you meant...
If
|
| + if (new_intercept) { |
| + return new_intercept(ptr, size, type); |
| + } |
| + return ptr; |
| +} |
| + |
| +void* __op_delete_intercept__(void* ptr, |
| + size_t size, |
| + const std::type_info& type) { |
| + base::allocated_type::InterceptFunction* delete_intercept = |
| + base::allocated_type::g_delete_intercept; |
| + if (delete_intercept) { |
| + return delete_intercept(ptr, size, type); |
| + } |
| + return ptr; |
| +} |
| + |
| +#endif // defined(PROFILING_ALLOCATED_TYPE) |