Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: base/process/memory_win.cc

Issue 1779333003: Add test for multithreaded ActiveVerifier behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@handlecreate
Patch Set: nits Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <new.h> 7 #include <new.h>
8 #include <psapi.h> 8 #include <psapi.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void EnableTerminationOnHeapCorruption() { 88 void EnableTerminationOnHeapCorruption() {
89 // Ignore the result code. Supported on XP SP3 and Vista. 89 // Ignore the result code. Supported on XP SP3 and Vista.
90 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); 90 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
91 } 91 }
92 92
93 void EnableTerminationOnOutOfMemory() { 93 void EnableTerminationOnOutOfMemory() {
94 _set_new_handler(&OnNoMemory); 94 _set_new_handler(&OnNoMemory);
95 _set_new_mode(1); 95 _set_new_mode(1);
96 } 96 }
97 97
98 HMODULE GetModuleFromAddress(void* address) { 98 HMODULE GetModuleFromAddress(const void* address) {
99 HMODULE instance = NULL; 99 HMODULE instance = NULL;
100 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | 100 if (!::GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
101 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, 101 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
102 static_cast<char*>(address), 102 static_cast<char*>(const_cast<void*>(address)),
103 &instance)) { 103 &instance)) {
104 NOTREACHED(); 104 NOTREACHED();
105 } 105 }
106 return instance; 106 return instance;
107 } 107 }
108 108
109 // Implemented using a weak symbol. 109 // Implemented using a weak symbol.
110 bool UncheckedMalloc(size_t size, void** result) { 110 bool UncheckedMalloc(size_t size, void** result) {
111 *result = malloc_unchecked(size); 111 *result = malloc_unchecked(size);
112 return *result != NULL; 112 return *result != NULL;
113 } 113 }
114 114
115 } // namespace base 115 } // namespace base
OLDNEW
« no previous file with comments | « base/process/memory.h ('k') | base/win/scoped_handle.h » ('j') | base/win/scoped_handle.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698