Chromium Code Reviews| 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 <limits.h> | 5 #include <limits.h> |
| 6 #include <malloc.h> | 6 #include <malloc.h> |
| 7 #include <new.h> | 7 #include <new.h> |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 const size_t kWindowsPageSize = 4096; | 37 const size_t kWindowsPageSize = 4096; |
| 38 const size_t kMaxWindowsAllocation = INT_MAX - kWindowsPageSize; | 38 const size_t kMaxWindowsAllocation = INT_MAX - kWindowsPageSize; |
| 39 int new_mode = 0; | 39 int new_mode = 0; |
| 40 | 40 |
| 41 // VS2013 crt uses the process heap as its heap, so we do the same here. | 41 // VS2013 crt uses the process heap as its heap, so we do the same here. |
| 42 // See heapinit.c in VS CRT sources. | 42 // See heapinit.c in VS CRT sources. |
| 43 bool win_heap_init() { | 43 bool win_heap_init() { |
| 44 // Set the _crtheap global here. THis allows us to offload most of the | 44 // Set the _crtheap global here. THis allows us to offload most of the |
| 45 // memory management to the CRT, except the functions we need to shim. | 45 // memory management to the CRT, except the functions we need to shim. |
| 46 _crtheap = GetProcessHeap(); | 46 _crtheap = GetProcessHeap(); |
| 47 if (_crtheap == NULL) | 47 return _crtheap != NULL; |
|
scottmg
2016/03/29 20:23:32
NULL -> nullptr
manzagop (departed)
2016/03/29 20:35:04
Done.
| |
| 48 return false; | |
| 49 | |
| 50 ULONG enable_lfh = 2; | |
| 51 // NOTE: Setting LFH may fail. Vista already has it enabled. | |
| 52 // And under the debugger, it won't use LFH. So we | |
| 53 // ignore any errors. | |
| 54 HeapSetInformation(_crtheap, HeapCompatibilityInformation, &enable_lfh, | |
| 55 sizeof(enable_lfh)); | |
| 56 | |
| 57 return true; | |
| 58 } | 48 } |
| 59 | 49 |
| 60 void* win_heap_malloc(size_t size) { | 50 void* win_heap_malloc(size_t size) { |
| 61 if (size < kMaxWindowsAllocation) | 51 if (size < kMaxWindowsAllocation) |
| 62 return HeapAlloc(_crtheap, 0, size); | 52 return HeapAlloc(_crtheap, 0, size); |
| 63 return NULL; | 53 return NULL; |
| 64 } | 54 } |
| 65 | 55 |
| 66 void win_heap_free(void* size) { | 56 void win_heap_free(void* size) { |
| 67 HeapFree(_crtheap, 0, size); | 57 HeapFree(_crtheap, 0, size); |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 void _free_dbg(void* ptr, int) { | 310 void _free_dbg(void* ptr, int) { |
| 321 free(ptr); | 311 free(ptr); |
| 322 } | 312 } |
| 323 | 313 |
| 324 void* _calloc_dbg(size_t n, size_t size, int, const char*, int) { | 314 void* _calloc_dbg(size_t n, size_t size, int, const char*, int) { |
| 325 return calloc(n, size); | 315 return calloc(n, size); |
| 326 } | 316 } |
| 327 #endif // NDEBUG | 317 #endif // NDEBUG |
| 328 | 318 |
| 329 } // extern C | 319 } // extern C |
| OLD | NEW |