@@ -36,9 +36,11 @@ public static nuint ZSTD_compressBound(nuint srcSize)
3636 private static void ZSTD_initCCtx ( ZSTD_CCtx_s * cctx , ZSTD_customMem memManager )
3737 {
3838 assert ( cctx != null ) ;
39- memset ( cctx , 0 , ( uint ) sizeof ( ZSTD_CCtx_s ) ) ;
40- cctx ->customMem = memManager ;
41- cctx ->bmi2 = 0 ;
39+ * cctx = new ZSTD_CCtx_s
40+ {
41+ customMem = memManager ,
42+ bmi2 = 0
43+ } ;
4244 {
4345 nuint err = ZSTD_CCtx_reset ( cctx , ZSTD_ResetDirective . ZSTD_reset_parameters ) ;
4446 assert ( ! ERR_isError ( err ) ) ;
@@ -91,7 +93,7 @@ private static void ZSTD_initCCtx(ZSTD_CCtx_s* cctx, ZSTD_customMem memManager)
9193 cctx = ( ZSTD_CCtx_s * ) ZSTD_cwksp_reserve_object ( & ws , ( nuint ) sizeof ( ZSTD_CCtx_s ) ) ;
9294 if ( cctx == null )
9395 return null ;
94- memset ( cctx , 0 , ( uint ) sizeof ( ZSTD_CCtx_s ) ) ;
96+ * cctx = new ZSTD_CCtx_s ( ) ;
9597 ZSTD_cwksp_move ( & cctx ->workspace , & ws ) ;
9698 cctx ->staticSize = workspaceSize ;
9799 if ( ZSTD_cwksp_check_available ( & cctx ->workspace , ( nuint ) ( ( 8 << 10 ) + 512 + sizeof ( uint ) * ( 52 + 2 ) + 2 * sizeof ( ZSTD_compressedBlockState_t ) ) ) == 0 )
@@ -110,8 +112,8 @@ private static void ZSTD_clearAllDicts(ZSTD_CCtx_s* cctx)
110112 {
111113 ZSTD_customFree ( cctx ->localDict . dictBuffer , cctx ->customMem ) ;
112114 ZSTD_freeCDict ( cctx ->localDict . cdict ) ;
113- memset ( & cctx ->localDict , 0 , ( uint ) sizeof ( ZSTD_localDict ) ) ;
114- memset ( & cctx ->prefixDict , 0 , ( uint ) sizeof ( ZSTD_prefixDict_s ) ) ;
115+ cctx ->localDict = new ZSTD_localDict ( ) ;
116+ cctx ->prefixDict = new ZSTD_prefixDict_s ( ) ;
115117 cctx ->cdict = null ;
116118 }
117119
@@ -370,8 +372,10 @@ public static nuint ZSTD_CCtxParams_init(ZSTD_CCtx_params_s* cctxParams, int com
370372 return unchecked ( ( nuint ) ( - ( int ) ZSTD_ErrorCode . ZSTD_error_GENERIC ) ) ;
371373 }
372374
373- memset ( cctxParams , 0 , ( uint ) sizeof ( ZSTD_CCtx_params_s ) ) ;
374- cctxParams ->compressionLevel = compressionLevel ;
375+ * cctxParams = new ZSTD_CCtx_params_s
376+ {
377+ compressionLevel = compressionLevel
378+ } ;
375379 cctxParams ->fParams . contentSizeFlag = 1 ;
376380 return 0 ;
377381 }
@@ -383,12 +387,14 @@ public static nuint ZSTD_CCtxParams_init(ZSTD_CCtx_params_s* cctxParams, int com
383387 private static void ZSTD_CCtxParams_init_internal ( ZSTD_CCtx_params_s * cctxParams , ZSTD_parameters * @params , int compressionLevel )
384388 {
385389 assert ( ZSTD_checkCParams ( @params ->cParams ) == 0 ) ;
386- memset ( cctxParams , 0 , ( uint ) sizeof ( ZSTD_CCtx_params_s ) ) ;
387- cctxParams ->cParams = @params ->cParams ;
388- cctxParams ->fParams = @params ->fParams ;
389- cctxParams ->compressionLevel = compressionLevel ;
390- cctxParams ->useRowMatchFinder = ZSTD_resolveRowMatchFinderMode ( cctxParams ->useRowMatchFinder , & @params ->cParams ) ;
391- cctxParams ->useBlockSplitter = ZSTD_resolveBlockSplitterMode ( cctxParams ->useBlockSplitter , & @params ->cParams ) ;
390+ * cctxParams = new ZSTD_CCtx_params_s
391+ {
392+ cParams = @params ->cParams ,
393+ fParams = @params ->fParams ,
394+ compressionLevel = compressionLevel ,
395+ useRowMatchFinder = ZSTD_resolveRowMatchFinderMode ( cctxParams ->useRowMatchFinder , & @params ->cParams ) ,
396+ useBlockSplitter = ZSTD_resolveBlockSplitterMode ( cctxParams ->useBlockSplitter , & @params ->cParams )
397+ } ;
392398 cctxParams ->ldmParams . enableLdm = ZSTD_resolveEnableLdm ( cctxParams ->ldmParams . enableLdm , & @params ->cParams ) ;
393399 cctxParams ->validateSequences = ZSTD_resolveExternalSequenceValidation ( cctxParams ->validateSequences ) ;
394400 cctxParams ->maxBlockSize = ZSTD_resolveMaxBlockSize ( cctxParams ->maxBlockSize ) ;
@@ -3234,7 +3240,7 @@ private static nuint ZSTD_postProcessSequenceProducerResult(ZSTD_Sequence* outSe
32343240
32353241 if ( srcSize == 0 )
32363242 {
3237- memset ( & outSeqs [ 0 ] , 0 , ( uint ) sizeof ( ZSTD_Sequence ) ) ;
3243+ outSeqs [ 0 ] = new ZSTD_Sequence ( ) ;
32383244 return 1 ;
32393245 }
32403246
@@ -3250,7 +3256,7 @@ private static nuint ZSTD_postProcessSequenceProducerResult(ZSTD_Sequence* outSe
32503256 return unchecked ( ( nuint ) ( - ( int ) ZSTD_ErrorCode . ZSTD_error_sequenceProducer_failed ) ) ;
32513257 }
32523258
3253- memset ( & outSeqs [ nbExternalSeqs ] , 0 , ( uint ) sizeof ( ZSTD_Sequence ) ) ;
3259+ outSeqs [ nbExternalSeqs ] = new ZSTD_Sequence ( ) ;
32543260 return nbExternalSeqs + 1 ;
32553261 }
32563262 }
@@ -4322,7 +4328,7 @@ private static nuint ZSTD_compressBlock_splitBlock_internal(ZSTD_CCtx_s* zc, voi
43224328 repcodes_s cRep ;
43234329 memcpy ( dRep . rep , zc ->blockState . prevCBlock ->rep , ( uint ) sizeof ( repcodes_s ) ) ;
43244330 memcpy ( cRep . rep , zc ->blockState . prevCBlock ->rep , ( uint ) sizeof ( repcodes_s ) ) ;
4325- memset ( nextSeqStore , 0 , ( uint ) sizeof ( seqStore_t ) ) ;
4331+ * nextSeqStore = new seqStore_t ( ) ;
43264332 if ( numSplits == 0 )
43274333 {
43284334 nuint cSizeSingleBlock = ZSTD_compressSeqStore_singleBlock ( zc , & zc ->seqStore , & dRep , & cRep , op , dstCapacity , ip , blockSize , lastBlock , 0 ) ;
@@ -5677,7 +5683,7 @@ private static nuint ZSTD_initCDict_internal(ZSTD_CDict_s* cdict, void* dictBuff
56775683 public static ZSTD_CDict_s * ZSTD_createCDict_advanced ( void * dictBuffer , nuint dictSize , ZSTD_dictLoadMethod_e dictLoadMethod , ZSTD_dictContentType_e dictContentType , ZSTD_compressionParameters cParams , ZSTD_customMem customMem )
56785684 {
56795685 ZSTD_CCtx_params_s cctxParams;
5680- memset ( & cctxParams , 0 , ( uint ) sizeof ( ZSTD_CCtx_params_s ) ) ;
5686+ cctxParams = new ZSTD_CCtx_params_s ( ) ;
56815687 ZSTD_CCtxParams_init ( & cctxParams , 0 ) ;
56825688 cctxParams . cParams = cParams ;
56835689 cctxParams . customMem = customMem ;
@@ -6618,7 +6624,7 @@ private static nuint ZSTD_CCtx_init_compressStream2(ZSTD_CCtx_s* cctx, ZSTD_EndD
66186624 }
66196625 }
66206626
6621- memset ( & cctx->prefixDict, 0 , ( uint ) sizeof ( ZSTD_prefixDict_s ) ) ;
6627+ cctx->prefixDict = new ZSTD_prefixDict_s( ) ;
66226628 assert( prefixDict. dict == null || cctx->cdict == null ) ;
66236629 if ( cctx->cdict != null && cctx->localDict. cdict == null )
66246630 {
@@ -7715,8 +7721,10 @@ private static ZSTD_parameters ZSTD_getParams_internal(int compressionLevel, ulo
77157721 {
77167722 ZSTD_parameters @params;
77177723 ZSTD_compressionParameters cParams = ZSTD_getCParams_internal( compressionLevel, srcSizeHint, dictSize, mode) ;
7718- memset( & @params, 0 , ( uint ) sizeof ( ZSTD_parameters) ) ;
7719- @params. cParams = cParams;
7724+ @params = new ZSTD_parameters
7725+ {
7726+ cParams = cParams
7727+ } ;
77207728 @params. fParams. contentSizeFlag = 1 ;
77217729 return @params;
77227730 }
0 commit comments