big maxsi → small maxsi

Sortix libz

This is Sortix libz. This is not zlib. This is a fork of zlib.

libz is a general purpose data compression library. The data format used by libz is described by RFC 1950 (zlib format), RFC 1951 (deflate format), and RFC 1952 (gzip format).

Sortix libz is developed as part of the Sortix operating system by Jonas 'Sortie' Termansen ( and contributors.

This libz has been cleaned up:

The result is a more secure and compact libz with focus on correctness, proper portability, auditability, simplification and opportunities to optimize.

libz is an ABI-compatible and API-compatible drop-in replacement for zlib 1.2.8 with a superior standard build system. libz is portable to Linux, the BSD systems, OS X, and even unknown operating systems assuming they behave like a standard Unix. Like zlib, libz does not contain vendor-specific patches and might not be a perfect replacement for your system libz (if it is patched).

The zlib.h API contains many design flaws that are unfixable. The result is that it is tricky to use the API correctly, especially for large files and buffers. Much application code using the zlib.h API is flawed and needs a serious audit.

A safer replacement API for is evolving.


This library is of course under the zlib license. See zlib.h for details.

The latest release is libz-

Older releases can be found in the release directory or the mirror.


libz is maintained in a git repository on gitlab.

Please check my work. I supply a script that can help you:

    # Ensure lists all the files that came from zlib. List
    # all the new files that are new and check them separately.
    sh ./ /path/to/zlib-1.2.8

This gives you a diff of my changes to the zlib release I diverged from. My original changes were deliberately done so this diff is reasonably readable without noise, but it's still big.


Please note the purpose of this fork is not to replace or discredit zlib. The zlib library was written in another age where robust coding practices were not as widespread and the common operating systems were often of low quality. The zlib library remains truly useful to many severely limited embedded platforms and other obscure platforms. As such, by popular demand it works on almost everything imaginable. This is fine.

The real issue is that it fits in poorly with modern operating systems, where we can do better with simpler, clearer and more robust coding practices, where we can assume the toolchains actually work and implement standard C. The coding style of zlib can be obscure and hard to audit. It doesn't take advantage of core standard library responsibilities such as fixed size integers and endian detection. It feels odd to compile a modern operating system from scratch and find such a poorly-integrated library at the core of the dependency graph.

This fork cleans up the official zlib to integrate it better with modern C environments. Not everyone has one of those and they can't use this fork. That's okay: They can use zlib instead. Relevant upstream work will be continuously merged, this is no big concern as zlib is largely in maintenance mode. It's unlikely that zlib will ever adopt the greater changes in this fork. Individual defects found while cleaning and auditing the code should be easily upstreamable though.


libz development is coordinated in #libz on freenode IRC.

Bugs can be filed at the issue tracker.

Jonas 'Sortie' Termansen can be contacted at

I am an operating systems developer and not a web developer. Appreciate the correctness and simplicity of this website.


zlib was written by Jean-loup Gailly (compression) and Mark Adler (decompression). libz is forked from zlib.

This page is best viewed in a browser compiled with a K&R compiler.

uch uchf ush usfh ulg
local z_const OF((subvert))
zlib standard c

old redundancy
noise kindle forking fire
code disappears

a libz forked
libz is not zlib
compressed zlib