libz_rs_sys

Function deflateBound

Source
#[export_name = "deflateBound"]
pub unsafe extern "C-unwind" fn deflateBound(
    strm: *mut z_stream,
    sourceLen: c_ulong,
) -> c_ulong
Expand description

Returns an upper bound on the compressed size after deflation of sourceLen bytes.

This function must be called after deflateInit_ or deflateInit2_. This would be used to allocate an output buffer for deflation in a single pass, and so would be called before deflate. If that first deflate call is provided the sourceLen input bytes, an output buffer allocated to the size returned by deflateBound, and the flush value Z_FINISH, then deflate is guaranteed to return Z_STREAM_END.

Note that it is possible for the compressed size to be larger than the value returned by deflateBound if flush options other than Z_FINISH or Z_NO_FLUSH are used.

ยงSafety

  • Either
    • strm is NULL
    • strm satisfies the requirements of &mut *strm and was initialized with deflateInit_ or similar