| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trace_event/heap_profiler_allocation_register.h" | 5 #include "base/trace_event/heap_profiler_allocation_register.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/bits.h" | 10 #include "base/bits.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // read/write accessible space is still at least |min_size| bytes. | 44 // read/write accessible space is still at least |min_size| bytes. |
| 45 void* guard_addr = | 45 void* guard_addr = |
| 46 reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(addr) + size); | 46 reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(addr) + size); |
| 47 result = VirtualAlloc(guard_addr, GetGuardSize(), MEM_COMMIT, PAGE_NOACCESS); | 47 result = VirtualAlloc(guard_addr, GetGuardSize(), MEM_COMMIT, PAGE_NOACCESS); |
| 48 PCHECK(result != nullptr); | 48 PCHECK(result != nullptr); |
| 49 | 49 |
| 50 return addr; | 50 return addr; |
| 51 } | 51 } |
| 52 | 52 |
| 53 void FreeGuardedVirtualMemory(void* address, size_t allocated_size) { | 53 void FreeGuardedVirtualMemory(void* address, size_t allocated_size) { |
| 54 // For |VirtualFree|, the size passed with |MEM_RELEASE| mut be 0. Windows | 54 // For |VirtualFree|, the size passed with |MEM_RELEASE| must be 0. Windows |
| 55 // automatically frees the entire region that was reserved by the | 55 // automatically frees the entire region that was reserved by the |
| 56 // |VirtualAlloc| with flag |MEM_RESERVE|. | 56 // |VirtualAlloc| with flag |MEM_RESERVE|. |
| 57 VirtualFree(address, 0, MEM_RELEASE); | 57 VirtualFree(address, 0, MEM_RELEASE); |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace internal | 60 } // namespace internal |
| 61 } // namespace trace_event | 61 } // namespace trace_event |
| 62 } // namespace base | 62 } // namespace base |
| OLD | NEW |