summaryrefslogtreecommitdiff
path: root/base/allocator/allocator_extension_thunks.cc
blob: e4024fb332e8d1edc4cff44bbcbb340c7c730f0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/allocator/allocator_extension_thunks.h"

#include <cstddef> // for NULL

namespace base {
namespace allocator {
namespace thunks {

// This slightly odd translation unit exists because of the peculularity of how
// allocator_unittests work on windows.  That target has to perform
// tcmalloc-specific initialization on windows, but it cannot depend on base
// otherwise. This target sits in the middle - base and allocator_unittests
// can depend on it. This file can't depend on anything else in base, including
// logging.

static GetAllocatorWasteSizeFunction g_get_allocator_waste_size_function = NULL;
static GetStatsFunction g_get_stats_function = NULL;
static ReleaseFreeMemoryFunction g_release_free_memory_function = NULL;

void SetGetAllocatorWasteSizeFunction(
    GetAllocatorWasteSizeFunction get_allocator_waste_size_function) {
  g_get_allocator_waste_size_function = get_allocator_waste_size_function;
}

GetAllocatorWasteSizeFunction GetGetAllocatorWasteSizeFunction() {
  return g_get_allocator_waste_size_function;
}

void SetGetStatsFunction(GetStatsFunction get_stats_function) {
  g_get_stats_function = get_stats_function;
}

GetStatsFunction GetGetStatsFunction() {
  return g_get_stats_function;
}

void SetReleaseFreeMemoryFunction(
    ReleaseFreeMemoryFunction release_free_memory_function) {
  g_release_free_memory_function = release_free_memory_function;
}

ReleaseFreeMemoryFunction GetReleaseFreeMemoryFunction() {
  return g_release_free_memory_function;
}

}  // namespace thunks
}  // namespace allocator
}  // namespace base