feat(compress): move repcode invalidation to Rust
Keep ZSTD_invalidateRepCodes responsible for extracting the private previous block state and checking that the match window has no external dictionary. Delegate only the fixed three-entry repcode reset through a narrow pointer ABI, with a C assertion preserving the Rust side's ZSTD_REP_NUM assumption. Test Plan: - `cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression zstd_compress::tests::invalidate_rep_codes_clears_all_entries` -- passed - `make -B -C lib -j2 lib` -- passed - `make -C tests -j2 fuzzer` and `./tests/fuzzer -s4560 -t47 -i48 -v` -- passed - Required clippy, nightly fmt, and diff checks -- passed
This commit is contained in:
@@ -298,6 +298,8 @@ size_t ZSTD_rust_copyBlockSequences(
|
||||
SeqCollector* seqCollector, const SeqStore_t* seqStore,
|
||||
const U32 prevRepcodes[ZSTD_REP_NUM]);
|
||||
void ZSTD_rust_resetCompressedBlockState(ZSTD_compressedBlockState_t* bs);
|
||||
void ZSTD_rust_invalidateRepCodes(U32 rep[ZSTD_REP_NUM]);
|
||||
typedef char ZSTD_rust_invalidate_rep_count[(ZSTD_REP_NUM == 3) ? 1 : -1];
|
||||
void ZSTD_rust_confirmRepcodesAndEntropyTables(
|
||||
ZSTD_compressedBlockState_t** prevCBlock,
|
||||
ZSTD_compressedBlockState_t** nextCBlock);
|
||||
@@ -1798,8 +1800,8 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
|
||||
* Note : only works with regular variant;
|
||||
* do not use with extDict variant ! */
|
||||
void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx) {
|
||||
int i;
|
||||
for (i=0; i<ZSTD_REP_NUM; i++) cctx->blockState.prevCBlock->rep[i] = 0;
|
||||
ZSTD_compressedBlockState_t* const prevCBlock = cctx->blockState.prevCBlock;
|
||||
ZSTD_rust_invalidateRepCodes(prevCBlock->rep);
|
||||
assert(!ZSTD_window_hasExtDict(cctx->blockState.matchState.window));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user