• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/allocator/allocator_check.h"
6 
7 #include "build/build_config.h"
8 #include "partition_alloc/buildflags.h"
9 
10 #if BUILDFLAG(IS_WIN)
11 #include "partition_alloc/shim/winheap_stubs_win.h"
12 #endif
13 
14 #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
15 #include <malloc.h>
16 #endif
17 
18 #if BUILDFLAG(IS_APPLE)
19 #include "partition_alloc/shim/allocator_interception_apple.h"
20 #endif
21 
22 namespace base::allocator {
23 
IsAllocatorInitialized()24 bool IsAllocatorInitialized() {
25 #if BUILDFLAG(IS_WIN) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
26   // Set by allocator_shim_override_ucrt_symbols_win.h when the
27   // shimmed _set_new_mode() is called.
28   return allocator_shim::g_is_win_shim_layer_initialized;
29 #elif BUILDFLAG(IS_APPLE) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && \
30     !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&                      \
31     PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
32   // From allocator_interception_mac.mm.
33   return allocator_shim::g_replaced_default_zone;
34 #else
35   return true;
36 #endif
37 }
38 
39 }  // namespace base::allocator
40