feat(compress): move CCtx custom memory copy into Rust
Replace the remaining CCtx-copy custom-memory callback with explicit source and destination pointers. Rust now copies the ABI-checked ZSTD_customMem payload in its original position before reset, while C retains private context access and the surrounding workspace and table operations. Test Plan: - ulimit -v 41943040 cargo fmt --manifest-path rust/Cargo.toml -- --check - ulimit -v 41943040 CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040 CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml - 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
This commit is contained in:
@@ -459,8 +459,6 @@ typedef char ZSTD_rust_reset_cctx_state_layout[
|
||||
? 1 : -1];
|
||||
typedef size_t (*ZSTD_rust_copyCCtxCheckStage_f)(
|
||||
void* context, const void* srcCCtx);
|
||||
typedef void (*ZSTD_rust_copyCCtxCopyState_f)(
|
||||
void* context, const void* srcCCtx);
|
||||
typedef size_t (*ZSTD_rust_copyCCtxReset_f)(
|
||||
void* context, const void* srcCCtx,
|
||||
const ZSTD_frameParameters* fParams,
|
||||
@@ -474,7 +472,8 @@ typedef struct {
|
||||
const ZSTD_frameParameters* fParams;
|
||||
U64 pledgedSrcSize;
|
||||
ZSTD_rust_copyCCtxCheckStage_f checkStage;
|
||||
ZSTD_rust_copyCCtxCopyState_f copyCustomMem;
|
||||
void* destinationCustomMem;
|
||||
const void* sourceCustomMem;
|
||||
ZSTD_rust_copyCCtxReset_f reset;
|
||||
ZSTD_rust_copyCCtxMarkTables_f markTablesDirty;
|
||||
ZSTD_rust_copyCCtxCopyTables_f copyTables;
|
||||
@@ -536,7 +535,7 @@ typedef char ZSTD_rust_copy_cctx_internal_state_layout[
|
||||
== 3 * sizeof(void*) + sizeof(U64)
|
||||
&& offsetof(ZSTD_rust_copyCCtxInternalState, zbuff)
|
||||
== 3 * sizeof(void*) + sizeof(U64)
|
||||
+ 18 * sizeof(void*)
|
||||
+ 19 * sizeof(void*)
|
||||
&& sizeof(ZSTD_rust_copyCCtxInternalState)
|
||||
== ((offsetof(ZSTD_rust_copyCCtxInternalState, zbuff)
|
||||
+ sizeof(int) + sizeof(void*) - 1) / sizeof(void*))
|
||||
@@ -4756,14 +4755,6 @@ static size_t ZSTD_rust_copyCCtx_check_stage(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ZSTD_rust_copyCCtx_copy_custom_mem(
|
||||
void* context, const void* srcCCtx)
|
||||
{
|
||||
ZSTD_CCtx* const dst = (ZSTD_CCtx*)context;
|
||||
const ZSTD_CCtx* const src = (const ZSTD_CCtx*)srcCCtx;
|
||||
ZSTD_memcpy(&dst->customMem, &src->customMem, sizeof(ZSTD_customMem));
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_copyCCtx_reset(
|
||||
void* context, const void* srcCCtx,
|
||||
const ZSTD_frameParameters* fParams,
|
||||
@@ -4846,7 +4837,10 @@ static size_t ZSTD_rust_copyCCtx_internal_callback(
|
||||
state.fParams = fParams;
|
||||
state.pledgedSrcSize = pledgedSrcSize;
|
||||
state.checkStage = ZSTD_rust_copyCCtx_check_stage;
|
||||
state.copyCustomMem = ZSTD_rust_copyCCtx_copy_custom_mem;
|
||||
state.destinationCustomMem =
|
||||
&((ZSTD_CCtx*)context)->customMem;
|
||||
state.sourceCustomMem =
|
||||
&((const ZSTD_CCtx*)srcCCtx)->customMem;
|
||||
state.reset = ZSTD_rust_copyCCtx_reset;
|
||||
state.markTablesDirty = ZSTD_rust_copyCCtx_mark_tables_dirty;
|
||||
state.copyTables = ZSTD_rust_copyCCtx_copy_tables;
|
||||
|
||||
Reference in New Issue
Block a user