From 2c644304f5c84b81d4096bb9ae0df967905af9db Mon Sep 17 00:00:00 2001 From: ddidderr Date: Mon, 20 Jul 2026 01:30:23 +0200 Subject: [PATCH] feat(compress): route CDict end through Rust Share the existing end-state projection between the public C wrapper and Rust-owned compressed-dictionary orchestration. The CDict callback now reaches ZSTD_rust_compressEnd through the private dispatcher without re-entering the public C end wrapper, while the exported API keeps its compatibility wrapper. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo fmt --manifest-path rust/Cargo.toml --all -- --check - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --lib - 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 --- lib/compress/zstd_compress.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 81a02e763..647394711 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -6205,9 +6205,9 @@ static void ZSTD_rust_compressEnd_trace(void* context, size_t extraCSize) ZSTD_CCtx_trace((ZSTD_CCtx*)context, extraCSize); } -size_t ZSTD_compressEnd_public(ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize) +static size_t ZSTD_compressEnd_dispatch(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize) { ZSTD_rust_compressContinueContext continueContext; ZSTD_rust_compressEndState state; @@ -6229,6 +6229,13 @@ size_t ZSTD_compressEnd_public(ZSTD_CCtx* cctx, &state, dst, dstCapacity, src, srcSize); } +size_t ZSTD_compressEnd_public(ZSTD_CCtx* cctx, + void* dst, size_t dstCapacity, + const void* src, size_t srcSize) +{ + return ZSTD_compressEnd_dispatch(cctx, dst, dstCapacity, src, srcSize); +} + /* NOTE: Must just wrap ZSTD_compressEnd_public() */ size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, @@ -6939,7 +6946,7 @@ static size_t ZSTD_rust_compressUsingCDict_end( void* context, void* dst, size_t dstCapacity, const void* src, size_t srcSize) { - return ZSTD_compressEnd_public( + return ZSTD_compressEnd_dispatch( (ZSTD_CCtx*)context, dst, dstCapacity, src, srcSize); }