zstd_flush_stream(9)
π 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->posgets updated to indicate how much compressed data was written. so like, don't go readingposbefore 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:
zstd_compress_bound(9)zstd_is_error(9)zstd_get_error_code(9)zstd_get_error_name(9)zstd_min_clevel(9)zstd_max_clevel(9)zstd_default_clevel(9)zstd_get_params(9)zstd_get_cparams(9)zstd_cctx_set_param(9)zstd_cctx_workspace_bound(9)zstd_cctx_workspace_bound_with_ext_seq_prod(9)zstd_init_cctx(9)zstd_compress_cctx(9)zstd_create_cctx_advanced(9)zstd_free_cctx(9)zstd_create_cdict_byreference(9)zstd_free_cdict(9)zstd_compress_using_cdict(9)zstd_dctx_workspace_bound(9)zstd_init_dctx(9)zstd_decompress_dctx(9)zstd_create_ddict_byreference(9)zstd_free_ddict(9)zstd_create_dctx_advanced(9)zstd_free_dctx(9)zstd_decompress_using_ddict(9)zstd_cstream_workspace_bound(9)zstd_cstream_workspace_bound_with_ext_seq_prod(9)zstd_init_cstream(9)zstd_reset_cstream(9)zstd_compress_stream(9)zstd_end_stream(9)zstd_dstream_workspace_bound(9)zstd_init_dstream(9)zstd_reset_dstream(9)zstd_decompress_stream(9)zstd_find_frame_compressed_size(9)zstd_get_frame_header(9)zstd_compress_sequences_and_literals(9)
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
- 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