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

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

Strengthen the CDict initialization tests to verify reset repcodes and
repeat-mode state through the direct Rust path.

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:04:39 +02:00
parent 29198a1157
commit fb78186ed9
2 changed files with 17 additions and 37 deletions
+3 -10
View File
@@ -2225,7 +2225,6 @@ typedef char ZSTD_rust_external_sequence_store_state_layout[
typedef void* (*ZSTD_rust_initCDictReserveContent_f)(
void* context, size_t dictSize);
typedef void* (*ZSTD_rust_initCDictReserveEntropy_f)(void* context);
typedef void (*ZSTD_rust_initCDictResetBlockState_f)(void* context);
typedef size_t (*ZSTD_rust_initCDictResetMatchState_f)(
void* context, const ZSTD_compressionParameters* cParams,
int useRowMatchFinder);
@@ -2249,7 +2248,7 @@ typedef struct {
int* contentSizeFlag;
ZSTD_rust_initCDictReserveContent_f reserveContent;
ZSTD_rust_initCDictReserveEntropy_f reserveEntropy;
ZSTD_rust_initCDictResetBlockState_f resetBlockState;
void* blockState;
ZSTD_rust_initCDictResetMatchState_f resetMatchState;
ZSTD_rust_initCDictInsertDictionary_f insertDictionary;
} ZSTD_rust_initCDictState;
@@ -2287,7 +2286,7 @@ typedef char ZSTD_rust_init_cdict_state_layout[
== 14 * sizeof(void*)
&& offsetof(ZSTD_rust_initCDictState, reserveEntropy)
== 15 * sizeof(void*)
&& offsetof(ZSTD_rust_initCDictState, resetBlockState)
&& offsetof(ZSTD_rust_initCDictState, blockState)
== 16 * sizeof(void*)
&& offsetof(ZSTD_rust_initCDictState, resetMatchState)
== 17 * sizeof(void*)
@@ -6042,12 +6041,6 @@ static void* ZSTD_rust_initCDict_reserveEntropy(void* context)
return ZSTD_cwksp_reserve_object(&cdict->workspace, HUF_WORKSPACE_SIZE);
}
static void ZSTD_rust_initCDict_resetBlockState(void* context)
{
ZSTD_CDict* const cdict = (ZSTD_CDict*)context;
ZSTD_reset_compressedBlockState(&cdict->cBlockState);
}
static size_t ZSTD_rust_initCDict_resetMatchState(
void* context, const ZSTD_compressionParameters* cParams,
int useRowMatchFinder)
@@ -6617,7 +6610,7 @@ static size_t ZSTD_initCDict_internal(
state.contentSizeFlag = &params.fParams.contentSizeFlag;
state.reserveContent = ZSTD_rust_initCDict_reserveContent;
state.reserveEntropy = ZSTD_rust_initCDict_reserveEntropy;
state.resetBlockState = ZSTD_rust_initCDict_resetBlockState;
state.blockState = &cdict->cBlockState;
state.resetMatchState = ZSTD_rust_initCDict_resetMatchState;
state.insertDictionary = ZSTD_rust_initCDict_insertDictionary;
return ZSTD_rust_initCDict(