MCPcopy Create free account
hub / github.com/ElementsProject/elements / AllocateLocked

Method AllocateLocked

src/support/lockedpool.cpp:186–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184 page_size = sSysInfo.dwPageSize;
185}
186void *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}
199void Win32LockedPageAllocator::FreeLocked(void* addr, size_t len)
200{
201 len = align_up(len, page_size);

Callers 1

new_arenaMethod · 0.45

Calls 1

align_upFunction · 0.85

Tested by

no test coverage detected