zstd_init_cstream(9)
π zstd_init_cstream(9) β from the Kernel API Manual, bestie
okay so picture this: you're in kernel land, you wanna compress stuff as a stream (not all at once, like a whole vibe unfolding), and you need to set up the little context that makes it happen. that's this function. it's giving "start of something beautiful" β¨
πΈ NAME πΈ
zstd_init_cstream β initialize a zstd streaming compression context
and the manpage also says, literally, @parameters The zstd parameters to use for compression. β like yes bestie we know, thank you π
β¨ SYNOPSIS β¨
zstd_cstream * zstd_init_cstream (const zstd_parameters *parameters ,
unsigned long long pledged_src_size , void *workspace , size_t
workspace_size );
four things in, one streaming context out. no cap. π«Ά
π ARGUMENTS π
parametersβ the original page just says-- undescribed --π so like... that's all we got. it's the zstd params, obviously, but the manpage left this one blank, and I'm not about to make stuff up. iconic laziness tbh.pledged_src_sizeβ okay this one's important, listen up π. Ifparams.fParams.contentSizeFlag == 1then you must pass the source size (and zero means the source is empty β not "unknown", empty, bestie, there's a difference π). Otherwise, when that flag isn't set, you may optionally pass the source size, or just pass zero if you don't know it. your call, main character energy.workspaceβ the memory you're emplacing the context into. it must outlive the returned context β like, don't free this bad boy early or the whole thing falls apart π that's a hard requirement, not a suggestion.workspace_sizeβ how bigworkspaceis. π Usezstd_cstream_workspace_bound(params->cparams)to figure out how large the workspace has to be. don't guess, just call the bound function, she'll tell you.
π₯ RETURN π₯
The zstd streaming compression context, or NULL on error. that's it. that's the whole return. if you get NULL, something went sideways β check your sizes, bestie π«Ά
π¦ SEE ALSO π¦
so there's a whole zstd family reunion down here, and honestly? every single one of them is invited π the kernel file for all this is ./include/linux/zstd.h.
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_reset_cstream(9)zstd_compress_stream(9)zstd_flush_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 I said. family reunion. everyone showed up π
lowkey the biggest takeaway: the workspace has to outlive the context, and the workspace size comes from zstd_cstream_workspace_bound(params->cparams). those two are the ones that'll bite you. everything else is chill π
and that's the page bestie!! this one's from ./include/linux, dated October 2026 β mwah, slay, go compress some streams π
ππ§ π
π¦ 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