refactor(compress): expose compressed block reset from Rust
The compressed-block reset logic was already implemented in Rust, but the Rust export used a private bridge name and C retained a forwarding wrapper under the original ABI name. Export the original `ZSTD_reset_compressedBlockState` symbol directly from Rust, keep the `ZSTD_rust_resetCompressedBlockState` crate-local alias for existing Rust callers, and remove only the redundant C declaration and body. Private context-layout code and other C functions remain unchanged. Test Plan: - `git diff --check` -- passed. - `cc -std=c99 -Ilib -Ilib/common -Ilib/compress -Ilib/decompress -Ilib/dict -fsyntax-only lib/compress/zstd_compress.c` -- passed. - `cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check` -- passed. - Cargo build/test and make were intentionally not run per the requested lightweight-only scope.
This commit is contained in:
@@ -1089,7 +1089,7 @@ pub unsafe extern "C" fn ZSTD_rust_postProcessSequenceProducerResult(
|
||||
/// `ZSTD_reset_compressedBlockState()`. The caller must provide a valid
|
||||
/// mutable compressed block state.
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn ZSTD_rust_resetCompressedBlockState(
|
||||
pub unsafe extern "C" fn ZSTD_reset_compressedBlockState(
|
||||
block_state: *mut ZSTD_compressedBlockState_t,
|
||||
) {
|
||||
let block_state = unsafe { &mut *block_state };
|
||||
@@ -1100,6 +1100,8 @@ pub unsafe extern "C" fn ZSTD_rust_resetCompressedBlockState(
|
||||
block_state.entropy.fse.litlength_repeatMode = FSE_REPEAT_NONE;
|
||||
}
|
||||
|
||||
pub(crate) use ZSTD_reset_compressedBlockState as ZSTD_rust_resetCompressedBlockState;
|
||||
|
||||
/// Swaps the two C-owned block-state pointers after a block is confirmed.
|
||||
///
|
||||
/// The enclosing `ZSTD_blockState_t` contains C-only match-state storage, so
|
||||
@@ -3287,7 +3289,7 @@ mod tests {
|
||||
block_state.entropy.fse.matchlength_repeatMode = 1;
|
||||
block_state.entropy.fse.litlength_repeatMode = 2;
|
||||
|
||||
unsafe { ZSTD_rust_resetCompressedBlockState(&mut block_state) };
|
||||
unsafe { ZSTD_reset_compressedBlockState(&mut block_state) };
|
||||
|
||||
assert_eq!(block_state.rep, [1, 4, 8]);
|
||||
assert_eq!(block_state.entropy.huf.repeatMode, HUF_REPEAT_NONE);
|
||||
|
||||
Reference in New Issue
Block a user