Make memory locking optional (mlock, VirtualLock).

Fix desired locking operation (to fix "sudo" memory).
It was discovered that some systems have outdated configuration.
With too tight limit, it's almost impossible to lock anything in memory.
This commit is contained in:
Nekotekina 2020-11-10 05:56:29 +03:00
parent dcbe8ef5f4
commit d1ee7c651f
4 changed files with 20 additions and 7 deletions

View file

@ -186,12 +186,12 @@ namespace utils
#endif
}
void memory_lock(void* pointer, std::size_t size)
bool memory_lock(void* pointer, std::size_t size)
{
#ifdef _WIN32
verify("VirtualLock" HERE), ::VirtualLock(pointer, size);
return ::VirtualLock(pointer, size);
#else
verify("mlock" HERE), !::mlock(pointer, size);
return !::mlock(pointer, size);
#endif
}