libz_rs_sys

Function adler32

Source
#[export_name = "adler32"]
pub unsafe extern "C-unwind" fn adler32(
    adler: c_ulong,
    buf: *const Bytef,
    len: uInt,
) -> c_ulong
Expand description

Calculates the adler32 checksum of a sequence of bytes.

When the pointer argument is NULL, the initial checksum value is returned.

§Safety

The caller must guarantee that either:

§Example

use libz_rs_sys::adler32;

unsafe {
    assert_eq!(adler32(0, core::ptr::null(), 0), 1);
    assert_eq!(adler32(1, core::ptr::null(), 32), 1);

    let input = [1,2,3];
    assert_eq!(adler32(0, input.as_ptr(), input.len() as _), 655366);
}