feat(compress): call the Rust CCtx block reset leaf directly

Pass the private CCtx compressed-block-state pointer into the Rust reset
tail and invoke the existing Rust reset leaf directly. Remove the
redundant C adapter while keeping reset-tail ordering and private state
opaque at the ABI boundary.

Strengthen reset-tail tests to verify the direct reset state.

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:
2026-07-19 22:09:11 +02:00
parent fb78186ed9
commit 45191e1413
2 changed files with 30 additions and 52 deletions
+3 -11
View File
@@ -1563,14 +1563,14 @@ typedef char ZSTD_rust_reset_cctx_workspace_state_layout[
typedef struct {
void* callbackContext;
ZSTD_rust_resetCCtxStorageCallback_f initialize;
ZSTD_rust_resetCCtxStorageCallback_f resetCompressedBlockState;
void* compressedBlockState;
ZSTD_rust_resetCCtxTailCallback_f resetMatchState;
ZSTD_rust_resetCCtxTailCallback_f resetStorage;
} ZSTD_rust_resetCCtxTailState;
typedef char ZSTD_rust_reset_cctx_tail_state_layout[
(offsetof(ZSTD_rust_resetCCtxTailState, callbackContext) == 0
&& offsetof(ZSTD_rust_resetCCtxTailState, initialize) == sizeof(void*)
&& offsetof(ZSTD_rust_resetCCtxTailState, resetCompressedBlockState)
&& offsetof(ZSTD_rust_resetCCtxTailState, compressedBlockState)
== 2 * sizeof(void*)
&& offsetof(ZSTD_rust_resetCCtxTailState, resetMatchState)
== 3 * sizeof(void*)
@@ -4248,13 +4248,6 @@ static void ZSTD_rust_resetCCtxTail_initialize(void* opaque)
cctx->dictContentSize = 0;
}
static void ZSTD_rust_resetCCtxTail_resetCompressedBlockState(void* opaque)
{
ZSTD_rust_resetCCtxTailContext* const context =
(ZSTD_rust_resetCCtxTailContext*)opaque;
ZSTD_reset_compressedBlockState(context->cctx->blockState.prevCBlock);
}
static size_t ZSTD_rust_resetCCtxTail_resetMatchState(void* opaque)
{
ZSTD_rust_resetCCtxTailContext* const context =
@@ -4427,8 +4420,7 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
tailContext.storageState = &storageState;
tailState.callbackContext = &tailContext;
tailState.initialize = ZSTD_rust_resetCCtxTail_initialize;
tailState.resetCompressedBlockState =
ZSTD_rust_resetCCtxTail_resetCompressedBlockState;
tailState.compressedBlockState = zc->blockState.prevCBlock;
tailState.resetMatchState = ZSTD_rust_resetCCtxTail_resetMatchState;
tailState.resetStorage = ZSTD_rust_resetCCtxTail_resetStorage;
FORWARD_IF_ERROR(ZSTD_rust_resetCCtxTail(&tailState), "");