feat(compress): move CCtx parameter allocation to Rust

Move CCtx_params allocation, initialization, and release behind Rust ABI helpers while preserving the public C wrappers and custom allocator contract. Keep parameter bounds and policy in the existing C implementation.

Test Plan:\n- cargo clippy --manifest-path rust/Cargo.toml\n- cargo clippy --manifest-path rust/Cargo.toml --benches\n- cargo clippy --manifest-path rust/Cargo.toml --tests\n- cargo +nightly fmt --manifest-path rust/Cargo.toml --all\n- cargo test --manifest-path rust/Cargo.toml --no-default-features --features compression\n- make -B -C lib -j2 lib\n- make -B -C tests -j2 test-rust-lib-smoke\n- make -B -C tests -j2 test-zstream\n- make -B -C tests -j2 test-cli-tests
This commit is contained in:
2026-07-18 03:01:08 +02:00
parent 4171c42448
commit 3feb9370c8
2 changed files with 115 additions and 16 deletions
+4 -11
View File
@@ -87,6 +87,8 @@ size_t ZSTD_rust_cctx_params_clamp_bounds(int param, int* value);
int ZSTD_rust_cctx_params_within_bounds(int param, int value);
int ZSTD_rust_cctx_params_is_multithreaded(void);
int ZSTD_rust_cctx_params_job_size_min(void);
ZSTD_CCtx_params* ZSTD_rust_createCCtxParams(ZSTD_customMem customMem);
size_t ZSTD_rust_freeCCtxParams(ZSTD_CCtx_params* params);
#define ZSTD_RUST_CCTX_PARAMS_ASSERT(name, condition) \
typedef char name[(condition) ? 1 : -1]
@@ -531,14 +533,7 @@ static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
static ZSTD_CCtx_params* ZSTD_createCCtxParams_advanced(
ZSTD_customMem customMem)
{
ZSTD_CCtx_params* params;
if ((!customMem.customAlloc) ^ (!customMem.customFree)) return NULL;
params = (ZSTD_CCtx_params*)ZSTD_customCalloc(
sizeof(ZSTD_CCtx_params), customMem);
if (!params) { return NULL; }
ZSTD_CCtxParams_init(params, ZSTD_CLEVEL_DEFAULT);
params->customMem = customMem;
return params;
return ZSTD_rust_createCCtxParams(customMem);
}
ZSTD_CCtx_params* ZSTD_createCCtxParams(void)
@@ -548,9 +543,7 @@ ZSTD_CCtx_params* ZSTD_createCCtxParams(void)
size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params)
{
if (params == NULL) { return 0; }
ZSTD_customFree(params, params->customMem);
return 0;
return ZSTD_rust_freeCCtxParams(params);
}
#define ZSTD_NO_CLEVEL 0