Skip to content

Commit c323559

Browse files
bjorn3folkertdev
authored andcommitted
Inline ZSTD_defaultCMem
1 parent bb79157 commit c323559

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

lib/common/pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::thread::JoinHandle;
55
use libc::size_t;
66

77
use crate::lib::common::allocations::{ZSTD_customCalloc, ZSTD_customFree};
8-
use crate::lib::zstd::{ZSTD_customMem, ZSTD_defaultCMem};
8+
use crate::lib::zstd::ZSTD_customMem;
99

1010
pub struct POOL_ctx {
1111
customMem: ZSTD_customMem,
@@ -66,7 +66,7 @@ pub unsafe extern "C" fn ZSTD_createThreadPool(numThreads: size_t) -> *mut ZSTD_
6666
POOL_create(numThreads, 0)
6767
}
6868
pub unsafe fn POOL_create(numThreads: size_t, queueSize: size_t) -> *mut POOL_ctx {
69-
POOL_create_advanced(numThreads, queueSize, ZSTD_defaultCMem)
69+
POOL_create_advanced(numThreads, queueSize, ZSTD_customMem::default())
7070
}
7171
pub(crate) unsafe fn POOL_create_advanced(
7272
numThreads: size_t,

lib/compress/zstd_compress.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ pub unsafe extern "C" fn ZSTD_compressBound(srcSize: size_t) -> size_t {
15941594
}
15951595
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_createCCtx))]
15961596
pub unsafe extern "C" fn ZSTD_createCCtx() -> *mut ZSTD_CCtx {
1597-
ZSTD_createCCtx_advanced(ZSTD_defaultCMem)
1597+
ZSTD_createCCtx_advanced(ZSTD_customMem::default())
15981598
}
15991599
unsafe fn ZSTD_initCCtx(cctx: *mut ZSTD_CCtx, memManager: ZSTD_customMem) {
16001600
ptr::write_bytes(cctx as *mut u8, 0, ::core::mem::size_of::<ZSTD_CCtx>());
@@ -1958,7 +1958,7 @@ unsafe fn ZSTD_createCCtxParams_advanced(customMem: ZSTD_customMem) -> *mut ZSTD
19581958
}
19591959
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_createCCtxParams))]
19601960
pub unsafe extern "C" fn ZSTD_createCCtxParams() -> *mut ZSTD_CCtx_params {
1961-
ZSTD_createCCtxParams_advanced(ZSTD_defaultCMem)
1961+
ZSTD_createCCtxParams_advanced(ZSTD_customMem::default())
19621962
}
19631963
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_freeCCtxParams))]
19641964
pub unsafe extern "C" fn ZSTD_freeCCtxParams(params: *mut ZSTD_CCtx_params) -> size_t {
@@ -5554,7 +5554,7 @@ pub unsafe extern "C" fn ZSTD_generateSequences(
55545554
if nbWorkers != 0 {
55555555
return Error::parameter_unsupported.to_error_code();
55565556
}
5557-
dst = ZSTD_customMalloc(dstCapacity, ZSTD_defaultCMem);
5557+
dst = ZSTD_customMalloc(dstCapacity, ZSTD_customMem::default());
55585558
if dst.is_null() {
55595559
return Error::memory_allocation.to_error_code();
55605560
}
@@ -5564,7 +5564,7 @@ pub unsafe extern "C" fn ZSTD_generateSequences(
55645564
seqCollector.maxSequences = outSeqsSize;
55655565
(*zc).seqCollector = seqCollector;
55665566
let ret = ZSTD_compress2(zc, dst, dstCapacity, src, srcSize);
5567-
ZSTD_customFree(dst, ZSTD_defaultCMem);
5567+
ZSTD_customFree(dst, ZSTD_customMem::default());
55685568
let err_code_1 = ret;
55695569
if ERR_isError(err_code_1) {
55705570
return err_code_1;
@@ -8487,7 +8487,7 @@ pub unsafe extern "C" fn ZSTD_compress(
84878487
extSeqBuf: core::ptr::null_mut::<ZSTD_Sequence>(),
84888488
extSeqBufCapacity: 0,
84898489
};
8490-
ZSTD_initCCtx(&mut ctxBody, ZSTD_defaultCMem);
8490+
ZSTD_initCCtx(&mut ctxBody, ZSTD_customMem::default());
84918491
result = ZSTD_compressCCtx(
84928492
&mut ctxBody,
84938493
dst,
@@ -8830,7 +8830,7 @@ pub unsafe extern "C" fn ZSTD_createCDict(
88308830
ZSTD_dlm_byCopy,
88318831
ZSTD_dct_auto,
88328832
cParams,
8833-
ZSTD_defaultCMem,
8833+
ZSTD_customMem::default(),
88348834
);
88358835
if !cdict.is_null() {
88368836
(*cdict).compressionLevel = if compressionLevel == 0 {
@@ -8859,7 +8859,7 @@ pub unsafe extern "C" fn ZSTD_createCDict_byReference(
88598859
ZSTD_dlm_byRef,
88608860
ZSTD_dct_auto,
88618861
cParams,
8862-
ZSTD_defaultCMem,
8862+
ZSTD_customMem::default(),
88638863
);
88648864
if !cdict.is_null() {
88658865
(*cdict).compressionLevel = if compressionLevel == 0 {
@@ -9225,7 +9225,7 @@ pub unsafe extern "C" fn ZSTD_compress_usingCDict(
92259225
}
92269226
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_createCStream))]
92279227
pub unsafe extern "C" fn ZSTD_createCStream() -> *mut ZSTD_CStream {
9228-
ZSTD_createCStream_advanced(ZSTD_defaultCMem)
9228+
ZSTD_createCStream_advanced(ZSTD_customMem::default())
92299229
}
92309230
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_initStaticCStream))]
92319231
pub unsafe extern "C" fn ZSTD_initStaticCStream(

lib/decompress/zstd_decompress.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ pub unsafe extern "C" fn ZSTD_createDCtx_advanced(customMem: ZSTD_customMem) ->
728728

729729
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_createDCtx))]
730730
pub unsafe extern "C" fn ZSTD_createDCtx() -> *mut ZSTD_DCtx {
731-
ZSTD_createDCtx_internal(ZSTD_defaultCMem)
731+
ZSTD_createDCtx_internal(ZSTD_customMem::default())
732732
}
733733

734734
unsafe fn ZSTD_clearDict(dctx: *mut ZSTD_DCtx) {
@@ -1790,7 +1790,7 @@ pub unsafe extern "C" fn ZSTD_decompress(
17901790
srcSize: size_t,
17911791
) -> size_t {
17921792
let mut regenSize: size_t = 0;
1793-
let dctx = ZSTD_createDCtx_internal(ZSTD_defaultCMem);
1793+
let dctx = ZSTD_createDCtx_internal(ZSTD_customMem::default());
17941794
if dctx.is_null() {
17951795
return Error::memory_allocation.to_error_code();
17961796
}
@@ -2318,7 +2318,7 @@ pub unsafe extern "C" fn ZSTD_decompress_usingDDict(
23182318

23192319
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_createDStream))]
23202320
pub unsafe extern "C" fn ZSTD_createDStream() -> *mut ZSTD_DStream {
2321-
ZSTD_createDCtx_internal(ZSTD_defaultCMem)
2321+
ZSTD_createDCtx_internal(ZSTD_customMem::default())
23222322
}
23232323
#[cfg_attr(feature = "export-symbols", export_name = crate::prefix!(ZSTD_initStaticDStream))]
23242324
pub unsafe extern "C" fn ZSTD_initStaticDStream(

lib/dictBuilder/zdict.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ unsafe fn ZDICT_analyzeEntropy(
986986
ZSTD_dlm_byRef,
987987
ZSTD_dct_rawContent,
988988
params.cParams,
989-
ZSTD_defaultCMem,
989+
ZSTD_customMem::default(),
990990
);
991991
esr.zc = ZSTD_createCCtx();
992992
esr.workPlace = malloc(ZSTD_BLOCKSIZE_MAX as size_t);

lib/zstd.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,6 @@ impl TryFrom<u32> for BufferMode {
184184
}
185185
}
186186

187-
pub static mut ZSTD_defaultCMem: ZSTD_customMem = ZSTD_customMem {
188-
customAlloc: None,
189-
customFree: None,
190-
opaque: core::ptr::null_mut(),
191-
};
192-
193187
#[derive(Copy, Clone)]
194188
#[repr(C)]
195189
pub struct ZSTD_frameProgression {

0 commit comments

Comments
 (0)