Skip to content

Commit 15e17fc

Browse files
committed
[docs] Clarify dictionary loading documentation
Reinforce that loading a new dictionary clears the current dictionary. Except for the multiple-ddict mode.
1 parent ef566c8 commit 15e17fc

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/zstd.h

+10-8
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,9 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
990990
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
991991
* Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary,
992992
* meaning "return to no-dictionary mode".
993-
* Note 1 : Dictionary is sticky, it will be used for all future compressed frames.
994-
* To return to "no-dictionary" situation, load a NULL dictionary (or reset parameters).
993+
* Note 1 : Dictionary is sticky, it will be used for all future compressed frames,
994+
* until parameters are reset, a new dictionary is loaded, or the dictionary
995+
* is explicitly invalidated by loading a NULL dictionary.
995996
* Note 2 : Loading a dictionary involves building tables.
996997
* It's also a CPU consuming operation, with non-negligible impact on latency.
997998
* Tables are dependent on compression parameters, and for this reason,
@@ -1004,7 +1005,7 @@ ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
10041005
ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
10051006

10061007
/*! ZSTD_CCtx_refCDict() : Requires v1.4.0+
1007-
* Reference a prepared dictionary, to be used for all next compressed frames.
1008+
* Reference a prepared dictionary, to be used for all future compressed frames.
10081009
* Note that compression parameters are enforced from within CDict,
10091010
* and supersede any compression parameter previously set within CCtx.
10101011
* The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs.
@@ -1039,9 +1040,9 @@ ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
10391040
const void* prefix, size_t prefixSize);
10401041

10411042
/*! ZSTD_DCtx_loadDictionary() : Requires v1.4.0+
1042-
* Create an internal DDict from dict buffer,
1043-
* to be used to decompress next frames.
1044-
* The dictionary remains valid for all future frames, until explicitly invalidated.
1043+
* Create an internal DDict from dict buffer, to be used to decompress al future frames.
1044+
* The dictionary remains valid for all future frames, until explicitly invalidated, or
1045+
* a new dictionary is loaded.
10451046
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
10461047
* Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary,
10471048
* meaning "return to no-dictionary mode".
@@ -1065,9 +1066,10 @@ ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, s
10651066
* The memory for the table is allocated on the first call to refDDict, and can be
10661067
* freed with ZSTD_freeDCtx().
10671068
*
1069+
* If called with ZSTD_d_refMultipleDDicts disabled (the default), only one dictionary
1070+
* will be managed, and referencing a dictionary effectively "discards" any previous one.
1071+
*
10681072
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
1069-
* Note 1 : Currently, only one dictionary can be managed.
1070-
* Referencing a new dictionary effectively "discards" any previous one.
10711073
* Special: referencing a NULL DDict means "return to no-dictionary mode".
10721074
* Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx.
10731075
*/

0 commit comments

Comments
 (0)