LZ4_compress_destSize(9)
π LZ4_compress_destSize(9) π
okay so bestie, welcome to the Kernel API Manual β¨ today we're talking about LZ4_compress_destSize(9) β yes that's the whole title, no we're not scared of it, and yes it's giving "compression but make it backwards" energy π¦
π NAME π
LZ4_compress_destSize β compress as much data as possible from source to dest π
literally the "fill the cup till it overflows" of compression functions fr fr
β¨ SYNOPSIS β¨
int LZ4_compress_destSize (const char *source , char *dest , int
*sourceSizePtr , int targetDestSize , void *wrkmem );
that's the whole signature, copy it exactly, don't be cute with the spacing π the compiler does not care about your aesthetic
πΈ ARGUMENTS πΈ
sourceβ the source address of the original data π this is the stuff you're squishing, the raw material, the main characterdestβ the output buffer address of the compressed data π this is where the squished stuff landssourceSizePtrβ bestie this one gets modified π it's changed to indicate how many bytes were read from'source'to fill'dest'. and listen β the new value is necessarily<=the old value. no cap. it can only shrink or stay the same, never grow πtargetDestSizeβ the size of buffer'dest', which must already be allocated β οΈ you cannot skip this step, you cannot manifest the buffer into existence, allocate it firstwrkmemβ the address of the working memory π§ this requires'workmem'ofLZ4_MEM_COMPRESS(yes it's spelled'workmem'there andwrkmemin the signature β that's just how it is, we love a little inconsistency, it's iconic)
π₯ DESCRIPTION π₯
okay so the whole vibe here is: reverse the logic π« instead of "here's my data, give me enough room for it," you're saying "here's my room, give me as much data as fits."
So basically β compress as much data as possible from the 'source' buffer into the already allocated buffer 'dest' of size 'targetDestSize' π
and it does one of two things, periodt:
- if
'dest'is large enough, it compresses the entire'source'content into'dest'β - otherwise, it fills the
'dest'buffer completely with as much data as possible from'source'π«Ά
either way, dest is getting fed. it's a greedy little buffer and we respect it.
β RETURN β
it returns the number of bytes written into 'dest' β which is necessarily <= targetDestSize π β or 0 if compression fails π
so if you get 0 back, that's your vibe check failing. compression did not slay. handle it.
π SEE ALSO π
Kernel file ./include/linux/lz4.h β go read it, iykyk π and then the whole LZ4 extended family, all of them, no skipping, they're all icons:
LZ4_compressBound(9), LZ4_compress_default(9), LZ4_compress_fast(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_compress_HC_continue(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)
and that's the page, bestie π«Άβ¨ brought to you from ./include/linux, dated October 2026, under the ever-watchful gaze of LZ4_compress_destSize(9) π go compress responsibly, allocate your buffers, and remember: the new value is necessarily <= the old value ππ
π¦ 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