Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: base/debug/thread_heap_usage_tracker.cc

Issue 2658723007: Hook up allocator shim on mac. (Closed)
Patch Set: remove a debugging test. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/allocator/allocator_shim_unittest.cc ('k') | base/debug/thread_heap_usage_tracker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 =
« no previous file with comments | « base/allocator/allocator_shim_unittest.cc ('k') | base/debug/thread_heap_usage_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698