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#ifndef BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_
6#define BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_
7
8#include <stddef.h> // for size_t
9
10#include "base/base_export.h"
11#include "build/build_config.h"
12
13namespace base {
14namespace allocator {
15
16typedef void (*ReleaseFreeMemoryFunction)();
17typedef bool (*GetNumericPropertyFunction)(const char* name, size_t* value);
18
19// Request that the allocator release any free memory it knows about to the
20// system.
21BASE_EXPORT void ReleaseFreeMemory();
22
23// Get the named property's |value|. Returns true if the property is known.
24// Returns false if the property is not a valid property name for the current
25// allocator implementation.
26// |name| or |value| cannot be NULL
27BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value);
28
29// These settings allow specifying a callback used to implement the allocator
30// extension functions.  These are optional, but if set they must only be set
31// once.  These will typically called in an allocator-specific initialization
32// routine.
33//
34// No threading promises are made.  The caller is responsible for making sure
35// these pointers are set before any other threads attempt to call the above
36// functions.
37
38BASE_EXPORT void SetReleaseFreeMemoryFunction(
39    ReleaseFreeMemoryFunction release_free_memory_function);
40
41BASE_EXPORT void SetGetNumericPropertyFunction(
42    GetNumericPropertyFunction get_numeric_property_function);
43
44}  // namespace allocator
45}  // namespace base
46
47#endif  // BASE_ALLOCATOR_ALLOCATOR_EXTENSION_H_
48