blob: e4024fb332e8d1edc4cff44bbcbb340c7c730f0a [file] [log] [blame]
[email protected]237a14852012-04-28 02:56:381// Copyright (c) 2012 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
5#include "base/allocator/allocator_extension_thunks.h"
6
7#include <cstddef> // for NULL
8
9namespace base {
10namespace allocator {
11namespace thunks {
12
13// This slightly odd translation unit exists because of the peculularity of how
[email protected]a849dc12012-05-24 11:13:2314// allocator_unittests work on windows. That target has to perform
[email protected]237a14852012-04-28 02:56:3815// tcmalloc-specific initialization on windows, but it cannot depend on base
[email protected]a849dc12012-05-24 11:13:2316// otherwise. This target sits in the middle - base and allocator_unittests
17// can depend on it. This file can't depend on anything else in base, including
18// logging.
[email protected]237a14852012-04-28 02:56:3819
[email protected]3b8759592012-12-07 12:19:5120static GetAllocatorWasteSizeFunction g_get_allocator_waste_size_function = NULL;
[email protected]094c8932012-09-17 11:44:1021static GetStatsFunction g_get_stats_function = NULL;
22static ReleaseFreeMemoryFunction g_release_free_memory_function = NULL;
[email protected]237a14852012-04-28 02:56:3823
[email protected]3b8759592012-12-07 12:19:5124void SetGetAllocatorWasteSizeFunction(
25 GetAllocatorWasteSizeFunction get_allocator_waste_size_function) {
26 g_get_allocator_waste_size_function = get_allocator_waste_size_function;
[email protected]094c8932012-09-17 11:44:1027}
28
[email protected]3b8759592012-12-07 12:19:5129GetAllocatorWasteSizeFunction GetGetAllocatorWasteSizeFunction() {
30 return g_get_allocator_waste_size_function;
[email protected]094c8932012-09-17 11:44:1031}
32
33void SetGetStatsFunction(GetStatsFunction get_stats_function) {
[email protected]237a14852012-04-28 02:56:3834 g_get_stats_function = get_stats_function;
35}
36
[email protected]094c8932012-09-17 11:44:1037GetStatsFunction GetGetStatsFunction() {
[email protected]237a14852012-04-28 02:56:3838 return g_get_stats_function;
39}
40
41void SetReleaseFreeMemoryFunction(
[email protected]094c8932012-09-17 11:44:1042 ReleaseFreeMemoryFunction release_free_memory_function) {
[email protected]237a14852012-04-28 02:56:3843 g_release_free_memory_function = release_free_memory_function;
44}
45
[email protected]094c8932012-09-17 11:44:1046ReleaseFreeMemoryFunction GetReleaseFreeMemoryFunction() {
[email protected]237a14852012-04-28 02:56:3847 return g_release_free_memory_function;
48}
49
50} // namespace thunks
51} // namespace allocator
52} // namespace base