LZ4_compress_HC_continue(9)
π LZ4_compress_HC_continue(9) β the kernel API manual, but make it make sense π
okay bestie, so this is a section 9 kernel API page (that's the (9) β kernel-land, not your regular user commands, iykyk). Buckle up, this one's actually iconic once it clicks. π¦
β¨ NAME β¨
LZ4_compress_HC_continue β compresses src using data from previously compressed blocks as a dictionary, and it does it with the HC algorithm (that's High Compression, the fancy one π
).
πΈ SYNOPSIS πΈ
int LZ4_compress_HC_continue (LZ4_streamHC_t *streamHCPtr , const char
*src , char *dst , int srcSize , int maxDstSize );
literally the whole vibe in one line, no cap.
π ARGUMENTS π
streamHCPtrβ a pointer to the previousLZ4_streamHC_tstructure. this is your little state baby, it remembers stuff between blocks π«Άsrcβ the source address of the original data. the raw material, the moment before compression β¨dstβ the output buffer address for the compressed data, and heads up: it must be already allocated. you can't just hand over a vibe and hope π«srcSizeβ the size of the input data. the max supported value isLZ4_MAX_INPUT_SIZE, so don't go overboard πmaxDstSizeβ the full or partial size of bufferdest, which must already be allocated too. (yes, the manpage saysdesthere while the param isdstβ i did not write this, i am merely the messenger π)
π§ DESCRIPTION π§
okay so the way this works: these functions compress data in successive blocks of any size, using previous blocks as a dictionary. it's giving "build on what came before" main character energy. π
one key assumption tho β previous blocks (up to 64 KB) remain read-accessible while you're compressing the next blocks. that's the whole deal, bestie.
there is an exception for ring buffers, which can be smaller than 64 KB. π« the ring buffers scenario is automatically detected and handled by LZ4_compress_HC_continue, so you don't gotta do a thing. slay.
before you even start compressing, the state must be properly initialized, using LZ4_resetStreamHC. then a first "fictional block" can be designated as the initial dictionary, using LZ4_loadDictHC (this part is Optional β no pressure π).
then, use LZ4_compress_HC_continue to compress each successive block. and this is the important bit: previous memory blocks (including the initial dictionary when present) must remain accessible and unmodified during compression. don't be out here editing your own history, it will not eat π
LZ4_compressBound, to ensure operation success. π₯ (yes that's how the original rolls, we keeping it)
now β if, for any reason, previous data blocks can't be preserved unmodified in memory during the next compression block, you must save it to a safer memory space, using LZ4_saveDictHC. the return value of LZ4_saveDictHC is the size of the dictionary effectively saved into 'safeBuffer'. note that: effectively saved. it's not a promise, it's a receipt π§Ύβ¨
β RETURN β
the number of bytes written into buffer 'dst' β or 0 if compression fails. that's it. zero means sad times, positive number means we ate π
π¦ SEE ALSO π¦
the kernel file ./include/linux/lz4.h, plus the whole extended lz4 family reunion:
LZ4_compressBound(9)LZ4_compress_default(9)LZ4_compress_fast(9)LZ4_compress_destSize(9)LZ4_decompress_fast(9)LZ4_decompress_safe(9)LZ4_decompress_safe_partial(9)LZ4_compress_HC(9)LZ4_resetStreamHC(9)LZ4_loadDictHC(9)LZ4_saveDictHC(9)LZ4_resetStream(9)LZ4_loadDict(9)LZ4_saveDict(9)LZ4_compress_fast_continue(9)LZ4_setStreamDecode(9)LZ4_decompress_safe_continue(9)LZ4_decompress_fast_continue(9)LZ4_decompress_safe_usingDict(9)LZ4_decompress_fast_usingDict(9)
like, the entire friend group. go read them too, they're all valid π
π and that's the page!! source lives in ./include/linux, version stamped October 2026, and it's filed under Kernel API Manual β so if you ever need to cite your sources, that's where she lives. mwah, go compress something responsibly, bestie π«ΆπΈ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms