Library:Libdeflate
Appearance
| Developer | Eric Biggers |
|---|---|
| Versions | 1.26 in the current repository (LIBDEFLATE_VERSION_STRING) |
| License | MIT |
| Website | https://github.com/ebiggers/libdeflate |
| On this wiki | Facts · Code · Notes · Topics |
Eric Biggers' fast whole-buffer DEFLATE, zlib and gzip compressor and decompressor (C, MIT): no streaming API, libdeflate_* function names, no copyright banner or version string in the library code, and its own table-driven decoder (precode/litlen/offset decode_results) instead of zlib's inftrees tables.
Overview
libdeflate compresses and decompresses whole buffers (libdeflate_deflate_compress, libdeflate_zlib_compress, libdeflate_gzip_compress and the matching *_decompress, *_decompress_ex, libdeflate_adler32, libdeflate_crc32) with compression levels 0-12. It is also wrapped by bindings for other languages. Output is standard DEFLATE (Format:DEFLATE), readable by Library:Zlib and everything else.
Identification
- Names: exported or debug-visible functions
libdeflate_alloc_compressor,libdeflate_alloc_decompressor,libdeflate_free_compressor,libdeflate_free_decompressor,libdeflate_set_memory_allocator(libdeflate.h). The headers defineLIBDEFLATE_VERSION_STRING("1.26" at the pinned commit), but the library code never returns it at run time; only the command-line programs print it, so a stripped library has no version string. - Compressor tables (
lib/deflate_compress.clines 237-268):deflate_length_slot_base[](3,4,5,...,258 as 32-bit),deflate_extra_length_bits[](28 bytes, ending 5,5,5,5,0),deflate_offset_slot_base[](1,...,24577) anddeflate_extra_offset_bits[](0,0,0,0,1,1,...,13,13; 30 entries): no padding entries like zlib's 31/32-entry tables, which separates it from zlib, miniz and zlib-ng. - Decompressor tables: three u32 arrays
precode_decode_results,litlen_decode_results(the 256 literal entries first, eachHUFFDEC_LITERAL | literal << 16) andoffset_decode_resultsinlib/deflate_decompress.c(lines 407, 504, 617).deflate_precode_lens_permutationis the standard 16,17,18,0,8,7,9,...;bitreverse_tab[256]appears in the compressor. - CRC-32:
crc32_slice1_table(starts 0x00000000 0x77073096 0xEE0E612C 0x990951BA, the zlib table) and a largercrc32_slice8_table(lib/crc32_tables.h); on x86 and ARM, carry-less multiply constants incrc32_multipliers.hreplace them. Adler-32 is the usual 65521 modulus. - Behaviour: decompress calls return
enum libdeflate_result(0 success, 1 bad data, 2 short output, 3 insufficient space); there is noinflate()state machine, so there is noz_stream.
Code & repositories
- https://github.com/ebiggers/libdeflate @
92e6a0db9fa848d742f9eb286c92afc60f2c3dda· license: MIT
libdeflate source: lib/ has the DEFLATE compressor and decompressor, zlib and gzip wrappers, CRC-32 and Adler-32; NEWS.md lists the versions.
Tested on: source read, not run: source read at the pinned commit; nothing built or run · checked 2026-10-18; last activity 2026-08-22; Note: the latest release ships binaries; the wiki links only the source, never the binaries
Pitfalls
- A stripped statically linked libdeflate is told from zlib by the missing
lextpattern and the unpadded compressor tables. Source check at commit 92e6a0db9fa848d742f9eb286c92afc60f2c3dda: neitherlib/deflate_decompress.cnorlib/deflate_compress.ccontains anylext,lbaseordextarray (a text search finds none), while zlib and zlib-ng keep them ininftrees.c(Library:Zlib-ng#Identification). This is a statement about the source; no compiled binary was inspected.
Evidence & references
- ebiggers/libdeflate commit 92e6a0db9fa848d742f9eb286c92afc60f2c3dda:
libdeflate.h,lib/deflate_compress.c,lib/deflate_decompress.c,lib/crc32_tables.h. Read only.