| 184 | page_size = sSysInfo.dwPageSize; |
| 185 | } |
| 186 | void *Win32LockedPageAllocator::AllocateLocked(size_t len, bool *lockingSuccess) |
| 187 | { |
| 188 | len = align_up(len, page_size); |
| 189 | void *addr = VirtualAlloc(nullptr, len, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); |
| 190 | if (addr) { |
| 191 | // VirtualLock is used to attempt to keep keying material out of swap. Note |
| 192 | // that it does not provide this as a guarantee, but, in practice, memory |
| 193 | // that has been VirtualLock'd almost never gets written to the pagefile |
| 194 | // except in rare circumstances where memory is extremely low. |
| 195 | *lockingSuccess = VirtualLock(const_cast<void*>(addr), len) != 0; |
| 196 | } |
| 197 | return addr; |
| 198 | } |
| 199 | void Win32LockedPageAllocator::FreeLocked(void* addr, size_t len) |
| 200 | { |
| 201 | len = align_up(len, page_size); |