OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/allocator/allocator_extension.h" | 5 #include "base/allocator/allocator_extension.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 namespace allocator { | 10 namespace allocator { |
11 | 11 |
12 bool GetProperty(const char* name, size_t* value) { | |
13 if (thunks::GetPropertyFunction* get_property_function = | |
14 base::allocator::thunks::GetGetPropertyFunction()) | |
jar (doing other things)
2012/08/11 03:39:46
nit: No reason to put a declaration in an if.... s
alexeif
2012/08/11 11:19:55
I don't like assignments inside 'if' either. I jus
| |
15 return get_property_function(name, value); | |
16 else | |
jar (doing other things)
2012/08/11 03:39:46
nit: no need for else... as you're returning.
alexeif
2012/08/11 11:19:55
Done.
| |
17 return false; | |
18 } | |
19 | |
12 void GetStats(char* buffer, int buffer_length) { | 20 void GetStats(char* buffer, int buffer_length) { |
13 DCHECK_GT(buffer_length, 0); | 21 DCHECK_GT(buffer_length, 0); |
14 if (thunks::GetStatsFunction* get_stats_function = | 22 if (thunks::GetStatsFunction* get_stats_function = |
15 base::allocator::thunks::GetGetStatsFunction()) | 23 base::allocator::thunks::GetGetStatsFunction()) |
16 get_stats_function(buffer, buffer_length); | 24 get_stats_function(buffer, buffer_length); |
17 else | 25 else |
18 buffer[0] = '\0'; | 26 buffer[0] = '\0'; |
19 } | 27 } |
20 | 28 |
21 void ReleaseFreeMemory() { | 29 void ReleaseFreeMemory() { |
22 if (thunks::ReleaseFreeMemoryFunction* release_free_memory_function = | 30 if (thunks::ReleaseFreeMemoryFunction* release_free_memory_function = |
23 base::allocator::thunks::GetReleaseFreeMemoryFunction()) | 31 base::allocator::thunks::GetReleaseFreeMemoryFunction()) |
jar (doing other things)
2012/08/11 03:39:46
nit: I think this should just be a 4 character ind
alexeif
2012/08/11 11:19:55
Done.
| |
24 release_free_memory_function(); | 32 release_free_memory_function(); |
25 } | 33 } |
26 | 34 |
35 void SetGetPropertyFunction( | |
36 thunks::GetPropertyFunction* get_property_function) { | |
37 DCHECK_EQ(base::allocator::thunks::GetGetPropertyFunction(), | |
38 reinterpret_cast<thunks::GetPropertyFunction*>(NULL)); | |
39 base::allocator::thunks::SetGetPropertyFunction(get_property_function); | |
40 } | |
41 | |
27 void SetGetStatsFunction(thunks::GetStatsFunction* get_stats_function) { | 42 void SetGetStatsFunction(thunks::GetStatsFunction* get_stats_function) { |
28 DCHECK_EQ(base::allocator::thunks::GetGetStatsFunction(), | 43 DCHECK_EQ(base::allocator::thunks::GetGetStatsFunction(), |
29 reinterpret_cast<thunks::GetStatsFunction*>(NULL)); | 44 reinterpret_cast<thunks::GetStatsFunction*>(NULL)); |
30 base::allocator::thunks::SetGetStatsFunction(get_stats_function); | 45 base::allocator::thunks::SetGetStatsFunction(get_stats_function); |
31 } | 46 } |
32 | 47 |
33 void SetReleaseFreeMemoryFunction( | 48 void SetReleaseFreeMemoryFunction( |
34 thunks::ReleaseFreeMemoryFunction* release_free_memory_function) { | 49 thunks::ReleaseFreeMemoryFunction* release_free_memory_function) { |
35 DCHECK_EQ(base::allocator::thunks::GetReleaseFreeMemoryFunction(), | 50 DCHECK_EQ(base::allocator::thunks::GetReleaseFreeMemoryFunction(), |
36 reinterpret_cast<thunks::ReleaseFreeMemoryFunction*>(NULL)); | 51 reinterpret_cast<thunks::ReleaseFreeMemoryFunction*>(NULL)); |
37 base::allocator::thunks::SetReleaseFreeMemoryFunction( | 52 base::allocator::thunks::SetReleaseFreeMemoryFunction( |
38 release_free_memory_function); | 53 release_free_memory_function); |
39 } | 54 } |
40 | 55 |
41 } // namespace allocator | 56 } // namespace allocator |
42 } // namespace base | 57 } // namespace base |
OLD | NEW |