| Index: base/trace_event/malloc_dump_provider.cc
|
| diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
|
| index 4683694d6bb60dc15a59b544dcadf639a7464e84..220b93e82d18fc4ef0295051c56d0a4dfc03ce4b 100644
|
| --- a/base/trace_event/malloc_dump_provider.cc
|
| +++ b/base/trace_event/malloc_dump_provider.cc
|
| @@ -82,14 +82,49 @@ size_t HookGetSizeEstimate(const AllocatorDispatch* self, void* address) {
|
| return next->get_size_estimate_function(next, address);
|
| }
|
|
|
| +unsigned HookBatchMalloc(const AllocatorDispatch* self,
|
| + size_t size,
|
| + void** results,
|
| + unsigned num_requested) {
|
| + const AllocatorDispatch* const next = self->next;
|
| + unsigned count =
|
| + next->batch_malloc_function(next, size, results, num_requested);
|
| + for (unsigned i = 0; i < count; ++i) {
|
| + MallocDumpProvider::GetInstance()->InsertAllocation(results[i], size);
|
| + }
|
| + return count;
|
| +}
|
| +
|
| +void HookBatchFree(const AllocatorDispatch* self,
|
| + void** to_be_freed,
|
| + unsigned num_to_be_freed) {
|
| + const AllocatorDispatch* const next = self->next;
|
| + for (unsigned i = 0; i < num_to_be_freed; ++i) {
|
| + MallocDumpProvider::GetInstance()->RemoveAllocation(to_be_freed[i]);
|
| + }
|
| + next->batch_free_function(next, to_be_freed, num_to_be_freed);
|
| +}
|
| +
|
| +void HookFreeDefiniteSize(const AllocatorDispatch* self,
|
| + void* ptr,
|
| + size_t size) {
|
| + if (ptr)
|
| + MallocDumpProvider::GetInstance()->RemoveAllocation(ptr);
|
| + const AllocatorDispatch* const next = self->next;
|
| + next->free_definite_size_function(next, ptr, size);
|
| +}
|
| +
|
| AllocatorDispatch g_allocator_hooks = {
|
| - &HookAlloc, /* alloc_function */
|
| - &HookZeroInitAlloc, /* alloc_zero_initialized_function */
|
| - &HookllocAligned, /* alloc_aligned_function */
|
| - &HookRealloc, /* realloc_function */
|
| - &HookFree, /* free_function */
|
| - &HookGetSizeEstimate, /* get_size_estimate_function */
|
| - nullptr, /* next */
|
| + &HookAlloc, /* alloc_function */
|
| + &HookZeroInitAlloc, /* alloc_zero_initialized_function */
|
| + &HookllocAligned, /* alloc_aligned_function */
|
| + &HookRealloc, /* realloc_function */
|
| + &HookFree, /* free_function */
|
| + &HookGetSizeEstimate, /* get_size_estimate_function */
|
| + &HookBatchMalloc, /* batch_malloc_function */
|
| + &HookBatchFree, /* batch_free_function */
|
| + &HookFreeDefiniteSize, /* free_definite_size_function */
|
| + nullptr, /* next */
|
| };
|
| #endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
|
|
|
|
|