zstd_flush_stream(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… zstd_flush_stream(9) β€” from the Kernel API Manual ✨

okay bestie, so we're in the kernel docs, section 9, and today's main character is zstd_flush_stream. she's a lil function with a big job and honestly? she ate. let's get into it πŸŽ€


✨ NAME ✨

zstd_flush_stream β€” flush internal buffers into output πŸ’–

Like, literally what it says on the tin. the internal buffers? they're getting emptied. into the output. periodt.


🌸 SYNOPSIS 🌸

size_t zstd_flush_stream (zstd_cstream *cstream , zstd_out_buffer
*output );

no cap, that's the signature. keep it exactly like that, the compiler is not as forgiving as your group chat 😭


πŸ¦‹ ARGUMENTS πŸ¦‹

  • cstream β€” the zstd streaming compression context. she's the whole vibe, your state, your everything πŸ’…
  • output β€” the destination buffer. and here's the important bit, output->pos gets updated to indicate how much compressed data was written. so like, don't go reading pos before you call it, that's giving chaos 🌈

πŸ‘‘ DESCRIPTION πŸ‘‘

okay so zstd_flush_stream must be called until it returns 0, because that's the signal meaning all the data has been flushed. like, fully drained. zero means we're done, bestie ✨

but here's the tea β˜• β€” zstd_flush_stream causes a block to be ended. so if you're calling it too often? that will degrade the compression ratio. ngl, it's giving "using a firehose to water one plant" πŸ’€ be chill about it.

🫢 real talk: keep calling it until you get 0, but don't spam it for no reason. two different rules, both matter. iykyk.

πŸ“ RETURN πŸ“

it returns the number of bytes still present within internal buffers, or an error πŸ”₯

and how do you know if it's an error? you can check it using zstd_is_error. that's the vibe check function, use it πŸ™ˆ


πŸ’œ SEE ALSO πŸ’œ

the kernel file ./include/linux/zstd.h and, like, the entire extended friend group:

like, the whole squad. go read them, they're iconic too πŸ’…βœ¨


and that's the page, bestie 🧚 source lives in ./include/linux, dated October 2026, and the page itself is zstd_flush_stream(9) β€” mwah, love that for us πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from