@@ -1604,9 +1604,6 @@ unsafe fn ZSTD_initCCtx(cctx: *mut ZSTD_CCtx, memManager: ZSTD_customMem) {
16041604}
16051605#[ cfg_attr( feature = "export-symbols" , export_name = crate :: prefix!( ZSTD_createCCtx_advanced ) ) ]
16061606pub unsafe extern "C" fn ZSTD_createCCtx_advanced ( customMem : ZSTD_customMem ) -> * mut ZSTD_CCtx {
1607- if customMem. customAlloc . is_none ( ) ^ customMem. customFree . is_none ( ) {
1608- return core:: ptr:: null_mut ( ) ;
1609- }
16101607 let cctx = ZSTD_customMalloc ( :: core:: mem:: size_of :: < ZSTD_CCtx > ( ) , customMem) as * mut ZSTD_CCtx ;
16111608 if cctx. is_null ( ) {
16121609 return core:: ptr:: null_mut ( ) ;
@@ -1950,11 +1947,7 @@ unsafe fn ZSTD_makeCCtxParamsFromCParams(cParams: ZSTD_compressionParameters) ->
19501947 cctxParams
19511948}
19521949unsafe fn ZSTD_createCCtxParams_advanced ( customMem : ZSTD_customMem ) -> * mut ZSTD_CCtx_params {
1953- let mut params = core:: ptr:: null_mut :: < ZSTD_CCtx_params > ( ) ;
1954- if customMem. customAlloc . is_none ( ) ^ customMem. customFree . is_none ( ) {
1955- return core:: ptr:: null_mut ( ) ;
1956- }
1957- params = ZSTD_customCalloc ( :: core:: mem:: size_of :: < ZSTD_CCtx_params > ( ) , customMem)
1950+ let params = ZSTD_customCalloc ( :: core:: mem:: size_of :: < ZSTD_CCtx_params > ( ) , customMem)
19581951 as * mut ZSTD_CCtx_params ;
19591952 if params. is_null ( ) {
19601953 return core:: ptr:: null_mut ( ) ;
@@ -8633,9 +8626,6 @@ unsafe fn ZSTD_createCDict_advanced_internal(
86338626 enableDedicatedDictSearch : core:: ffi:: c_int ,
86348627 customMem : ZSTD_customMem ,
86358628) -> * mut ZSTD_CDict {
8636- if customMem. customAlloc . is_none ( ) ^ customMem. customFree . is_none ( ) {
8637- return core:: ptr:: null_mut ( ) ;
8638- }
86398629 let workspaceSize = ( ZSTD_cwksp_alloc_size ( :: core:: mem:: size_of :: < ZSTD_CDict > ( ) ) )
86408630 . wrapping_add ( ZSTD_cwksp_alloc_size ( HUF_WORKSPACE_SIZE as size_t ) )
86418631 . wrapping_add ( ZSTD_sizeof_matchState (
@@ -8644,18 +8634,14 @@ unsafe fn ZSTD_createCDict_advanced_internal(
86448634 enableDedicatedDictSearch,
86458635 0 ,
86468636 ) )
8647- . wrapping_add (
8648- if dictLoadMethod as core:: ffi:: c_uint
8649- == ZSTD_dlm_byRef as core:: ffi:: c_int as core:: ffi:: c_uint
8650- {
8651- 0
8652- } else {
8653- ZSTD_cwksp_alloc_size ( ZSTD_cwksp_align (
8654- dictSize,
8655- :: core:: mem:: size_of :: < * mut core:: ffi:: c_void > ( ) ,
8656- ) )
8657- } ,
8658- ) ;
8637+ . wrapping_add ( if dictLoadMethod == ZSTD_dlm_byRef {
8638+ 0
8639+ } else {
8640+ ZSTD_cwksp_alloc_size ( ZSTD_cwksp_align (
8641+ dictSize,
8642+ :: core:: mem:: size_of :: < * mut core:: ffi:: c_void > ( ) ,
8643+ ) )
8644+ } ) ;
86598645 let workspace = ZSTD_customMalloc ( workspaceSize, customMem) ;
86608646 let mut ws = ZSTD_cwksp {
86618647 workspace : core:: ptr:: null_mut :: < core:: ffi:: c_void > ( ) ,
@@ -8670,13 +8656,12 @@ unsafe fn ZSTD_createCDict_advanced_internal(
86708656 phase : ZSTD_cwksp_alloc_objects ,
86718657 isStatic : ZSTD_cwksp_dynamic_alloc ,
86728658 } ;
8673- let mut cdict = core:: ptr:: null_mut :: < ZSTD_CDict > ( ) ;
86748659 if workspace. is_null ( ) {
86758660 ZSTD_customFree ( workspace, customMem) ;
86768661 return core:: ptr:: null_mut ( ) ;
86778662 }
86788663 ZSTD_cwksp_init ( & mut ws, workspace, workspaceSize, ZSTD_cwksp_dynamic_alloc ) ;
8679- cdict =
8664+ let cdict =
86808665 ZSTD_cwksp_reserve_object ( & mut ws, :: core:: mem:: size_of :: < ZSTD_CDict > ( ) ) as * mut ZSTD_CDict ;
86818666 ZSTD_cwksp_move ( & mut ( * cdict) . workspace , & mut ws) ;
86828667 ( * cdict) . customMem = customMem;
@@ -8781,9 +8766,6 @@ pub unsafe extern "C" fn ZSTD_createCDict_advanced2(
87818766 strategy : 0 ,
87828767 } ;
87838768 let mut cdict = core:: ptr:: null_mut :: < ZSTD_CDict > ( ) ;
8784- if customMem. customAlloc . is_none ( ) ^ customMem. customFree . is_none ( ) {
8785- return core:: ptr:: null_mut ( ) ;
8786- }
87878769 if cctxParams. enableDedicatedDictSearch != 0 {
87888770 cParams = ZSTD_dedicatedDictSearch_getCParams ( cctxParams. compressionLevel , dictSize) ;
87898771 ZSTD_overrideCParams ( & mut cParams, & cctxParams. cParams ) ;
0 commit comments