| 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 c09470befae184cd5dc38c87fc9e29d00d04c535..cccb56911406ffcfd7f574c21514515051d6853a 100644
|
| --- a/base/trace_event/malloc_dump_provider.cc
|
| +++ b/base/trace_event/malloc_dump_provider.cc
|
| @@ -82,6 +82,31 @@ 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) {
|
| + if (to_be_freed[i] != nullptr) {
|
| + MallocDumpProvider::GetInstance()->RemoveAllocation(to_be_freed[i]);
|
| + }
|
| + }
|
| + next->batch_free_function(next, to_be_freed, num_to_be_freed);
|
| +}
|
| +
|
| AllocatorDispatch g_allocator_hooks = {
|
| &HookAlloc, /* alloc_function */
|
| &HookZeroInitAlloc, /* alloc_zero_initialized_function */
|
| @@ -89,6 +114,8 @@ AllocatorDispatch g_allocator_hooks = {
|
| &HookRealloc, /* realloc_function */
|
| &HookFree, /* free_function */
|
| &HookGetSizeEstimate, /* get_size_estimate_function */
|
| + &HookBatchMalloc, /* get_size_estimate_function */
|
| + &HookBatchFree, /* get_size_estimate_function */
|
| nullptr, /* next */
|
| };
|
| #endif // BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
|
|
|