Index: base/debug/thread_heap_usage_tracker.cc |
diff --git a/base/debug/thread_heap_usage_tracker.cc b/base/debug/thread_heap_usage_tracker.cc |
index 25af20b0aa7d20ecdfa04af0bda3d6d0ab2eb884..3761cf9ab7fc1f43c814ffa6cebc78994cc89f1a 100644 |
--- a/base/debug/thread_heap_usage_tracker.cc |
+++ b/base/debug/thread_heap_usage_tracker.cc |
@@ -130,10 +130,46 @@ size_t GetSizeEstimateFn(const AllocatorDispatch* self, void* address) { |
return self->next->get_size_estimate_function(self->next, address); |
} |
+unsigned BatchMallocFn(const AllocatorDispatch* self, |
+ size_t size, |
+ void** results, |
+ unsigned num_requested) { |
+ unsigned count = self->next->batch_malloc_function(self->next, size, results, |
+ num_requested); |
+ for (unsigned i = 0; i < count; ++i) { |
+ RecordAlloc(self->next, results[i], size); |
+ } |
+ return count; |
+} |
+ |
+void BatchFreeFn(const AllocatorDispatch* self, |
+ void** to_be_freed, |
+ unsigned num_to_be_freed) { |
+ for (unsigned i = 0; i < num_to_be_freed; ++i) { |
+ if (to_be_freed[i] != nullptr) { |
+ RecordFree(self->next, to_be_freed[i]); |
+ } |
+ } |
+ self->next->batch_free_function(self->next, to_be_freed, num_to_be_freed); |
+} |
+ |
+void FreeDefiniteSizeFn(const AllocatorDispatch* self, void* ptr, size_t size) { |
+ if (ptr != nullptr) |
+ RecordFree(self->next, ptr); |
+ self->next->free_definite_size_function(self->next, ptr, size); |
+} |
+ |
// The allocator dispatch used to intercept heap operations. |
-AllocatorDispatch allocator_dispatch = { |
- &AllocFn, &AllocZeroInitializedFn, &AllocAlignedFn, &ReallocFn, |
- &FreeFn, &GetSizeEstimateFn, nullptr}; |
+AllocatorDispatch allocator_dispatch = {&AllocFn, |
+ &AllocZeroInitializedFn, |
+ &AllocAlignedFn, |
+ &ReallocFn, |
+ &FreeFn, |
+ &GetSizeEstimateFn, |
+ &BatchMallocFn, |
+ &BatchFreeFn, |
+ &FreeDefiniteSizeFn, |
+ nullptr}; |
ThreadHeapUsage* GetOrCreateThreadUsage() { |
ThreadHeapUsage* allocator_usage = |