Chromium Code Reviews| Index: base/allocator/allocator_extension.cc |
| diff --git a/base/allocator/allocator_extension.cc b/base/allocator/allocator_extension.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..05c0da018fcf26feeef9d38971f31f23fe85ffef |
| --- /dev/null |
| +++ b/base/allocator/allocator_extension.cc |
| @@ -0,0 +1,41 @@ |
| +// 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.h" |
| + |
| +#include "base/logging.h" |
| + |
| +namespace base { |
| +namespace allocator { |
| + |
| +static GetStatsFunction* g_get_stats_function = 0; |
|
willchan no longer on Chromium
2012/04/26 22:08:48
nit: s/0/NULL/. I've never seen = 0 for a pointer
|
| +static ReleaseFreeMemoryFunction* g_release_free_memory_function = 0; |
| + |
| +void GetStats(char* buffer, int buffer_length) { |
|
willchan no longer on Chromium
2012/04/26 22:08:48
You may need BASE_EXPORT here too.
|
| + DCHECK_GT(buffer_length, 0); |
| + if (g_get_stats_function) |
| + g_get_stats_function(buffer, buffer_length); |
| + else |
| + buffer[0] = '\0'; |
| +} |
| + |
| +void ReleaseFreeMemory() { |
| + if (g_release_free_memory_function) |
| + g_release_free_memory_function(); |
| +} |
| + |
| +void SetGetStatsFunction(GetStatsFunction* get_stats_function) { |
| + DCHECK_EQ(g_get_stats_function, reinterpret_cast<GetStatsFunction*>(NULL)); |
| + g_get_stats_function = get_stats_function; |
| +} |
| + |
| +void SetReleaseFreeMemoryFunction( |
| + ReleaseFreeMemoryFunction* release_free_memory_function) { |
| + DCHECK_EQ(g_release_free_memory_function, |
| + reinterpret_cast<ReleaseFreeMemoryFunction*>(NULL)); |
| + g_release_free_memory_function = release_free_memory_function; |
| +} |
| + |
| +} // namespace allocator |
| +} // namespace base |