LZ4_compress_default(9)
π 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 isLZ4_MAX_INPUT_SIZEβ go past that and it's giving "no β€οΈ" πmaxOutputSizeβ the full or partial size of bufferdest. 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'ofLZ4_MEM_COMPRESS(yes, the page spells it'workmem'there andwrkmemin 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:
LZ4_compressBound(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_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)
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
- 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