libz_rs_sys

Function uncompress

Source
#[export_name = "uncompress"]
pub unsafe extern "C-unwind" fn uncompress(
    dest: *mut u8,
    destLen: *mut c_ulong,
    source: *const u8,
    sourceLen: c_ulong,
) -> c_int
Expand description

Inflates source into dest, and writes the final inflated size into destLen.

Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the uncompressed data.

§Returns

In the case where there is not enough room, uncompress will fill the output buffer with the uncompressed data up to that point.

§Safety

The caller must guarantee that

§Example

use libz_rs_sys::{Z_OK, uncompress};

let source = [120, 156, 115, 75, 45, 42, 202, 44, 6, 0, 8, 6, 2, 108];

let mut dest = vec![0u8; 100];
let mut dest_len = dest.len() as _;

let err = unsafe {
    uncompress(
        dest.as_mut_ptr(),
        &mut dest_len,
        source.as_ptr(),
        source.len() as _,
    )
};

assert_eq!(err, Z_OK);
assert_eq!(dest_len, 6);

dest.truncate(dest_len as usize);
assert_eq!(dest, b"Ferris");