• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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 #ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_ALLOCATOR_SHIM_DEFAULT_DISPATCH_TO_PARTITION_ALLOC_H_
6 #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_ALLOCATOR_SHIM_DEFAULT_DISPATCH_TO_PARTITION_ALLOC_H_
7 
8 #include "base/allocator/partition_allocator/partition_alloc.h"
9 #include "base/allocator/partition_allocator/shim/allocator_shim.h"
10 #include "base/base_export.h"
11 
12 namespace allocator_shim::internal {
13 
14 void PartitionAllocSetCallNewHandlerOnMallocFailure(bool value);
15 
16 class BASE_EXPORT PartitionAllocMalloc {
17  public:
18   static partition_alloc::ThreadSafePartitionRoot* Allocator();
19   // May return |nullptr|, will never return the same pointer as |Allocator()|.
20   static partition_alloc::ThreadSafePartitionRoot* OriginalAllocator();
21   // May return the same pointer as |Allocator()|.
22   static partition_alloc::ThreadSafePartitionRoot* AlignedAllocator();
23 };
24 
25 BASE_EXPORT void* PartitionMalloc(const AllocatorDispatch*,
26                                   size_t size,
27                                   void* context);
28 
29 BASE_EXPORT void* PartitionMallocUnchecked(const AllocatorDispatch*,
30                                            size_t size,
31                                            void* context);
32 
33 BASE_EXPORT void* PartitionCalloc(const AllocatorDispatch*,
34                                   size_t n,
35                                   size_t size,
36                                   void* context);
37 
38 BASE_EXPORT void* PartitionMemalign(const AllocatorDispatch*,
39                                     size_t alignment,
40                                     size_t size,
41                                     void* context);
42 
43 BASE_EXPORT void* PartitionAlignedAlloc(const AllocatorDispatch* dispatch,
44                                         size_t size,
45                                         size_t alignment,
46                                         void* context);
47 
48 BASE_EXPORT void* PartitionAlignedRealloc(const AllocatorDispatch* dispatch,
49                                           void* address,
50                                           size_t size,
51                                           size_t alignment,
52                                           void* context);
53 
54 BASE_EXPORT void* PartitionRealloc(const AllocatorDispatch*,
55                                    void* address,
56                                    size_t size,
57                                    void* context);
58 
59 BASE_EXPORT void PartitionFree(const AllocatorDispatch*,
60                                void* object,
61                                void* context);
62 
63 BASE_EXPORT size_t PartitionGetSizeEstimate(const AllocatorDispatch*,
64                                             void* address,
65                                             void* context);
66 
67 }  // namespace allocator_shim::internal
68 
69 #endif  // BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_ALLOCATOR_SHIM_DEFAULT_DISPATCH_TO_PARTITION_ALLOC_H_
70