OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/allocator/type_profiler.h" | |
6 | |
7 #if defined(PROFILING_TYPE) | |
8 | |
9 namespace base { | |
10 namespace type_profiler { | |
11 | |
12 static InterceptFunction* g_new_intercept = NULL; | |
13 static InterceptFunction* g_delete_intercept = NULL; | |
14 | |
15 void SetInterceptFunctions(InterceptFunction* new_intercept, | |
16 InterceptFunction* delete_intercept) { | |
17 g_new_intercept = new_intercept; | |
18 g_delete_intercept = delete_intercept; | |
19 } | |
20 | |
21 bool IsInterceptFunctionsAvailable() { | |
22 return g_new_intercept != NULL || g_delete_intercept != NULL; | |
jar (doing other things)
2012/08/30 16:02:10
Note that this is not very thread safe, relative t
Dai Mikurube (NOT FULLTIME)
2012/08/31 06:10:30
Yeah, I know... In fact, it is not called in the
jar (doing other things)
2012/09/02 01:37:11
The most common pattern for enforcing this is to h
Dai Mikurube (NOT FULLTIME)
2012/09/03 08:16:30
Done.
| |
23 } | |
24 | |
25 } // namespace type_profiler | |
26 } // namespace base | |
27 | |
28 void* __op_new_intercept__(void* ptr, | |
jar (doing other things)
2012/08/30 16:02:10
can we say:
void* ::__op_new_intercept(...) {
...
Dai Mikurube (NOT FULLTIME)
2012/08/31 06:10:30
It is impossible. Clang++ says :
../../base/allo
| |
29 size_t size, | |
30 const std::type_info& type) { | |
31 base::type_profiler::InterceptFunction* new_intercept = | |
32 base::type_profiler::g_new_intercept; | |
33 if (new_intercept) | |
34 return new_intercept(ptr, size, type); | |
35 | |
36 return ptr; | |
37 } | |
38 | |
39 void* __op_delete_intercept__(void* ptr, | |
40 size_t size, | |
41 const std::type_info& type) { | |
42 base::type_profiler::InterceptFunction* delete_intercept = | |
43 base::type_profiler::g_delete_intercept; | |
44 if (delete_intercept) | |
45 return delete_intercept(ptr, size, type); | |
46 | |
47 return ptr; | |
48 } | |
49 | |
50 #endif // defined(PROFILING_TYPE) | |
OLD | NEW |