Skip to content

Commit

Permalink
Remove {in,de}flate_bytes_zlib.
Browse files Browse the repository at this point in the history
These functions are unused.
  • Loading branch information
nnethercote committed Oct 20, 2016
1 parent 0c42987 commit feefe77
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions src/libflate/lib.rs
Expand Up @@ -95,10 +95,10 @@ extern "C" {
}

const LZ_NORM: c_int = 0x80; // LZ with 128 probes, "normal"
const TINFL_FLAG_PARSE_ZLIB_HEADER: c_int = 0x1; // parse zlib header and adler32 checksum
const TDEFL_WRITE_ZLIB_HEADER: c_int = 0x01000; // write zlib header and adler32 checksum

fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Bytes {
/// Compress a buffer without writing any sort of header on the output.
pub fn deflate_bytes(bytes: &[u8]) -> Bytes {
let flags = LZ_NORM;
unsafe {
let mut outsz: size_t = 0;
let res = tdefl_compress_mem_to_heap(bytes.as_ptr() as *const _,
Expand All @@ -113,17 +113,9 @@ fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Bytes {
}
}

/// Compress a buffer, without writing any sort of header on the output.
pub fn deflate_bytes(bytes: &[u8]) -> Bytes {
deflate_bytes_internal(bytes, LZ_NORM)
}

/// Compress a buffer, using a header that zlib can understand.
pub fn deflate_bytes_zlib(bytes: &[u8]) -> Bytes {
deflate_bytes_internal(bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER)
}

fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Result<Bytes, Error> {
/// Decompress a buffer without parsing any sort of header on the input.
pub fn inflate_bytes(bytes: &[u8]) -> Result<Bytes, Error> {
let flags = 0;
unsafe {
let mut outsz: size_t = 0;
let res = tinfl_decompress_mem_to_heap(bytes.as_ptr() as *const _,
Expand All @@ -141,16 +133,6 @@ fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Result<Bytes, Error> {
}
}

/// Decompress a buffer, without parsing any sort of header on the input.
pub fn inflate_bytes(bytes: &[u8]) -> Result<Bytes, Error> {
inflate_bytes_internal(bytes, 0)
}

/// Decompress a buffer that starts with a zlib header.
pub fn inflate_bytes_zlib(bytes: &[u8]) -> Result<Bytes, Error> {
inflate_bytes_internal(bytes, TINFL_FLAG_PARSE_ZLIB_HEADER)
}

#[cfg(test)]
mod tests {
#![allow(deprecated)]
Expand Down

0 comments on commit feefe77

Please sign in to comment.