| Index: base/allocator/allocator_shim_default_dispatch_to_mac_zoned_malloc.cc
|
| diff --git a/base/allocator/allocator_shim_default_dispatch_to_mac_zoned_malloc.cc b/base/allocator/allocator_shim_default_dispatch_to_mac_zoned_malloc.cc
|
| index aabda1950cb290a5b2659e7a370551aea9613f1a..5cf0dbf6bd960e98fab47f0419a1ca76a423c8cd 100644
|
| --- a/base/allocator/allocator_shim_default_dispatch_to_mac_zoned_malloc.cc
|
| +++ b/base/allocator/allocator_shim_default_dispatch_to_mac_zoned_malloc.cc
|
| @@ -12,50 +12,45 @@
|
|
|
| namespace base {
|
| namespace allocator {
|
| -
|
| namespace {
|
|
|
| -// This is the zone that the allocator shim will call to actually perform heap
|
| -// allocations. It should be populated with the original, unintercepted default
|
| -// malloc zone.
|
| -MallocZoneFunctions g_default_zone;
|
| -
|
| void* MallocImpl(const AllocatorDispatch*, size_t size, void* context) {
|
| - return g_default_zone.malloc(
|
| - reinterpret_cast<struct _malloc_zone_t*>(context), size);
|
| + return MallocZoneAggregator::GetMallocZoneAggregator()->DispatchMallocToZone(
|
| + context, size);
|
| }
|
|
|
| void* CallocImpl(const AllocatorDispatch*,
|
| size_t n,
|
| size_t size,
|
| void* context) {
|
| - return g_default_zone.calloc(
|
| - reinterpret_cast<struct _malloc_zone_t*>(context), n, size);
|
| + return MallocZoneAggregator::GetMallocZoneAggregator()->DispatchCallocToZone(
|
| + context, n, size);
|
| }
|
|
|
| void* MemalignImpl(const AllocatorDispatch*,
|
| size_t alignment,
|
| size_t size,
|
| void* context) {
|
| - return g_default_zone.memalign(
|
| - reinterpret_cast<struct _malloc_zone_t*>(context), alignment, size);
|
| + return MallocZoneAggregator::GetMallocZoneAggregator()
|
| + ->DispatchMemalignToZone(context, alignment, size);
|
| }
|
|
|
| void* ReallocImpl(const AllocatorDispatch*,
|
| void* ptr,
|
| size_t size,
|
| void* context) {
|
| - return g_default_zone.realloc(
|
| - reinterpret_cast<struct _malloc_zone_t*>(context), ptr, size);
|
| + return MallocZoneAggregator::GetMallocZoneAggregator()->DispatchReallocToZone(
|
| + context, ptr, size);
|
| }
|
|
|
| void FreeImpl(const AllocatorDispatch*, void* ptr, void* context) {
|
| - g_default_zone.free(reinterpret_cast<struct _malloc_zone_t*>(context), ptr);
|
| + MallocZoneAggregator::GetMallocZoneAggregator()->DispatchFreeToZone(context,
|
| + ptr);
|
| }
|
|
|
| size_t GetSizeEstimateImpl(const AllocatorDispatch*, void* ptr, void* context) {
|
| - return g_default_zone.size(reinterpret_cast<struct _malloc_zone_t*>(context),
|
| - ptr);
|
| + return MallocZoneAggregator::GetMallocZoneAggregator()
|
| + ->DispatchGetSizeEstimateToZone(context, ptr);
|
| }
|
|
|
| unsigned BatchMallocImpl(const AllocatorDispatch* self,
|
| @@ -63,31 +58,30 @@ unsigned BatchMallocImpl(const AllocatorDispatch* self,
|
| void** results,
|
| unsigned num_requested,
|
| void* context) {
|
| - return g_default_zone.batch_malloc(
|
| - reinterpret_cast<struct _malloc_zone_t*>(context), size, results,
|
| - num_requested);
|
| + return MallocZoneAggregator::GetMallocZoneAggregator()
|
| + ->DispatchBatchMallocToZone(context, size, results, num_requested);
|
| }
|
|
|
| void BatchFreeImpl(const AllocatorDispatch* self,
|
| void** to_be_freed,
|
| unsigned num_to_be_freed,
|
| void* context) {
|
| - g_default_zone.batch_free(reinterpret_cast<struct _malloc_zone_t*>(context),
|
| - to_be_freed, num_to_be_freed);
|
| + MallocZoneAggregator::GetMallocZoneAggregator()->DispatchBatchFreeToZone(
|
| + context, to_be_freed, num_to_be_freed);
|
| }
|
|
|
| void FreeDefiniteSizeImpl(const AllocatorDispatch* self,
|
| void* ptr,
|
| size_t size,
|
| void* context) {
|
| - g_default_zone.free_definite_size(
|
| - reinterpret_cast<struct _malloc_zone_t*>(context), ptr, size);
|
| + MallocZoneAggregator::GetMallocZoneAggregator()
|
| + ->DispatchFreeDefiniteSizeToZone(context, ptr, size);
|
| }
|
|
|
| } // namespace
|
|
|
| void InitializeDefaultDispatchToMacAllocator() {
|
| - StoreFunctionsForDefaultZone(&g_default_zone);
|
| + StoreFunctionsForAllZones(MallocZoneAggregator::GetMallocZoneAggregator());
|
| }
|
|
|
| const AllocatorDispatch AllocatorDispatch::default_dispatch = {
|
|
|