allocator_shim_default_dispatch_to_partition_alloc.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_ALLOCATOR_ALLOCATOR_SHIM_DEFAULT_DISPATCH_TO_PARTITION_ALLOC_H_
  5. #define BASE_ALLOCATOR_ALLOCATOR_SHIM_DEFAULT_DISPATCH_TO_PARTITION_ALLOC_H_
  6. #include "base/allocator/allocator_shim.h"
  7. #include "base/allocator/partition_allocator/partition_alloc.h"
  8. #include "base/base_export.h"
  9. namespace base {
  10. namespace internal {
  11. void PartitionAllocSetCallNewHandlerOnMallocFailure(bool value);
  12. class BASE_EXPORT PartitionAllocMalloc {
  13. public:
  14. static partition_alloc::ThreadSafePartitionRoot* Allocator();
  15. // May return |nullptr|, will never return the same pointer as |Allocator()|.
  16. static partition_alloc::ThreadSafePartitionRoot* OriginalAllocator();
  17. // May return the same pointer as |Allocator()|.
  18. static partition_alloc::ThreadSafePartitionRoot* AlignedAllocator();
  19. };
  20. BASE_EXPORT void* PartitionMalloc(const base::allocator::AllocatorDispatch*,
  21. size_t size,
  22. void* context);
  23. BASE_EXPORT void* PartitionMallocUnchecked(
  24. const base::allocator::AllocatorDispatch*,
  25. size_t size,
  26. void* context);
  27. BASE_EXPORT void* PartitionCalloc(const base::allocator::AllocatorDispatch*,
  28. size_t n,
  29. size_t size,
  30. void* context);
  31. BASE_EXPORT void* PartitionMemalign(const base::allocator::AllocatorDispatch*,
  32. size_t alignment,
  33. size_t size,
  34. void* context);
  35. BASE_EXPORT void* PartitionAlignedAlloc(
  36. const base::allocator::AllocatorDispatch* dispatch,
  37. size_t size,
  38. size_t alignment,
  39. void* context);
  40. BASE_EXPORT void* PartitionAlignedRealloc(
  41. const base::allocator::AllocatorDispatch* dispatch,
  42. void* address,
  43. size_t size,
  44. size_t alignment,
  45. void* context);
  46. BASE_EXPORT void* PartitionRealloc(const base::allocator::AllocatorDispatch*,
  47. void* address,
  48. size_t size,
  49. void* context);
  50. BASE_EXPORT void PartitionFree(const base::allocator::AllocatorDispatch*,
  51. void* object,
  52. void* context);
  53. BASE_EXPORT size_t
  54. PartitionGetSizeEstimate(const base::allocator::AllocatorDispatch*,
  55. void* address,
  56. void* context);
  57. } // namespace internal
  58. } // namespace base
  59. #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_DEFAULT_DISPATCH_TO_PARTITION_ALLOC_H_