public void Dispose() { if (mPtrInputBuffer != IntPtr.Zero) { Marshal.FreeHGlobal(mPtrInputBuffer); mPtrInputBuffer = IntPtr.Zero; } if (mPtrOutputBuffer != IntPtr.Zero) { Marshal.FreeHGlobal(mPtrOutputBuffer); mPtrOutputBuffer = IntPtr.Zero; } if (mCompressionMode == CompressionMode.Compress) { Brolib.BrotliEncoderDestroyInstance(mPtrState); return; } Brolib.BrotliDecoderDestroyInstance(mPtrState); }
protected override void Dispose(bool disposing) { if (_mode == CompressionMode.Compress) { FlushBrotliStream(true); } base.Dispose(disposing); if (!_leaveOpen) { _stream.Dispose(); } _intermediateStream.Dispose(); if (_ptrInputBuffer != IntPtr.Zero) { Marshal.FreeHGlobal(_ptrInputBuffer); } if (_ptrOutputBuffer != IntPtr.Zero) { Marshal.FreeHGlobal(_ptrOutputBuffer); } _managedBuffer = null; _ptrInputBuffer = IntPtr.Zero; _ptrOutputBuffer = IntPtr.Zero; if (_state != IntPtr.Zero) { if (_mode == CompressionMode.Compress) { Brolib.BrotliEncoderDestroyInstance(_state); } else { Brolib.BrotliDecoderDestroyInstance(_state); } _state = IntPtr.Zero; } }