OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/process/memory.h" | 5 #include "base/process/memory.h" |
6 | 6 |
7 #include <psapi.h> | 7 #include <psapi.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 HMODULE instance = NULL; | 75 HMODULE instance = NULL; |
76 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | | 76 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | |
77 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, | 77 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, |
78 static_cast<char*>(address), | 78 static_cast<char*>(address), |
79 &instance)) { | 79 &instance)) { |
80 NOTREACHED(); | 80 NOTREACHED(); |
81 } | 81 } |
82 return instance; | 82 return instance; |
83 } | 83 } |
84 | 84 |
85 // TODO(b.kelemen): implement it with the required semantics. On Linux this is | |
86 // implemented with a weak symbol that is overridden by tcmalloc. This is | |
87 // neccessary because base cannot have a direct dependency on tcmalloc. Since | |
88 // weak symbols are not supported no Windows this will involve some build time | |
89 // magic, much like what is done for libcrt in order to override the allocation | |
90 // functions. | |
91 bool UncheckedMalloc(size_t size, void** result) { | |
92 *result = malloc(size); | |
93 return !!*result; | |
jar (doing other things)
2014/02/26 03:59:52
nit: Clearer might be:
return NULL != *result;
..
| |
94 } | |
95 | |
85 } // namespace base | 96 } // namespace base |
OLD | NEW |