Hi, I am using a slightly modified version of the DotZlib which is part of the contrib directory with the zlib source code to inflate a realtime data stream.
Instead of the regular inflateInit I need to use InflateInit2 - but this the only difference to the provided library.
Netherlesse after a couple of reads I receive error code 1 from the zlib and do not manage to recover when adding bytes.
The original code from the zlib contrib directory is:
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException()
;
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
err = inflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = inflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
setChecksum( _ztream.adler );
}
BTW Does anyone know how to contribute improved code? The implementation is nicely designed, but incomplete from my point of view.