ICSharpCode.SharpZipLib.Zip.Compression.PendingBuffer.Flush C# (CSharp) Method

Flush() public method

Flushes the pending buffer into the given output array. If the output array is to small, only a partial flush is done.
public Flush ( byte output, int offset, int length ) : int
output byte The output array.
offset int The offset into output array.
length int The maximum number of bytes to store.
return int
        public int Flush(byte[] output, int offset, int length)
        {
            if (bitCount >= 8) {
                buffer_[end++] = unchecked((byte)bits);
                bits >>= 8;
                bitCount -= 8;
            }

            if (length > end - start) {
                length = end - start;
                System.Array.Copy(buffer_, start, output, offset, length);
                start = 0;
                end = 0;
            } else {
                System.Array.Copy(buffer_, start, output, offset, length);
                start += length;
            }
            return length;
        }