zstd_init_cstream(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 πŸ‘‘. If params.fParams.contentSizeFlag == 1 then 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 big workspace is. πŸŽ€ Use zstd_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.

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