]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
add doc on CCtx UB state
authorYann Collet <cyan@fb.com>
Mon, 18 Mar 2024 19:30:35 +0000 (12:30 -0700)
committerYann Collet <cyan@fb.com>
Mon, 18 Mar 2024 19:30:35 +0000 (12:30 -0700)
lib/zstd.h

index d27e593179ba311caf4604581cbaf87e1b91d4d5..b13e7e95998bc4ba1c8e728b67a85f4f8833f589 100644 (file)
@@ -791,6 +791,11 @@ typedef enum {
  *            only ZSTD_e_end or ZSTD_e_flush operations are allowed.
  *            Before starting a new compression job, or changing compression parameters,
  *            it is required to fully flush internal buffers.
+ *  - note: if an operation ends with an error, it may leave @cctx in an undefined state.
+ *          Therefore, it's UB to invoke ZSTD_compressStream2() of ZSTD_compressStream() on such a state.
+ *          In order to be re-employed after an error, a state must be reset,
+ *          which can be done explicitly (ZSTD_CCtx_reset()),
+ *          or is sometimes implied by methods starting a new compression job (ZSTD_initCStream(), ZSTD_compressCCtx())
  */
 ZSTDLIB_API size_t ZSTD_compressStream2( ZSTD_CCtx* cctx,
                                          ZSTD_outBuffer* output,
@@ -905,11 +910,11 @@ ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
  *           or an error code, which can be tested using ZSTD_isError(),
  *           or any other value > 0, which means there is some decoding or flushing to do to complete current frame.
  *
- * Note: when an operation returns with an error code, the @zds state if left in undefined state.
+ * Note: when an operation returns with an error code, the @zds state may be left in undefined state.
  *       It's UB to invoke `ZSTD_decompressStream()` on such a state.
- *       In order to re-use such a state, it must be reset first,
+ *       In order to re-use such a state, it must be first reset,
  *       which can be done explicitly (`ZSTD_DCtx_reset()`),
- *       or is sometimes implied (`ZSTD_initDStream`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`)
+ *       or is implied for operations starting some new decompression job (`ZSTD_initDStream`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`)
  */
 ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);