ZSTD_CStream typedef

ZSTD_CStream = ZSTD_CCtx

-*********************************************************************** Streaming compression - HowTo

A ZSTD_CStream object is required to track streaming operation. Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources. ZSTD_CStream objects can be reused multiple times on consecutive compression operations. It is recommended to reuse ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory.

For parallel execution, use one separate ZSTD_CStream per thread.

note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing.

Parameters are sticky : when starting a new compression on the same context, it will reuse the same sticky parameters as previous compression session. When in doubt, it's recommended to fully initialize the context before usage. Use ZSTD_CCtx_reset() to reset the context and ZSTD_CCtx_setParameter(), ZSTD_CCtx_setPledgedSrcSize(), or ZSTD_CCtx_loadDictionary() and friends to set more specific parameters, the pledged source size, or load a dictionary.

Use ZSTD_compressStream2() with ZSTD_e_continue as many times as necessary to consume input stream. The function will automatically update both pos fields within input and output. Note that the function may not consume the entire input, for example, because the output buffer is already full, in which case input.pos < input.size. The caller must check if input has been entirely consumed. If not, the caller must make some room to receive more compressed data, and then present again remaining input data. note: ZSTD_e_continue is guaranteed to make some forward progress when called, but doesn't guarantee maximal forward progress. This is especially relevant when compressing with multiple threads. The call won't block if it can consume some input, but if it can't it will wait for some, but not all, output to be flushed. @return : provides a minimum amount of data remaining to be flushed from internal buffers or an error code, which can be tested using ZSTD_isError().

At any moment, it's possible to flush whatever data might remain stuck within internal buffer, using ZSTD_compressStream2() with ZSTD_e_flush. output->pos will be updated. Note that, if output->size is too small, a single invocation with ZSTD_e_flush might not be enough (return code > 0). In which case, make some room to receive more compressed data, and call again ZSTD_compressStream2() with ZSTD_e_flush. You must continue calling ZSTD_compressStream2() with ZSTD_e_flush until it returns 0, at which point you can change the operation. note: ZSTD_e_flush will flush as much output as possible, meaning when compressing with multiple threads, it will block until the flush is complete or the output buffer is full. @return : 0 if internal buffers are entirely flushed,

0 if some data still present within internal buffer (the value is minimal estimation of remaining size), or an error code, which can be tested using ZSTD_isError().

Calling ZSTD_compressStream2() with ZSTD_e_end instructs to finish a frame. It will perform a flush and write frame epilogue. The epilogue is required for decoders to consider a frame completed. flush operation is the same, and follows same rules as calling ZSTD_compressStream2() with ZSTD_e_flush. You must continue calling ZSTD_compressStream2() with ZSTD_e_end until it returns 0, at which point you are free to start a new frame. note: ZSTD_e_end will flush as much output as possible, meaning when compressing with multiple threads, it will block until the flush is complete or the output buffer is full. @return : 0 if frame fully completed and fully flushed,

0 if some data still present within internal buffer (the value is minimal estimation of remaining size), or an error code, which can be tested using ZSTD_isError().

Implementation

typedef ZSTD_CStream = ZSTD_CCtx;