feat(compress): move CDict metadata copies into Rust
Pass CCtx destination fields and CDict source fields through the attach and copy bridges, then copy dictID and dictContentSize in Rust at the original metadata-copy point. Remove the redundant C metadata callbacks while keeping reset error handling, attach ordering, and block-state copy ordering intact. Add focused tests for metadata values and callback sequencing. Test Plan: - ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml - ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040 && make -j1 - ulimit -v 41943040 && make -j1 -C tests test-zstream ZSTREAM_TESTTIME=-T2s - ulimit -v 41943040 && make -j1 -C tests test-fuzzer FUZZERTEST=-T3s FUZZER_FLAGS=--no-big-tests - ulimit -v 41943040 && cargo fmt --manifest-path rust/Cargo.toml -- --check - git diff --check
This commit is contained in:
@@ -2497,7 +2497,10 @@ typedef struct {
|
||||
ZSTD_rust_resetCCtxByCopyingCDictState_f zeroHashTable3;
|
||||
ZSTD_rust_resetCCtxByCopyingCDictMarkTables_f markTablesClean;
|
||||
ZSTD_rust_resetCCtxByCopyingCDictState_f copyMatchState;
|
||||
ZSTD_rust_resetCCtxByCopyingCDictState_f copyDictState;
|
||||
U32* destinationDictID;
|
||||
const U32* sourceDictID;
|
||||
size_t* destinationDictContentSize;
|
||||
const size_t* sourceDictContentSize;
|
||||
ZSTD_compressedBlockState_t** destinationBlockState;
|
||||
const ZSTD_compressedBlockState_t* sourceBlockState;
|
||||
int zbuff;
|
||||
@@ -2515,7 +2518,7 @@ typedef char ZSTD_rust_reset_cctx_by_copying_cdict_state_layout[
|
||||
&& offsetof(ZSTD_rust_resetCCtxByCopyingCDictState, reset)
|
||||
== 3 * sizeof(void*) + sizeof(U64)
|
||||
&& offsetof(ZSTD_rust_resetCCtxByCopyingCDictState, zbuff)
|
||||
== 3 * sizeof(void*) + sizeof(U64) + 9 * sizeof(void*)
|
||||
== 3 * sizeof(void*) + sizeof(U64) + 12 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_resetCCtxByCopyingCDictState)
|
||||
== ((offsetof(ZSTD_rust_resetCCtxByCopyingCDictState, zbuff)
|
||||
+ sizeof(int) + sizeof(void*) - 1) / sizeof(void*))
|
||||
@@ -2526,8 +2529,6 @@ typedef size_t (*ZSTD_rust_resetCCtxByAttachingCDictReset_f)(
|
||||
U64 pledgedSrcSize, int zbuff);
|
||||
typedef void (*ZSTD_rust_resetCCtxByAttachingCDictAttach_f)(
|
||||
void* context, const void* cdict);
|
||||
typedef void (*ZSTD_rust_resetCCtxByAttachingCDictState_f)(
|
||||
void* context, const void* cdict);
|
||||
typedef struct {
|
||||
void* callbackContext;
|
||||
const void* cdict;
|
||||
@@ -2535,7 +2536,10 @@ typedef struct {
|
||||
U64 pledgedSrcSize;
|
||||
ZSTD_rust_resetCCtxByAttachingCDictReset_f reset;
|
||||
ZSTD_rust_resetCCtxByAttachingCDictAttach_f attach;
|
||||
ZSTD_rust_resetCCtxByAttachingCDictState_f copyDictState;
|
||||
U32* destinationDictID;
|
||||
const U32* sourceDictID;
|
||||
size_t* destinationDictContentSize;
|
||||
const size_t* sourceDictContentSize;
|
||||
ZSTD_compressedBlockState_t** destinationBlockState;
|
||||
const ZSTD_compressedBlockState_t* sourceBlockState;
|
||||
int zbuff;
|
||||
@@ -2553,7 +2557,7 @@ typedef char ZSTD_rust_reset_cctx_by_attaching_cdict_state_layout[
|
||||
&& offsetof(ZSTD_rust_resetCCtxByAttachingCDictState, reset)
|
||||
== 3 * sizeof(void*) + sizeof(U64)
|
||||
&& offsetof(ZSTD_rust_resetCCtxByAttachingCDictState, zbuff)
|
||||
== 3 * sizeof(void*) + sizeof(U64) + 5 * sizeof(void*)
|
||||
== 3 * sizeof(void*) + sizeof(U64) + 8 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_resetCCtxByAttachingCDictState)
|
||||
== ((offsetof(ZSTD_rust_resetCCtxByAttachingCDictState, zbuff)
|
||||
+ sizeof(int) + sizeof(void*) - 1) / sizeof(void*))
|
||||
@@ -4512,15 +4516,6 @@ static void ZSTD_rust_resetCCtx_byAttachingCDict_attach(
|
||||
cctx->blockState.matchState.window.dictLimit;
|
||||
}
|
||||
|
||||
static void ZSTD_rust_resetCCtx_byAttachingCDict_copy_dict_state(
|
||||
void* context, const void* cdictOpaque)
|
||||
{
|
||||
ZSTD_CCtx* const cctx = (ZSTD_CCtx*)context;
|
||||
const ZSTD_CDict* const cdict = (const ZSTD_CDict*)cdictOpaque;
|
||||
cctx->dictID = cdict->dictID;
|
||||
cctx->dictContentSize = cdict->dictContentSize;
|
||||
}
|
||||
|
||||
static size_t
|
||||
ZSTD_resetCCtx_byAttachingCDict(ZSTD_CCtx* cctx,
|
||||
const ZSTD_CDict* cdict,
|
||||
@@ -4535,7 +4530,10 @@ ZSTD_resetCCtx_byAttachingCDict(ZSTD_CCtx* cctx,
|
||||
state.pledgedSrcSize = pledgedSrcSize;
|
||||
state.reset = ZSTD_rust_resetCCtx_byAttachingCDict_reset;
|
||||
state.attach = ZSTD_rust_resetCCtx_byAttachingCDict_attach;
|
||||
state.copyDictState = ZSTD_rust_resetCCtx_byAttachingCDict_copy_dict_state;
|
||||
state.destinationDictID = &cctx->dictID;
|
||||
state.sourceDictID = &cdict->dictID;
|
||||
state.destinationDictContentSize = &cctx->dictContentSize;
|
||||
state.sourceDictContentSize = &cdict->dictContentSize;
|
||||
state.destinationBlockState = &cctx->blockState.prevCBlock;
|
||||
state.sourceBlockState = &cdict->cBlockState;
|
||||
state.zbuff = (int)zbuff;
|
||||
@@ -4653,15 +4651,6 @@ static void ZSTD_rust_resetCCtx_byCopyingCDict_copy_match_state(
|
||||
dst->loadedDictEnd = src->loadedDictEnd;
|
||||
}
|
||||
|
||||
static void ZSTD_rust_resetCCtx_byCopyingCDict_copy_dict_state(
|
||||
void* context, const void* cdictOpaque)
|
||||
{
|
||||
ZSTD_CCtx* const cctx = (ZSTD_CCtx*)context;
|
||||
const ZSTD_CDict* const cdict = (const ZSTD_CDict*)cdictOpaque;
|
||||
cctx->dictID = cdict->dictID;
|
||||
cctx->dictContentSize = cdict->dictContentSize;
|
||||
}
|
||||
|
||||
static size_t ZSTD_resetCCtx_byCopyingCDict(ZSTD_CCtx* cctx,
|
||||
const ZSTD_CDict* cdict,
|
||||
ZSTD_CCtx_params params,
|
||||
@@ -4683,8 +4672,10 @@ static size_t ZSTD_resetCCtx_byCopyingCDict(ZSTD_CCtx* cctx,
|
||||
ZSTD_rust_resetCCtx_byCopyingCDict_mark_tables_clean;
|
||||
state.copyMatchState =
|
||||
ZSTD_rust_resetCCtx_byCopyingCDict_copy_match_state;
|
||||
state.copyDictState =
|
||||
ZSTD_rust_resetCCtx_byCopyingCDict_copy_dict_state;
|
||||
state.destinationDictID = &cctx->dictID;
|
||||
state.sourceDictID = &cdict->dictID;
|
||||
state.destinationDictContentSize = &cctx->dictContentSize;
|
||||
state.sourceDictContentSize = &cdict->dictContentSize;
|
||||
state.destinationBlockState = &cctx->blockState.prevCBlock;
|
||||
state.sourceBlockState = &cdict->cBlockState;
|
||||
state.zbuff = (int)zbuff;
|
||||
|
||||
@@ -1321,7 +1321,10 @@ pub struct ZSTD_rust_resetCCtxByCopyingCDictState {
|
||||
zero_hash_table3: Option<ResetCCtxByCopyingCDictStateFn>,
|
||||
mark_tables_clean: Option<ResetCCtxByCopyingCDictMarkTablesFn>,
|
||||
copy_match_state: Option<ResetCCtxByCopyingCDictStateFn>,
|
||||
copy_dict_state: Option<ResetCCtxByCopyingCDictStateFn>,
|
||||
destination_dict_id: *mut c_uint,
|
||||
source_dict_id: *const c_uint,
|
||||
destination_dict_content_size: *mut usize,
|
||||
source_dict_content_size: *const usize,
|
||||
destination_block_state: *mut *mut ZSTD_compressedBlockState_t,
|
||||
source_block_state: *const ZSTD_compressedBlockState_t,
|
||||
zbuff: c_int,
|
||||
@@ -1344,7 +1347,7 @@ const _: () = {
|
||||
);
|
||||
assert!(
|
||||
offset_of!(ZSTD_rust_resetCCtxByCopyingCDictState, zbuff)
|
||||
== 3 * size_of::<usize>() + size_of::<u64>() + size_of::<[usize; 9]>()
|
||||
== 3 * size_of::<usize>() + size_of::<u64>() + size_of::<[usize; 12]>()
|
||||
);
|
||||
assert!(
|
||||
size_of::<ZSTD_rust_resetCCtxByCopyingCDictState>()
|
||||
@@ -1371,7 +1374,6 @@ pub unsafe extern "C" fn ZSTD_rust_resetCCtxByCopyingCDict(
|
||||
Some(zero_hash_table3),
|
||||
Some(mark_tables_clean),
|
||||
Some(copy_match_state),
|
||||
Some(copy_dict_state),
|
||||
) = (
|
||||
state.reset,
|
||||
state.mark_tables_dirty,
|
||||
@@ -1379,7 +1381,6 @@ pub unsafe extern "C" fn ZSTD_rust_resetCCtxByCopyingCDict(
|
||||
state.zero_hash_table3,
|
||||
state.mark_tables_clean,
|
||||
state.copy_match_state,
|
||||
state.copy_dict_state,
|
||||
)
|
||||
else {
|
||||
return ERROR(ZstdErrorCode::Generic);
|
||||
@@ -1387,6 +1388,10 @@ pub unsafe extern "C" fn ZSTD_rust_resetCCtxByCopyingCDict(
|
||||
if state.callback_context.is_null()
|
||||
|| state.cdict.is_null()
|
||||
|| state.params.is_null()
|
||||
|| state.destination_dict_id.is_null()
|
||||
|| state.source_dict_id.is_null()
|
||||
|| state.destination_dict_content_size.is_null()
|
||||
|| state.source_dict_content_size.is_null()
|
||||
|| state.destination_block_state.is_null()
|
||||
|| state.source_block_state.is_null()
|
||||
{
|
||||
@@ -1409,7 +1414,8 @@ pub unsafe extern "C" fn ZSTD_rust_resetCCtxByCopyingCDict(
|
||||
zero_hash_table3(state.callback_context, state.cdict);
|
||||
mark_tables_clean(state.callback_context);
|
||||
copy_match_state(state.callback_context, state.cdict);
|
||||
copy_dict_state(state.callback_context, state.cdict);
|
||||
*state.destination_dict_id = *state.source_dict_id;
|
||||
*state.destination_dict_content_size = *state.source_dict_content_size;
|
||||
let destination_block_state = *state.destination_block_state;
|
||||
if destination_block_state.is_null() {
|
||||
return ERROR(ZstdErrorCode::Generic);
|
||||
@@ -1422,7 +1428,6 @@ pub unsafe extern "C" fn ZSTD_rust_resetCCtxByCopyingCDict(
|
||||
type ResetCCtxByAttachingCDictResetFn =
|
||||
unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void, u64, c_int) -> usize;
|
||||
type ResetCCtxByAttachingCDictAttachFn = unsafe extern "C" fn(*mut c_void, *const c_void);
|
||||
type ResetCCtxByAttachingCDictStateFn = unsafe extern "C" fn(*mut c_void, *const c_void);
|
||||
|
||||
/// Projection for attaching a prepared CDict to a working CCtx.
|
||||
///
|
||||
@@ -1436,7 +1441,10 @@ pub struct ZSTD_rust_resetCCtxByAttachingCDictState {
|
||||
pledged_src_size: u64,
|
||||
reset: Option<ResetCCtxByAttachingCDictResetFn>,
|
||||
attach: Option<ResetCCtxByAttachingCDictAttachFn>,
|
||||
copy_dict_state: Option<ResetCCtxByAttachingCDictStateFn>,
|
||||
destination_dict_id: *mut c_uint,
|
||||
source_dict_id: *const c_uint,
|
||||
destination_dict_content_size: *mut usize,
|
||||
source_dict_content_size: *const usize,
|
||||
destination_block_state: *mut *mut ZSTD_compressedBlockState_t,
|
||||
source_block_state: *const ZSTD_compressedBlockState_t,
|
||||
zbuff: c_int,
|
||||
@@ -1445,7 +1453,6 @@ pub struct ZSTD_rust_resetCCtxByAttachingCDictState {
|
||||
const _: () = {
|
||||
assert!(size_of::<ResetCCtxByAttachingCDictResetFn>() == size_of::<usize>());
|
||||
assert!(size_of::<ResetCCtxByAttachingCDictAttachFn>() == size_of::<usize>());
|
||||
assert!(size_of::<ResetCCtxByAttachingCDictStateFn>() == size_of::<usize>());
|
||||
assert!(offset_of!(ZSTD_rust_resetCCtxByAttachingCDictState, callback_context) == 0);
|
||||
assert!(offset_of!(ZSTD_rust_resetCCtxByAttachingCDictState, cdict) == size_of::<usize>());
|
||||
assert!(offset_of!(ZSTD_rust_resetCCtxByAttachingCDictState, params) == 2 * size_of::<usize>());
|
||||
@@ -1459,7 +1466,7 @@ const _: () = {
|
||||
);
|
||||
assert!(
|
||||
offset_of!(ZSTD_rust_resetCCtxByAttachingCDictState, zbuff)
|
||||
== 3 * size_of::<usize>() + size_of::<u64>() + size_of::<[usize; 5]>()
|
||||
== 3 * size_of::<usize>() + size_of::<u64>() + size_of::<[usize; 8]>()
|
||||
);
|
||||
assert!(
|
||||
size_of::<ZSTD_rust_resetCCtxByAttachingCDictState>()
|
||||
@@ -1479,14 +1486,16 @@ pub unsafe extern "C" fn ZSTD_rust_resetCCtxByAttachingCDict(
|
||||
return ERROR(ZstdErrorCode::Generic);
|
||||
}
|
||||
let state = unsafe { &*state };
|
||||
let (Some(reset), Some(attach), Some(copy_dict_state)) =
|
||||
(state.reset, state.attach, state.copy_dict_state)
|
||||
else {
|
||||
let (Some(reset), Some(attach)) = (state.reset, state.attach) else {
|
||||
return ERROR(ZstdErrorCode::Generic);
|
||||
};
|
||||
if state.callback_context.is_null()
|
||||
|| state.cdict.is_null()
|
||||
|| state.params.is_null()
|
||||
|| state.destination_dict_id.is_null()
|
||||
|| state.source_dict_id.is_null()
|
||||
|| state.destination_dict_content_size.is_null()
|
||||
|| state.source_dict_content_size.is_null()
|
||||
|| state.destination_block_state.is_null()
|
||||
|| state.source_block_state.is_null()
|
||||
{
|
||||
@@ -1505,7 +1514,8 @@ pub unsafe extern "C" fn ZSTD_rust_resetCCtxByAttachingCDict(
|
||||
return reset_error;
|
||||
}
|
||||
attach(state.callback_context, state.cdict);
|
||||
copy_dict_state(state.callback_context, state.cdict);
|
||||
*state.destination_dict_id = *state.source_dict_id;
|
||||
*state.destination_dict_content_size = *state.source_dict_content_size;
|
||||
let destination_block_state = *state.destination_block_state;
|
||||
if destination_block_state.is_null() {
|
||||
return ERROR(ZstdErrorCode::Generic);
|
||||
@@ -2775,19 +2785,14 @@ mod tests {
|
||||
.push("match");
|
||||
}
|
||||
|
||||
unsafe extern "C" fn reset_cctx_by_copying_cdict_copy_dict_state(
|
||||
context: *mut c_void,
|
||||
_cdict: *const c_void,
|
||||
) {
|
||||
unsafe { reset_cctx_by_copying_cdict_probe(context) }
|
||||
.events
|
||||
.push("dict");
|
||||
}
|
||||
|
||||
fn reset_cctx_by_copying_cdict_test_state(
|
||||
probe: &mut ResetCCtxByCopyingCDictProbe,
|
||||
cdict: *const c_void,
|
||||
params: *const c_void,
|
||||
destination_dict_id: *mut c_uint,
|
||||
source_dict_id: *const c_uint,
|
||||
destination_dict_content_size: *mut usize,
|
||||
source_dict_content_size: *const usize,
|
||||
destination_block_state: *mut *mut ZSTD_compressedBlockState_t,
|
||||
source_block_state: *const ZSTD_compressedBlockState_t,
|
||||
) -> ZSTD_rust_resetCCtxByCopyingCDictState {
|
||||
@@ -2802,7 +2807,10 @@ mod tests {
|
||||
zero_hash_table3: Some(reset_cctx_by_copying_cdict_zero_hash_table3),
|
||||
mark_tables_clean: Some(reset_cctx_by_copying_cdict_mark_clean),
|
||||
copy_match_state: Some(reset_cctx_by_copying_cdict_copy_match_state),
|
||||
copy_dict_state: Some(reset_cctx_by_copying_cdict_copy_dict_state),
|
||||
destination_dict_id,
|
||||
source_dict_id,
|
||||
destination_dict_content_size,
|
||||
source_dict_content_size,
|
||||
destination_block_state,
|
||||
source_block_state,
|
||||
zbuff: 7,
|
||||
@@ -2819,6 +2827,10 @@ mod tests {
|
||||
source_block_state.rep = [9, 10, 11];
|
||||
source_block_state.entropy.huf.repeatMode = HUF_REPEAT_VALID;
|
||||
source_block_state.entropy.fse.offcode_repeatMode = FSE_REPEAT_VALID;
|
||||
let source_dict_id = 0x1234_5678;
|
||||
let mut destination_dict_id = 0;
|
||||
let source_dict_content_size = 9876;
|
||||
let mut destination_dict_content_size = 0;
|
||||
let mut destination_block_state =
|
||||
unsafe { std::mem::MaybeUninit::<ZSTD_compressedBlockState_t>::zeroed().assume_init() };
|
||||
let mut destination_block_state_slot =
|
||||
@@ -2827,6 +2839,10 @@ mod tests {
|
||||
&mut probe,
|
||||
cdict,
|
||||
params,
|
||||
&mut destination_dict_id,
|
||||
&source_dict_id,
|
||||
&mut destination_dict_content_size,
|
||||
&source_dict_content_size,
|
||||
&mut destination_block_state_slot,
|
||||
&source_block_state,
|
||||
);
|
||||
@@ -2836,12 +2852,14 @@ mod tests {
|
||||
assert_eq!(result, 0);
|
||||
assert_eq!(
|
||||
probe.events,
|
||||
["reset", "dirty", "tables", "zero-h3", "clean", "match", "dict"]
|
||||
["reset", "dirty", "tables", "zero-h3", "clean", "match"]
|
||||
);
|
||||
assert_eq!(probe.cdict, cdict);
|
||||
assert_eq!(probe.params, params);
|
||||
assert_eq!(probe.pledged_src_size, 123);
|
||||
assert_eq!(probe.zbuff, 7);
|
||||
assert_eq!(destination_dict_id, source_dict_id);
|
||||
assert_eq!(destination_dict_content_size, source_dict_content_size);
|
||||
assert_eq!(destination_block_state.rep, source_block_state.rep);
|
||||
assert_eq!(
|
||||
destination_block_state.entropy.huf.repeatMode,
|
||||
@@ -2865,10 +2883,18 @@ mod tests {
|
||||
&mut destination_block_state as *mut ZSTD_compressedBlockState_t;
|
||||
let source_block_state =
|
||||
unsafe { std::mem::MaybeUninit::<ZSTD_compressedBlockState_t>::zeroed().assume_init() };
|
||||
let source_dict_id = 0x1234_5678;
|
||||
let mut destination_dict_id = 0;
|
||||
let source_dict_content_size = 9876;
|
||||
let mut destination_dict_content_size = 0;
|
||||
let state = reset_cctx_by_copying_cdict_test_state(
|
||||
&mut probe,
|
||||
0x4000usize as *const c_void,
|
||||
0x3000usize as *const c_void,
|
||||
&mut destination_dict_id,
|
||||
&source_dict_id,
|
||||
&mut destination_dict_content_size,
|
||||
&source_dict_content_size,
|
||||
&mut destination_block_state_slot,
|
||||
&source_block_state,
|
||||
);
|
||||
@@ -2920,19 +2946,14 @@ mod tests {
|
||||
.push("attach");
|
||||
}
|
||||
|
||||
unsafe extern "C" fn reset_cctx_by_attaching_cdict_copy_dict_state(
|
||||
context: *mut c_void,
|
||||
_cdict: *const c_void,
|
||||
) {
|
||||
unsafe { reset_cctx_by_attaching_cdict_probe(context) }
|
||||
.events
|
||||
.push("dict");
|
||||
}
|
||||
|
||||
fn reset_cctx_by_attaching_cdict_test_state(
|
||||
probe: &mut ResetCCtxByAttachingCDictProbe,
|
||||
cdict: *const c_void,
|
||||
params: *const c_void,
|
||||
destination_dict_id: *mut c_uint,
|
||||
source_dict_id: *const c_uint,
|
||||
destination_dict_content_size: *mut usize,
|
||||
source_dict_content_size: *const usize,
|
||||
destination_block_state: *mut *mut ZSTD_compressedBlockState_t,
|
||||
source_block_state: *const ZSTD_compressedBlockState_t,
|
||||
) -> ZSTD_rust_resetCCtxByAttachingCDictState {
|
||||
@@ -2943,7 +2964,10 @@ mod tests {
|
||||
pledged_src_size: 123,
|
||||
reset: Some(reset_cctx_by_attaching_cdict_reset),
|
||||
attach: Some(reset_cctx_by_attaching_cdict_attach),
|
||||
copy_dict_state: Some(reset_cctx_by_attaching_cdict_copy_dict_state),
|
||||
destination_dict_id,
|
||||
source_dict_id,
|
||||
destination_dict_content_size,
|
||||
source_dict_content_size,
|
||||
destination_block_state,
|
||||
source_block_state,
|
||||
zbuff: 7,
|
||||
@@ -2959,6 +2983,10 @@ mod tests {
|
||||
unsafe { std::mem::MaybeUninit::<ZSTD_compressedBlockState_t>::zeroed().assume_init() };
|
||||
source_block_state.rep = [12, 13, 14];
|
||||
source_block_state.entropy.huf.repeatMode = HUF_REPEAT_VALID;
|
||||
let source_dict_id = 0x8765_4321;
|
||||
let mut destination_dict_id = 0;
|
||||
let source_dict_content_size = 5432;
|
||||
let mut destination_dict_content_size = 0;
|
||||
let mut destination_block_state =
|
||||
unsafe { std::mem::MaybeUninit::<ZSTD_compressedBlockState_t>::zeroed().assume_init() };
|
||||
let mut destination_block_state_slot =
|
||||
@@ -2967,6 +2995,10 @@ mod tests {
|
||||
&mut probe,
|
||||
cdict,
|
||||
params,
|
||||
&mut destination_dict_id,
|
||||
&source_dict_id,
|
||||
&mut destination_dict_content_size,
|
||||
&source_dict_content_size,
|
||||
&mut destination_block_state_slot,
|
||||
&source_block_state,
|
||||
);
|
||||
@@ -2974,11 +3006,13 @@ mod tests {
|
||||
let result = unsafe { ZSTD_rust_resetCCtxByAttachingCDict(&state) };
|
||||
|
||||
assert_eq!(result, 0);
|
||||
assert_eq!(probe.events, ["reset", "attach", "dict"]);
|
||||
assert_eq!(probe.events, ["reset", "attach"]);
|
||||
assert_eq!(probe.cdict, cdict);
|
||||
assert_eq!(probe.params, params);
|
||||
assert_eq!(probe.pledged_src_size, 123);
|
||||
assert_eq!(probe.zbuff, 7);
|
||||
assert_eq!(destination_dict_id, source_dict_id);
|
||||
assert_eq!(destination_dict_content_size, source_dict_content_size);
|
||||
assert_eq!(destination_block_state.rep, source_block_state.rep);
|
||||
assert_eq!(
|
||||
destination_block_state.entropy.huf.repeatMode,
|
||||
@@ -2998,10 +3032,18 @@ mod tests {
|
||||
&mut destination_block_state as *mut ZSTD_compressedBlockState_t;
|
||||
let source_block_state =
|
||||
unsafe { std::mem::MaybeUninit::<ZSTD_compressedBlockState_t>::zeroed().assume_init() };
|
||||
let source_dict_id = 0x8765_4321;
|
||||
let mut destination_dict_id = 0;
|
||||
let source_dict_content_size = 5432;
|
||||
let mut destination_dict_content_size = 0;
|
||||
let state = reset_cctx_by_attaching_cdict_test_state(
|
||||
&mut probe,
|
||||
0x4000usize as *const c_void,
|
||||
0x3000usize as *const c_void,
|
||||
&mut destination_dict_id,
|
||||
&source_dict_id,
|
||||
&mut destination_dict_content_size,
|
||||
&source_dict_content_size,
|
||||
&mut destination_block_state_slot,
|
||||
&source_block_state,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user