Skip to content

Commit d6d900b

Browse files
bjorn3folkertdev
authored andcommitted
Cleanup allocator checks
1 parent 02a7ee7 commit d6d900b

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

lib/compress/zstd_compress.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,10 +1604,7 @@ 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))]
16061606
pub unsafe extern "C" fn ZSTD_createCCtx_advanced(customMem: ZSTD_customMem) -> *mut ZSTD_CCtx {
1607-
if (customMem.customAlloc).is_none() as core::ffi::c_int
1608-
^ (customMem.customFree).is_none() as core::ffi::c_int
1609-
!= 0
1610-
{
1607+
if customMem.customAlloc.is_none() ^ customMem.customFree.is_none() {
16111608
return core::ptr::null_mut();
16121609
}
16131610
let cctx = ZSTD_customMalloc(::core::mem::size_of::<ZSTD_CCtx>(), customMem) as *mut ZSTD_CCtx;
@@ -1954,10 +1951,7 @@ unsafe fn ZSTD_makeCCtxParamsFromCParams(cParams: ZSTD_compressionParameters) ->
19541951
}
19551952
unsafe fn ZSTD_createCCtxParams_advanced(customMem: ZSTD_customMem) -> *mut ZSTD_CCtx_params {
19561953
let mut params = core::ptr::null_mut::<ZSTD_CCtx_params>();
1957-
if (customMem.customAlloc).is_none() as core::ffi::c_int
1958-
^ (customMem.customFree).is_none() as core::ffi::c_int
1959-
!= 0
1960-
{
1954+
if customMem.customAlloc.is_none() ^ customMem.customFree.is_none() {
19611955
return core::ptr::null_mut();
19621956
}
19631957
params = ZSTD_customCalloc(::core::mem::size_of::<ZSTD_CCtx_params>(), customMem)
@@ -8639,10 +8633,7 @@ unsafe fn ZSTD_createCDict_advanced_internal(
86398633
enableDedicatedDictSearch: core::ffi::c_int,
86408634
customMem: ZSTD_customMem,
86418635
) -> *mut ZSTD_CDict {
8642-
if (customMem.customAlloc).is_none() as core::ffi::c_int
8643-
^ (customMem.customFree).is_none() as core::ffi::c_int
8644-
!= 0
8645-
{
8636+
if customMem.customAlloc.is_none() ^ customMem.customFree.is_none() {
86468637
return core::ptr::null_mut();
86478638
}
86488639
let workspaceSize = (ZSTD_cwksp_alloc_size(::core::mem::size_of::<ZSTD_CDict>()))
@@ -8790,10 +8781,7 @@ pub unsafe extern "C" fn ZSTD_createCDict_advanced2(
87908781
strategy: 0,
87918782
};
87928783
let mut cdict = core::ptr::null_mut::<ZSTD_CDict>();
8793-
if (customMem.customAlloc).is_none() as core::ffi::c_int
8794-
^ (customMem.customFree).is_none() as core::ffi::c_int
8795-
!= 0
8796-
{
8784+
if customMem.customAlloc.is_none() ^ customMem.customFree.is_none() {
87978785
return core::ptr::null_mut();
87988786
}
87998787
if cctxParams.enableDedicatedDictSearch != 0 {

lib/compress/zstdmt_compress.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,10 +1151,7 @@ unsafe fn ZSTDMT_createCCtx_advanced_internal(
11511151
256
11521152
}) as core::ffi::c_uint
11531153
};
1154-
if (cMem.customAlloc).is_some() as core::ffi::c_int
1155-
^ (cMem.customFree).is_some() as core::ffi::c_int
1156-
!= 0
1157-
{
1154+
if cMem.customAlloc.is_some() ^ cMem.customFree.is_some() {
11581155
return core::ptr::null_mut();
11591156
}
11601157
mtctx = ZSTD_customCalloc(::core::mem::size_of::<ZSTDMT_CCtx>(), cMem) as *mut ZSTDMT_CCtx;

lib/decompress/zstd_decompress.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ pub unsafe extern "C" fn ZSTD_initStaticDCtx(
711711
}
712712

713713
unsafe fn ZSTD_createDCtx_internal(customMem: ZSTD_customMem) -> *mut ZSTD_DCtx {
714-
if (customMem.customAlloc).is_none() ^ (customMem.customFree).is_none() {
714+
if customMem.customAlloc.is_none() ^ customMem.customFree.is_none() {
715715
return core::ptr::null_mut();
716716
}
717717

0 commit comments

Comments
 (0)