OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/trace_event/malloc_dump_provider.h" | 5 #include "base/trace_event/malloc_dump_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
10 #include "base/allocator/allocator_shim.h" | 10 #include "base/allocator/allocator_shim.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 return ptr; | 70 return ptr; |
71 } | 71 } |
72 | 72 |
73 void HookFree(const AllocatorDispatch* self, void* address) { | 73 void HookFree(const AllocatorDispatch* self, void* address) { |
74 if (address) | 74 if (address) |
75 MallocDumpProvider::GetInstance()->RemoveAllocation(address); | 75 MallocDumpProvider::GetInstance()->RemoveAllocation(address); |
76 const AllocatorDispatch* const next = self->next; | 76 const AllocatorDispatch* const next = self->next; |
77 next->free_function(next, address); | 77 next->free_function(next, address); |
78 } | 78 } |
79 | 79 |
80 size_t HookGetSizeEstimate(const AllocatorDispatch* self, void* address) { | |
81 const AllocatorDispatch* const next = self->next; | |
82 if (!next->get_size_estimate_function) | |
Primiano Tucci (use gerrit)
2016/09/07 17:53:38
not sure we need this level of protection here rig
Sigurður Ásgeirsson
2016/09/07 18:35:35
Done.
| |
83 return 0; | |
84 return next->get_size_estimate_function(next, address); | |
85 } | |
86 | |
80 AllocatorDispatch g_allocator_hooks = { | 87 AllocatorDispatch g_allocator_hooks = { |
81 &HookAlloc, /* alloc_function */ | 88 &HookAlloc, /* alloc_function */ |
82 &HookZeroInitAlloc, /* alloc_zero_initialized_function */ | 89 &HookZeroInitAlloc, /* alloc_zero_initialized_function */ |
83 &HookllocAligned, /* alloc_aligned_function */ | 90 &HookllocAligned, /* alloc_aligned_function */ |
84 &HookRealloc, /* realloc_function */ | 91 &HookRealloc, /* realloc_function */ |
85 &HookFree, /* free_function */ | 92 &HookFree, /* free_function */ |
86 nullptr, /* next */ | 93 &HookGetSizeEstimate, /* get_size_estimate_function */ |
94 nullptr, /* next */ | |
87 }; | 95 }; |
88 #endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) | 96 #endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM) |
89 | 97 |
90 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
91 // A structure containing some information about a given heap. | 99 // A structure containing some information about a given heap. |
92 struct WinHeapInfo { | 100 struct WinHeapInfo { |
93 HANDLE heap_id; | 101 HANDLE heap_id; |
94 size_t committed_size; | 102 size_t committed_size; |
95 size_t uncommitted_size; | 103 size_t uncommitted_size; |
96 size_t allocated_size; | 104 size_t allocated_size; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 tid_dumping_heap_ == PlatformThread::CurrentId()) | 359 tid_dumping_heap_ == PlatformThread::CurrentId()) |
352 return; | 360 return; |
353 AutoLock lock(allocation_register_lock_); | 361 AutoLock lock(allocation_register_lock_); |
354 if (!allocation_register_) | 362 if (!allocation_register_) |
355 return; | 363 return; |
356 allocation_register_->Remove(address); | 364 allocation_register_->Remove(address); |
357 } | 365 } |
358 | 366 |
359 } // namespace trace_event | 367 } // namespace trace_event |
360 } // namespace base | 368 } // namespace base |
OLD | NEW |