Lzlib

lzlib logo

Introduction

Lzlib is a data compression library providing in-memory LZMA compression and decompression functions, including integrity checking of the decompressed data. The compressed data format used by the library is the lzip format. Lzlib is written in C.

The functions and variables forming the interface of the compression library are declared in the file 'lzlib.h'. Usage examples of the library are given in the files 'bbexample.c', 'ffexample.c', and 'minilzip.c' from the source distribution.

All the library functions are thread safe. The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input.

Compression/decompression is done by repeatedly calling a couple of read/write functions until all the data have been processed by the library. This interface is safer and less error prone than the traditional zlib interface.

Compression/decompression is done when the read function is called. This means the value returned by the position functions is not updated until a read call, even if a lot of data are written. If you want the data to be compressed in advance, just call the read function with a size equal to 0.

If all the data to be compressed are written in advance, lzlib automatically adjusts the header of the compressed data to use the largest dictionary size that does not exceed neither the data size nor the limit given to 'LZ_compress_open'. This feature reduces the amount of memory needed for decompression and allows minilzip to produce identical compressed output as lzip.

Lzlib correctly decompresses a data stream which is the concatenation of two or more compressed data streams. The result is the concatenation of the corresponding decompressed data streams. Integrity testing of concatenated compressed data streams is also supported.

Lzlib is able to compress and decompress streams of unlimited size by automatically creating multimember output. The members so created are large, about 2 PiB each.

Documentation

The manual is available in the info system of the GNU Operating System. Use info to access the top level info page. Use info lzlib to access the lzlib section directly.

An online manual for lzlib can be found at manual/lzlib_manual.html.

Download

The latest released version of lzlib can be found at http://download.savannah.gnu.org/releases/lzip/lzlib/. You may also subscribe to lzip-bug and receive an email every time a new version is released.

You may compile and install lzlib by running the following commands:

tar -xf lzlib[version].tar.gz
cd lzlib[version] && ./configure && make all check

then (as root) type:

make install

How to get help

For general discussion of errors (bugs) in lzlib, the mailing list lzip-bug@nongnu.org is the most appropriate forum. Please send messages as plain text. Do not send HTML, base64 MIME, nor multiple formats. Use a descriptive subject line with the word "lzlib" in it.

An archive of the bug report mailing list is available at http://lists.gnu.org/mailman/listinfo/lzip-bug.

How to help

To contact the author, either to report an error (bug) or to contribute fixes or improvements, send mail to lzip-bug@nongnu.org. Please send messages as plain text. If posting patches they should be in unified diff format against the latest version. They should include a text description.

If you know someone who is using gzip, bzip2, or xz, please tell him/her about the advantages of switching to lzip. See this comparison of the formats and this comparison of the tools.

See also the lzip project page at Savannah.

Licensing

Lzlib is free software distributed under a 2-clause BSD license.

Valid HTML 4.01 Strict


Copyright © 2025 Antonio Diaz Diaz
Lzlib logo Copyright © 2013 Sonia Diaz Pacheco

You are free to copy, modify, and distribute all or part of this article without limitation.

Updated: 2025-01-13

This page does not use javascript.