locked property

bool locked

Controlls whether the pointer is locked in memory or not.

This provides convenient access to sodium_mlock and sodium_munlock via a single property. All SodiumPointers are locked by default, as sodium_malloc already lockes them.

See https://libsodium.gitbook.io/doc/memory_management#locking-memory

Implementation

bool get locked => _locked;
void locked=(bool locked)

Implementation

set locked(bool locked) {
  if (locked == _locked) {
    return;
  }

  int result;
  if (locked) {
    result = sodium.sodium_mlock(ptr.cast(), byteLength);
  } else {
    result = sodium.sodium_munlock(ptr.cast(), byteLength);
  }
  SodiumException.checkSucceededInt(result);

  _locked = locked;
}