dispose method
void
dispose()
Releases native resources held by this serializer.
Safe to call multiple times -- subsequent calls are no-ops. Safe to call after finish -- no-op since resources were already transferred.
Also detaches this object's finalizer, so the safety net cannot release it a second time.
Implementation
void dispose() {
if (_disposed) return;
if (_finished) {
// `finish()` already detached and released; a second detach here would
// be harmless but the early return makes it unreachable, and saying so
// is what keeps the "safe to call multiple times" note honest.
_disposed = true;
return;
}
_disposed = true;
serializerFinalizer.detach(this);
bindings.zd_serializer_drop(_ptr.cast());
calloc.free(_ptr);
}