@@ -1270,6 +1270,7 @@ public static nuint ZSTD_CCtx_setParametersUsingCCtxParams(ZSTD_CCtx_s* cctx, ZS
12701270 public static nuint ZSTD_CCtx_setCParams ( ZSTD_CCtx_s * cctx , ZSTD_compressionParameters cparams )
12711271 {
12721272 {
1273+ /* only update if all parameters are valid */
12731274 nuint err_code = ZSTD_checkCParams ( cparams ) ;
12741275 if ( ERR_isError ( err_code ) )
12751276 {
@@ -1376,6 +1377,7 @@ public static nuint ZSTD_CCtx_setFParams(ZSTD_CCtx_s* cctx, ZSTD_frameParameters
13761377 public static nuint ZSTD_CCtx_setParams ( ZSTD_CCtx_s * cctx , ZSTD_parameters @params )
13771378 {
13781379 {
1380+ /* First check cParams, because we want to update all or none. */
13791381 nuint err_code = ZSTD_checkCParams ( @params . cParams ) ;
13801382 if ( ERR_isError ( err_code ) )
13811383 {
@@ -1384,6 +1386,7 @@ public static nuint ZSTD_CCtx_setParams(ZSTD_CCtx_s* cctx, ZSTD_parameters @para
13841386 }
13851387
13861388 {
1389+ /* Next set fParams, because this could fail if the cctx isn't in init stage. */
13871390 nuint err_code = ZSTD_CCtx_setFParams ( cctx , @params . fParams ) ;
13881391 if ( ERR_isError ( err_code ) )
13891392 {
@@ -1392,6 +1395,7 @@ public static nuint ZSTD_CCtx_setParams(ZSTD_CCtx_s* cctx, ZSTD_parameters @para
13921395 }
13931396
13941397 {
1398+ /* Finally set cParams, which should succeed. */
13951399 nuint err_code = ZSTD_CCtx_setCParams ( cctx , @params . cParams ) ;
13961400 if ( ERR_isError ( err_code ) )
13971401 {
@@ -3347,6 +3351,7 @@ private static nuint ZSTD_buildSeqStore(ZSTD_CCtx_s* zc, void* src, nuint srcSiz
33473351 ldmSeqStore . seq = zc ->ldmSequences ;
33483352 ldmSeqStore . capacity = zc ->maxNbLdmSequences ;
33493353 {
3354+ /* Updates ldmSeqStore.size */
33503355 nuint err_code = ZSTD_ldm_generateSequences ( & zc ->ldmState , & ldmSeqStore , & zc ->appliedParams . ldmParams , src , srcSize ) ;
33513356 if ( ERR_isError ( err_code ) )
33523357 {
@@ -5343,6 +5348,7 @@ private static nuint ZSTD_compressBegin_internal(ZSTD_CCtx_s* cctx, void* dict,
53435348 private static nuint ZSTD_compressBegin_advanced_internal( ZSTD_CCtx_s * cctx , void * dict , nuint dictSize , ZSTD_dictContentType_e dictContentType , ZSTD_dictTableLoadMethod_e dtlm , ZSTD_CDict_s * cdict , ZSTD_CCtx_params_s * @params , ulong pledgedSrcSize )
53445349 {
53455350 {
5351+ /* compression parameters verification and optimization */
53465352 nuint err_code = ZSTD_checkCParams( @params ->cParams ) ;
53475353 if ( ERR_isError( err_code) )
53485354 {
@@ -5908,6 +5914,7 @@ public static nuint ZSTD_compressBegin_usingCDict(ZSTD_CCtx_s* cctx, ZSTD_CDict_
59085914 private static nuint ZSTD_compress_usingCDict_internal ( ZSTD_CCtx_s * cctx , void * dst , nuint dstCapacity , void * src , nuint srcSize , ZSTD_CDict_s * cdict , ZSTD_frameParameters fParams )
59095915 {
59105916 {
5917+ /* will check if cdict != NULL */
59115918 nuint err_code = ZSTD_compressBegin_usingCDict_internal ( cctx , cdict , fParams , srcSize ) ;
59125919 if ( ERR_isError ( err_code ) )
59135920 {
@@ -6048,6 +6055,7 @@ private static nuint ZSTD_initCStream_internal(ZSTD_CCtx_s* zcs, void* dict, nui
60486055 }
60496056 else
60506057 {
6058+ /* Dictionary is cleared if !cdict */
60516059 nuint err_code = ZSTD_CCtx_refCDict( zcs, cdict ) ;
60526060 if ( ERR_isError ( err_code ) )
60536061 {
@@ -6617,6 +6625,7 @@ private static nuint ZSTD_CCtx_init_compressStream2(ZSTD_CCtx_s* cctx, ZSTD_EndD
66176625 ZSTD_CCtx_params_s @params = cctx ->requestedParams ;
66186626 ZSTD_prefixDict_s prefixDict = cctx ->prefixDict ;
66196627 {
6628+ /* Init the local dict if present. */
66206629 nuint err_code = ZSTD_initLocalDict ( cctx ) ;
66216630 if ( ERR_isError( err_code) )
66226631 {
@@ -6771,6 +6780,7 @@ public static nuint ZSTD_compressStream2(ZSTD_CCtx_s* cctx, ZSTD_outBuffer_s* ou
67716780 }
67726781
67736782 {
6783+ /* end of transparent initialization stage */
67746784 nuint err_code = ZSTD_checkBufferStability ( cctx , output , input , endOp ) ;
67756785 if ( ERR_isError ( err_code ) )
67766786 {
0 commit comments