feat(compress): move window clearing leaf into Rust
Keep the private ZSTD_window_t layout and pointer-difference calculation in C, then route the size_t-to-U32 conversion and paired limit writes through a small Rust ABI leaf. This removes the inline C window-clear implementation while preserving its overflow behavior at both single-threaded and multithreaded call sites. Test Plan: - cargo test --manifest-path rust/Cargo.toml --lib zstd_compress::tests (77 passed) - make -C programs -j2 zstd - rustfmt +nightly --edition 2021 rust/src/zstd_compress.rs --check - make -C tests -j2 test-cli-tests (41 passed) - make -C tests -j2 test-legacy test-invalidDictionaries test-decodecorpus test-rust-lib-smoke (passed) - git diff --check
This commit is contained in:
@@ -1486,7 +1486,8 @@ void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs)
|
||||
*/
|
||||
static void ZSTD_invalidateMatchState(ZSTD_MatchState_t* ms)
|
||||
{
|
||||
ZSTD_window_clear(&ms->window);
|
||||
ZSTD_rust_windowClear((size_t)(ms->window.nextSrc - ms->window.base),
|
||||
&ms->window.lowLimit, &ms->window.dictLimit);
|
||||
|
||||
ms->nextToUpdate = ms->window.dictLimit;
|
||||
ms->loadedDictEnd = 0;
|
||||
@@ -1893,7 +1894,11 @@ ZSTD_resetCCtx_byAttachingCDict(ZSTD_CCtx* cctx,
|
||||
if (cctx->blockState.matchState.window.dictLimit < cdictEnd) {
|
||||
cctx->blockState.matchState.window.nextSrc =
|
||||
cctx->blockState.matchState.window.base + cdictEnd;
|
||||
ZSTD_window_clear(&cctx->blockState.matchState.window);
|
||||
ZSTD_rust_windowClear(
|
||||
(size_t)(cctx->blockState.matchState.window.nextSrc -
|
||||
cctx->blockState.matchState.window.base),
|
||||
&cctx->blockState.matchState.window.lowLimit,
|
||||
&cctx->blockState.matchState.window.dictLimit);
|
||||
}
|
||||
/* loadedDictEnd is expressed within the referential of the active context */
|
||||
cctx->blockState.matchState.loadedDictEnd = cctx->blockState.matchState.window.dictLimit;
|
||||
|
||||
Reference in New Issue
Block a user