Home | History | Annotate | Download | only in allocator
      1 // 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.h"
      6 
      7 #include "base/logging.h"
      8 
      9 namespace base {
     10 namespace allocator {
     11 
     12 namespace {
     13 ReleaseFreeMemoryFunction g_release_free_memory_function = nullptr;
     14 GetNumericPropertyFunction g_get_numeric_property_function = nullptr;
     15 }
     16 
     17 void ReleaseFreeMemory() {
     18   if (g_release_free_memory_function)
     19     g_release_free_memory_function();
     20 }
     21 
     22 bool GetNumericProperty(const char* name, size_t* value) {
     23   return g_get_numeric_property_function &&
     24          g_get_numeric_property_function(name, value);
     25 }
     26 
     27 void SetReleaseFreeMemoryFunction(
     28     ReleaseFreeMemoryFunction release_free_memory_function) {
     29   DCHECK(!g_release_free_memory_function);
     30   g_release_free_memory_function = release_free_memory_function;
     31 }
     32 
     33 void SetGetNumericPropertyFunction(
     34     GetNumericPropertyFunction get_numeric_property_function) {
     35   DCHECK(!g_get_numeric_property_function);
     36   g_get_numeric_property_function = get_numeric_property_function;
     37 }
     38 
     39 }  // namespace allocator
     40 }  // namespace base
     41