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

Unified Diff: base/allocator/allocator_shim.cc

Issue 2712363002: Use mach_override to intercept all newly registered malloc zones.
Patch Set: compile error. Created 3 years, 10 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_interception_mac_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/allocator_shim.cc
diff --git a/base/allocator/allocator_shim.cc b/base/allocator/allocator_shim.cc
index a401139ee652d5043279aa899674aba7b82101b1..e6eb256cf568925ab441cc75c4539ba6d005bc32 100644
--- a/base/allocator/allocator_shim.cc
+++ b/base/allocator/allocator_shim.cc
@@ -25,6 +25,8 @@
#include <malloc/malloc.h>
#include "base/allocator/allocator_interception_mac.h"
+#include "base/base_switches.h"
+#include "base/command_line.h"
#endif
// No calls to malloc / new in this file. They would would cause re-entrancy of
@@ -328,6 +330,13 @@ void InitializeAllocatorShim() {
MallocZoneFunctions functions = MallocZoneFunctionsToReplaceDefault();
+ // Intercept and override newly registered malloc zones.
+ if (CommandLine::InitializedForCurrentProcess() &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableHeapProfiling)) {
+ InterceptNewlyRegisteredMallocZones(&functions);
+ }
+
// This replaces the default malloc zone, causing calls to malloc & friends
// from the codebase to be routed to ShimMalloc() above.
base::allocator::ReplaceFunctionsForStoredZones(&functions);
« no previous file with comments | « base/allocator/allocator_interception_mac_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698