Module: compress.zlib

Source: ./compress/zlib.reef


Overview

compress/zlib - Zlib compression using FFI

This module provides zlib compression/decompression using the system's zlib library via FFI. The zlib format includes a header and checksum.

IMPORTANT: This module requires the zlib library (-lz) to be linked. reefc auto-links -lz when compress.zlib is imported (directly or transitively), so no manual linker flags are needed.

Uses native byte arrays ([byte]) which map directly to C's unsigned char*, providing efficient memory usage and correct operation with zlib.

Usage: import compress.zlib unsafe let src: [byte] = zlib_alloc_buffer(100) // Fill src with data let dest: [byte] = zlib_alloc_buffer(zlib_compress_bound(100)) let compressed_len = zlib_compress(src, 100, dest, dest_size) end unsafe


Functions

fn compress2(dest: pointer, destLen: pointer, src: pointer, srcLen: int, level: int): int

Zlib FFI functions

fn uncompress(dest: pointer, destLen: pointer, src: pointer, srcLen: int): int

fn compressBound(srcLen: int): int

fn ZLIB_NO_COMPRESSION(): int

fn ZLIB_BEST_SPEED(): int

fn ZLIB_BEST_COMPRESSION(): int

fn ZLIB_DEFAULT_COMPRESSION(): int

fn ZLIB_OK(): int

fn ZLIB_STREAM_END(): int

fn ZLIB_ERRNO(): int

fn ZLIB_STREAM_ERROR(): int

fn ZLIB_DATA_ERROR(): int

fn ZLIB_MEM_ERROR(): int

fn ZLIB_BUF_ERROR(): int

fn zlib_alloc_buffer(size: int): [uint8]

Allocate a byte buffer for use with compression functions

fn zlib_compress_bound(src_len: int): int

fn zlib_compress(src: [uint8], src_len: int, dest: [uint8], dest_len: int): int

Compress data with default compression level

fn zlib_compress_level(src: [uint8], src_len: int, dest: [uint8], dest_len: int, level: int): int

Compress data with specified compression level

fn zlib_decompress(src: [uint8], src_len: int, dest: [uint8], dest_len: int): int


Generated by reefc doc