libz_rs_sys

Function crc32

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

Calculates the crc32 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::crc32;

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

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