feat(decompress): move DCtx prefix copy into Rust

Move the `ZSTD_copyDCtx` prefix-copy leaf into the Rust decompression module.
Rust uses the C-projected address of `inBuff` to preserve the exact private
context cutoff, while C retains the configuration-dependent context layout
and shallow-pointer ownership semantics. Add a focused boundary test and
remove the now-unused C copy helper.

Test Plan:
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo fmt --manifest-path rust/Cargo.toml -- --check
- ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml copy_prefix -- --nocapture
- 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 -B -C programs -j1 zstd
- ulimit -v 41943040 make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
This commit is contained in:
2026-07-19 19:32:48 +02:00
parent 1cb3efd0af
commit bd9ca5115d
3 changed files with 35 additions and 11 deletions
-7
View File
@@ -117,7 +117,6 @@ ZSTD_DDict* ZSTD_rust_create_ddict(const void* dict, size_t dictSize,
ZSTD_dictLoadMethod_e dictLoadMethod,
ZSTD_dictContentType_e dictContentType,
ZSTD_customMem customMem);
void ZSTD_rust_dctx_copy_prefix(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx);
void ZSTD_rust_dctx_trace_begin(ZSTD_DCtx* dctx);
void ZSTD_rust_dctx_trace_end(ZSTD_DCtx* dctx, U64 uncompressedSize,
U64 compressedSize, int streaming);
@@ -261,12 +260,6 @@ ZSTD_DDict* ZSTD_rust_create_ddict(const void* dict, size_t dictSize,
dictContentType, customMem);
}
void ZSTD_rust_dctx_copy_prefix(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx)
{
size_t const toCopy = (size_t)((const char*)(&dstDCtx->inBuff) - (const char*)dstDCtx);
ZSTD_memcpy(dstDCtx, srcDCtx, toCopy);
}
void ZSTD_rust_dctx_trace_begin(ZSTD_DCtx* dctx)
{
#if ZSTD_TRACE