markConsumed method

void markConsumed()

Internal: called by Session.open / Zenoh.scout after the config has been moved into zenoh-c via z_config_move.

Mirrors ZBytes.markConsumed: the move gravestones the native z_owned_config_t, so the Dart-owned calloc block wrapping it is freed here. The native handle is deliberately NOT dropped (zenoh-c already gravestoned it -- drop-after-move is the double-drop class).

Unlike ZBytes, a consumed config is not silently disposable: dispose still throws StateError (see its doc). Freeing here is what makes the internally-created config of a Session.open({config: null}) reclaimable at all -- it has no other owner to dispose it.

Callers must mark only after the consuming FFI call has returned.

Implementation

void markConsumed() {
  if (_disposed || _consumed) return;
  _consumed = true;
  // ⛔ THE HOT DETACH. This method FREES the block rather than transferring
  // it, so without this line the finalizer would later hand the same address
  // to `free()` a second time -- a double free on the session-open path, not
  // a leak. Canon has already gravestoned the native handle, so the
  // finalizer's `zd_config_drop` would be a drop-after-move besides.
  configFinalizer.detach(this);
  calloc.free(_ptr);
}