refactor(compress): move stable buffer policy to Rust
Move the stable input and output expectation update into the Rust compression module. Keep the private CCtx layout and debug logging in the C adapter while passing only the buffer-mode scalars and projected buffer fields across the ABI. Preserve C size_t wrapping for the output remainder and leave buffered modes unchanged. Test Plan: - rustfmt --edition 2021 --check rust/src/zstd_compress.rs - 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; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml --all-targets - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/cli/Cargo.toml --all-targets - ulimit -v 41943040; make -j1 -C tests test
This commit is contained in:
@@ -1792,6 +1792,10 @@ size_t ZSTD_rust_checkBufferStability(
|
||||
const void* expectedInSrc, size_t expectedInPos,
|
||||
const void* inputSrc, size_t inputPos,
|
||||
size_t expectedOutBufferSize, size_t outputSize, size_t outputPos);
|
||||
void ZSTD_rust_setBufferExpectations(
|
||||
int inBufferMode, int outBufferMode,
|
||||
ZSTD_inBuffer* expectedInBuffer, size_t* expectedOutBufferSize,
|
||||
const ZSTD_outBuffer* output, const ZSTD_inBuffer* input);
|
||||
|
||||
/* Context-free compression-parameter selection and sizing leaves live in
|
||||
* Rust (rust/src/zstd_compress_params.rs). This file retains
|
||||
@@ -7690,12 +7694,13 @@ static void
|
||||
ZSTD_setBufferExpectations(ZSTD_CCtx* cctx, const ZSTD_outBuffer* output, const ZSTD_inBuffer* input)
|
||||
{
|
||||
DEBUGLOG(5, "ZSTD_setBufferExpectations (for advanced stable in/out modes)");
|
||||
if (cctx->appliedParams.inBufferMode == ZSTD_bm_stable) {
|
||||
cctx->expectedInBuffer = *input;
|
||||
}
|
||||
if (cctx->appliedParams.outBufferMode == ZSTD_bm_stable) {
|
||||
cctx->expectedOutBufferSize = output->size - output->pos;
|
||||
}
|
||||
ZSTD_rust_setBufferExpectations(
|
||||
(int)cctx->appliedParams.inBufferMode,
|
||||
(int)cctx->appliedParams.outBufferMode,
|
||||
&cctx->expectedInBuffer,
|
||||
&cctx->expectedOutBufferSize,
|
||||
output,
|
||||
input);
|
||||
}
|
||||
|
||||
/* Validate that the input/output buffers match the expectations set by
|
||||
|
||||
Reference in New Issue
Block a user