LZ4_compress_default(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ LZ4_compress_default(9) β€” like, the Kernel API Manual page, bestie

okay so picture this: you're in the kernel, your data is way too chunky, and this little icon is here to squeeze it down. welcome to LZ4_compress_default(9). it's glorious, it's fast, and it's lowkey the main character of the LZ4 lineup ✨


🌸 NAME 🌸

LZ4_compress_default β€” compress data from source to dest. that's it, that's the vibe πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

int LZ4_compress_default (const char *source , char *dest , int
inputSize , int maxOutputSize , void *wrkmem );

yeah. five arguments. don't panic, we're gonna go through each one together 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • source β€” the source address of the original data. i.e. the raw, un-smooshed stuff you're trying to shrink πŸ’–
  • dest β€” output buffer address of the compressed data. this is where the glow-up lands ✨
  • inputSize β€” size of the input data. max supported value is LZ4_MAX_INPUT_SIZE β€” go past that and it's giving "no ❀️" 😭
  • maxOutputSize β€” the full or partial size of buffer dest. be so fr when you set this, because the buffer must be already allocated β€” no take-backs, no auto-growing πŸ™ˆ
  • wrkmem β€” address of the working memory. this one requires 'workmem' of LZ4_MEM_COMPRESS (yes, the page spells it 'workmem' there and wrkmem in the parameter β€” she contains multitudes 🌈). think of it as the little backstage area where the compression gets ready 😌

πŸ”₯ DESCRIPTION πŸ”₯

so here's the tea: it compresses 'sourceSize' bytes from buffer 'source' into the already-allocated 'dest' buffer of size 'maxOutputSize'. πŸ’«

and here's a line straight from the page, word for word, because she's iconic and also a little bit of a sentence-fragment queen: Compression is guaranteed to succeed if It also runs faster, so it's a recommended setting. like, yes ma'am, we love a confident queen πŸ’… (that's literally how it's written β€” not me, blame the source 🫢)

now the dramatic part: if the function cannot compress 'source' into a more limited 'dest' budget, compression stops *immediately*, and the function result is zero. periodt. πŸ’€

and as a consequence β€” this matters, bestie β€” 'dest' content is not valid in that case. do not go reading it, do not go trusting it, do not go passing it to your friends. it is not the moment. πŸ™…β€β™€οΈ

⭐ RETURN ⭐

it hands you back the number of bytes written into buffer 'dest' β€” necessarily <= maxOutputSize, so it never overstays its welcome β€” or 0 if compression fails. zero means "we don't have the budget for this, conversation over" 😭


🌈 SEE ALSO 🌈

the kernel file: ./include/linux/lz4.h β€” that's the mothership πŸ‘‘

and the whole extended friend group:

twenty of them. i counted. go read them, iykyk πŸ“šπŸ’–


and that's the whole page, bestie 🧚 from ./include/linux, dated October 2026, sitting pretty at version LZ4_compress_default(9). slay, bye πŸŽ€πŸ’œ

πŸ“¦ where this page comes from