OLD | NEW |
---|---|
(Empty) | |
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 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
| |
13 static ReleaseFreeMemoryFunction* g_release_free_memory_function = 0; | |
14 | |
15 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.
| |
16 DCHECK_GT(buffer_length, 0); | |
17 if (g_get_stats_function) | |
18 g_get_stats_function(buffer, buffer_length); | |
19 else | |
20 buffer[0] = '\0'; | |
21 } | |
22 | |
23 void ReleaseFreeMemory() { | |
24 if (g_release_free_memory_function) | |
25 g_release_free_memory_function(); | |
26 } | |
27 | |
28 void SetGetStatsFunction(GetStatsFunction* get_stats_function) { | |
29 DCHECK_EQ(g_get_stats_function, reinterpret_cast<GetStatsFunction*>(NULL)); | |
30 g_get_stats_function = get_stats_function; | |
31 } | |
32 | |
33 void SetReleaseFreeMemoryFunction( | |
34 ReleaseFreeMemoryFunction* release_free_memory_function) { | |
35 DCHECK_EQ(g_release_free_memory_function, | |
36 reinterpret_cast<ReleaseFreeMemoryFunction*>(NULL)); | |
37 g_release_free_memory_function = release_free_memory_function; | |
38 } | |
39 | |
40 } // namespace allocator | |
41 } // namespace base | |
OLD | NEW |