public static int compress2(byte[] dest, ref int destLen, byte[] source, int sourceLen, int level) { z_stream_s stream = new z_stream_s(); int err = 0; int max = int.MaxValue; int left = destLen; err = (int)Deflate.deflateInit_(stream, level, "1.2.11"); if (err != 0) { return(err); } stream.next_out = dest; stream.avail_out = 0; stream.next_in = source; stream.avail_in = 0; do { if (stream.avail_out == 0) { stream.avail_out = left > ((int)max) ? max : left; left -= (int)stream.avail_out; } if (stream.avail_in == 0) { stream.avail_in = sourceLen > ((int)max) ? max : sourceLen; sourceLen -= (int)stream.avail_in; } err = (int)Deflate.deflate(stream, sourceLen != 0 ? 0 : 4); }while (err == 0); destLen = stream.total_out; Deflate.deflateEnd(stream); return(err == 1 ? 0 : err); }
public int deflateEnd() { if (dstate == null) return Z_STREAM_ERROR; int ret = dstate.deflateEnd(); dstate = null; return ret; }
public int deflateEnd() { if (dstate == null) { return(Z_STREAM_ERROR); } int ret = dstate.deflateEnd(); dstate = null; return(ret); }
public int deflateEnd() { if (dstate == null) { return(-2); } int result = dstate.deflateEnd(); dstate = null; return(result); }
/// <summary> /// All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending /// output. /// </summary> /// <returns> /// deflateEnd returns <see cref="ZLibResultCode.Z_OK" /> if success, <see cref="ZLibResultCode.Z_STREAM_ERROR" /> if the stream state was inconsistent, /// <see cref="ZLibResultCode.Z_DATA_ERROR" /> if the stream was freed prematurely (some input or output was discarded). In the error case, /// <see cref="msg" /> may be set but then points to a static string (which must not be deallocated). /// </returns> public int deflateEnd() { next_in_index = 0; next_out_index = 0; if (_dstate == null) { return((int)ZLibResultCode.Z_STREAM_ERROR); } int ret = _dstate.deflateEnd(); _dstate = null; return(ret); }