Decompresses data into a new buffer. max_output bounds the result (a compressed bomb fails
instead of exhausting memory). A GZIP stream is a single member; bytes after the stream are
ignored. On failure the output is empty and error says why.
since 0.28.0
#import "Extensions/Deflate";
The DEFLATE compressed format (RFC 1951) with its zlib (RFC 1950) and gzip (RFC 1952) wrappers, in plain Jai. A jaic extension, not official Jai. See docs/extensions/deflate.md.
#import "Extensions/Deflate";
bytes := cast([] u8) "hello hello hello hello";
packed := deflate(bytes, .GZIP);
unpacked, ok, error := inflate(packed, .GZIP);Show moreShow less
Results are allocated with context.allocator and owned by the caller. Errors are static strings.
Procedures#
Like inflate, into a buffer the caller sized. Fails with "output is too small" when the
stream expands past output; nothing is written beyond it.
Compresses data. level runs from 0 (stored blocks only) to 9 (smallest); 6 is the usual
balance. Out-of-range levels are clamped.
CRC-32 (the checksum of gzip and PNG). To continue over more data, pass the previous result.
Types#
Constants#
A gzip member is at least this long: 10 bytes of header and 8 of trailer.
DEFLATE cannot expand a byte past 1032 bytes of output.
inflate refuses to produce more than this many bytes unless told otherwise.