Commit b25d4263 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

base/allocator: Move InitializeDefaultDispatchToMacAllocator

Moves InitializeDefaultDispatchToMacAllocator from
allocator_shim_default_dispatch_to_mac_zoned_malloc.{cc,h} to
allocator_interception_mac.{cc,h} so that it works with other
allocator shims.

The function is used to hook the standard allocation functions
and not used to install our own allocator shim.  So,
allocator_interception_mac.{cc,h} is a better place.

This patch makes PA-E on macOS compilable.

Bug: 998048
Change-Id: I03f3cecc0f79febd5aec6ef4fde9a72cc0787d37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2400781Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarBenoit L <lizeb@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805811}
parent 767a6fa1
......@@ -15,6 +15,11 @@ namespace allocator {
struct MallocZoneFunctions;
// This initializes AllocatorDispatch::default_dispatch by saving pointers to
// the functions in the current default malloc zone. This must be called before
// the default malloc zone is changed to have its intended effect.
void InitializeDefaultDispatchToMacAllocator();
// Saves the function pointers currently used by the default zone.
void StoreFunctionsForDefaultZone();
......
......@@ -310,6 +310,10 @@ bool UncheckedCallocMac(size_t num_items, size_t size, void** result) {
return *result != NULL;
}
void InitializeDefaultDispatchToMacAllocator() {
StoreFunctionsForAllZones();
}
void StoreFunctionsForDefaultZone() {
ChromeMallocZone* default_zone = reinterpret_cast<ChromeMallocZone*>(
malloc_default_zone());
......
......@@ -329,7 +329,6 @@ ALWAYS_INLINE void ShimAlignedFree(void* address, void* context) {
// On Windows we use plain link-time overriding of the CRT symbols.
#include "base/allocator/allocator_shim_override_ucrt_symbols_win.h"
#elif defined(OS_APPLE)
#include "base/allocator/allocator_shim_default_dispatch_to_mac_zoned_malloc.h"
#include "base/allocator/allocator_shim_override_mac_symbols.h"
#else
#include "base/allocator/allocator_shim_override_libc_symbols.h"
......
......@@ -88,10 +88,6 @@ void FreeDefiniteSizeImpl(const AllocatorDispatch* self,
} // namespace
void InitializeDefaultDispatchToMacAllocator() {
StoreFunctionsForAllZones();
}
const AllocatorDispatch AllocatorDispatch::default_dispatch = {
&MallocImpl, /* alloc_function */
&CallocImpl, /* alloc_zero_initialized_function */
......
......@@ -8,11 +8,6 @@
namespace base {
namespace allocator {
// This initializes AllocatorDispatch::default_dispatch by saving pointers to
// the functions in the current default malloc zone. This must be called before
// the default malloc zone is changed to have its intended effect.
void InitializeDefaultDispatchToMacAllocator();
} // namespace allocator
} // namespace base
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment