diff --git a/rust/src/zstd_compress_dictionary.rs b/rust/src/zstd_compress_dictionary.rs index a31efc197..27a1153f8 100644 --- a/rust/src/zstd_compress_dictionary.rs +++ b/rust/src/zstd_compress_dictionary.rs @@ -1115,7 +1115,7 @@ const _: () = { assert!(offset_of!(ZSTD_rust_initStaticCDictState, c_params) == 5 * size_of::()); assert!(offset_of!(ZSTD_rust_initStaticCDictState, sizing) == 6 * size_of::()); assert!(offset_of!(ZSTD_rust_initStaticCDictState, create_workspace) == 7 * size_of::()); - assert!(offset_of!(ZSTD_rust_initStaticCDictState, reserve_object) == 8 * size_of::()); + assert!(offset_of!(ZSTD_rust_initStaticCDictState, reserve_object) == usize::BITS as usize); assert!(offset_of!(ZSTD_rust_initStaticCDictState, move_workspace) == 9 * size_of::()); assert!(offset_of!(ZSTD_rust_initStaticCDictState, initialize) == 10 * size_of::()); assert!(offset_of!(ZSTD_rust_initStaticCDictState, init) == 11 * size_of::()); diff --git a/rust/src/zstdmt_compress.rs b/rust/src/zstdmt_compress.rs index 6354ceeef..64de5cd6d 100644 --- a/rust/src/zstdmt_compress.rs +++ b/rust/src/zstdmt_compress.rs @@ -6821,7 +6821,9 @@ mod tests { jobIDMask: 0, ..ZSTDMT_flushContextProjection::default() }; - let mut error_cleanup = Vec::new(); + let error_cleanup = Rc::new(RefCell::new(Vec::new())); + let wait_cleanup = Rc::clone(&error_cleanup); + let release_cleanup = Rc::clone(&error_cleanup); let result = unsafe { flush_produced_with( context, @@ -6834,13 +6836,13 @@ mod tests { |_job_id, _projection| panic!("unexpected checksum callback"), |_job_id, _dst_flushed| panic!("unexpected update callback"), |_job_id, _src_size, _c_size| panic!("unexpected completion callback"), - || error_cleanup.push("wait"), - || error_cleanup.push("release"), + move || wait_cleanup.borrow_mut().push("wait"), + move || release_cleanup.borrow_mut().push("release"), ) }; assert_eq!(result.result, ERROR(ZstdErrorCode::Generic)); assert_eq!(result.outputPos, 0); - assert_eq!(error_cleanup, ["wait", "release"]); + assert_eq!(&*error_cleanup.borrow(), &["wait", "release"]); let job = [0x80u8, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86]; let mut output = [0xa5u8; 8]; @@ -6899,7 +6901,9 @@ mod tests { frameChecksumNeeded: 1, ..ZSTDMT_flushJobProjection::default() }; - let mut error_cleanup = Vec::new(); + let error_cleanup = Rc::new(RefCell::new(Vec::new())); + let wait_cleanup = Rc::clone(&error_cleanup); + let release_cleanup = Rc::clone(&error_cleanup); let mut completed = false; let result = unsafe { @@ -6921,14 +6925,14 @@ mod tests { }, |_job_id, _dst_flushed| panic!("unexpected update callback"), |_job_id, _src_size, _c_size| completed = true, - || error_cleanup.push("wait"), - || error_cleanup.push("release"), + move || wait_cleanup.borrow_mut().push("wait"), + move || release_cleanup.borrow_mut().push("release"), ) }; assert_eq!(result.result, ERROR(ZstdErrorCode::DstSizeTooSmall)); assert_eq!(result.outputPos, 0); - assert_eq!(error_cleanup, ["wait", "release"]); + assert_eq!(&*error_cleanup.borrow(), &["wait", "release"]); assert!(!completed); assert_eq!(output, [0xa5; 8]); }