LZ4_compress_destSize(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 character
  • dest β€” the output buffer address of the compressed data πŸŽ€ this is where the squished stuff lands
  • sourceSizePtr β€” 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 first
  • wrkmem β€” the address of the working memory 🧚 this requires 'workmem' of LZ4_MEM_COMPRESS (yes it's spelled 'workmem' there and wrkmem in 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