[email protected] | 237a1485 | 2012-04-28 02:56:38 | [diff] [blame] | 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 | void GetStats(char* buffer, int buffer_length) { |
| 13 | DCHECK_GT(buffer_length, 0); |
| 14 | if (thunks::GetStatsFunction* get_stats_function = |
| 15 | base::allocator::thunks::GetGetStatsFunction()) |
| 16 | get_stats_function(buffer, buffer_length); |
| 17 | else |
| 18 | buffer[0] = '\0'; |
| 19 | } |
| 20 | |
| 21 | void ReleaseFreeMemory() { |
| 22 | if (thunks::ReleaseFreeMemoryFunction* release_free_memory_function = |
| 23 | base::allocator::thunks::GetReleaseFreeMemoryFunction()) |
| 24 | release_free_memory_function(); |
| 25 | } |
| 26 | |
| 27 | void SetGetStatsFunction(thunks::GetStatsFunction* get_stats_function) { |
| 28 | DCHECK_EQ(base::allocator::thunks::GetGetStatsFunction(), |
| 29 | reinterpret_cast<thunks::GetStatsFunction*>(NULL)); |
| 30 | base::allocator::thunks::SetGetStatsFunction(get_stats_function); |
| 31 | } |
| 32 | |
| 33 | void SetReleaseFreeMemoryFunction( |
| 34 | thunks::ReleaseFreeMemoryFunction* release_free_memory_function) { |
| 35 | DCHECK_EQ(base::allocator::thunks::GetReleaseFreeMemoryFunction(), |
| 36 | reinterpret_cast<thunks::ReleaseFreeMemoryFunction*>(NULL)); |
| 37 | base::allocator::thunks::SetReleaseFreeMemoryFunction( |
| 38 | release_free_memory_function); |
| 39 | } |
| 40 | |
| 41 | } // namespace allocator |
| 42 | } // namespace base |