Closed HadrienG2 closed 4 years ago
That's a keen observation, and I concur.
When I first designed this library back in 2016, I was not aware of mem::forget
and it's characteristics (it being safe), nor that destructors had no guarantee to be called. Using unsafe
for the LockGuard::release
was also a bit of a misnomer, since I assumed that leaving a page lock was not safe behavior per-se, but I forgot to take into account Rust's exact definition of safe code.
With that said, I will update the library by deprecating the following:
LockGuard::release
ProtectGuard::release
And completely remove these at a later date.
Given that it's just a mem::forget under the hood, which is otherwise safe to call, and that AFAIK the typical operating system won't even mind if you don't unlock the memory and just do it for you at memory deallocation time, I do not get it.