Index: base/allocator/win_allocator.cc |
diff --git a/base/allocator/win_allocator.cc b/base/allocator/win_allocator.cc |
index ee451f546101c008c0b081f4c880790c20027bd6..98aea70ded27d1f9da63310a7ce0905a5c4e5f5a 100644 |
--- a/base/allocator/win_allocator.cc |
+++ b/base/allocator/win_allocator.cc |
@@ -6,27 +6,30 @@ |
extern "C" { |
+const size_t kWindowsPageSize = 4096; |
+const size_t kMaxWindowsAllocation = |
+ std::numeric_limits<int>::max() - kWindowsPageSize; |
HANDLE win_heap; |
-bool win_heap_init(bool use_lfh) { |
- win_heap = HeapCreate(0, 0, 0); |
+bool win_heap_init() { |
+ win_heap = static_cast<HANDLE>(GetProcessHeap()); |
cpu_(ooo_6.6-7.5)
2015/01/07 17:25:26
use http://msdn.microsoft.com/en-us/library/csd157
Will Harris
2015/01/07 17:29:37
yes I was going to use _get_heap_handle, but for s
|
if (win_heap == NULL) |
return false; |
- if (use_lfh) { |
- ULONG enable_lfh = 2; |
- HeapSetInformation(win_heap, HeapCompatibilityInformation, |
- &enable_lfh, sizeof(enable_lfh)); |
- // NOTE: Setting LFH may fail. Vista already has it enabled. |
- // And under the debugger, it won't use LFH. So we |
- // ignore any errors. |
- } |
+ ULONG enable_lfh = 2; |
+ // NOTE: Setting LFH may fail. Vista already has it enabled. |
+ // And under the debugger, it won't use LFH. So we |
+ // ignore any errors. |
+ HeapSetInformation(win_heap, HeapCompatibilityInformation, &enable_lfh, |
+ sizeof(enable_lfh)); |
return true; |
} |
void* win_heap_malloc(size_t size) { |
- return HeapAlloc(win_heap, 0, size); |
+ if (size < kMaxWindowsAllocation) |
+ return HeapAlloc(win_heap, 0, size); |
+ return NULL; |
} |
void win_heap_free(void* size) { |
@@ -40,7 +43,9 @@ void* win_heap_realloc(void* ptr, size_t size) { |
win_heap_free(ptr); |
return NULL; |
} |
- return HeapReAlloc(win_heap, 0, ptr, size); |
+ if (size < kMaxWindowsAllocation) |
cpu_(ooo_6.6-7.5)
2015/01/07 17:25:26
if (size > kMaxWindowsAllocation)
return NULL;
|
+ return HeapReAlloc(win_heap, 0, ptr, size); |
+ return NULL; |
} |
size_t win_heap_msize(void* ptr) { |