feat(compress): move local dictionary sizing leaf to Rust
ZSTD_sizeof_localDict only combines the optional local dictionary buffer size with the already-owned C dictionary size. Keep dictionary ownership and workspace sizing in C, but pass the three scalar inputs to Rust so the leaf uses explicit C size_t wrapping semantics. The CCtx NULL sizing guard and surrounding ownership and call structure remain unchanged. Test Plan: - `cargo clippy --manifest-path rust/Cargo.toml --no-default-features --features compression` (before and after formatting) -- passed - The same clippy command with `--benches` and `--tests` (before and after formatting) -- passed - `cargo +nightly fmt --manifest-path rust/Cargo.toml` -- passed - `cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression` -- 272 passed - `make -B -C lib -j2 lib` -- passed - `make -C tests test-rust-lib-smoke` and direct `rustLibSmoke` execution -- passed - `make -C tests -j2 fuzzer` -- passed - `./fuzzer -s4560 -t56 -i57 -v` -- passed - `git diff --check` and `git diff --cached --check` -- passed
This commit is contained in:
@@ -88,6 +88,8 @@ size_t ZSTD_rust_nextInputSizeHint(int inBufferMode,
|
||||
size_t inBuffPos);
|
||||
size_t ZSTD_rust_CStreamInSize(void);
|
||||
size_t ZSTD_rust_CStreamOutSize(void);
|
||||
size_t ZSTD_rust_sizeofLocalDict(int dictBufferPresent, size_t dictSize,
|
||||
size_t cdictSize);
|
||||
|
||||
/* Context-free compression-parameter selection and sizing leaves live in
|
||||
* Rust (rust/src/zstd_compress_params.rs). This file retains
|
||||
@@ -528,9 +530,9 @@ static void ZSTD_clearAllDicts(ZSTD_CCtx* cctx)
|
||||
|
||||
static size_t ZSTD_sizeof_localDict(ZSTD_localDict dict)
|
||||
{
|
||||
size_t const bufferSize = dict.dictBuffer != NULL ? dict.dictSize : 0;
|
||||
size_t const cdictSize = ZSTD_sizeof_CDict(dict.cdict);
|
||||
return bufferSize + cdictSize;
|
||||
return ZSTD_rust_sizeofLocalDict(dict.dictBuffer != NULL, dict.dictSize,
|
||||
cdictSize);
|
||||
}
|
||||
|
||||
static void ZSTD_freeCCtxContent(ZSTD_CCtx* cctx)
|
||||
|
||||
Reference in New Issue
Block a user