refactor(mt): move serial reset error policy to Rust
Project the private serial-state reset result into Rust for the stream-initialization error decision while retaining C-owned allocation, serial-state mutation, dictionary setup, synchronization, callback order, and ABI layouts. Nonzero callback status preserves the existing memory_allocation error path. Test Plan: ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings; cargo clippy --manifest-path rust/cli/Cargo.toml --all-targets -- -D warnings; cargo test --manifest-path rust/cli/Cargo.toml --all-targets (188 passed); cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check; make -j1; ./tests/rustLibSmoke; make -j1 -C tests test (all shell tests, large streaming tests, native tester, fuzzer phases, and zstream tester passed).
This commit is contained in:
@@ -853,6 +853,7 @@ size_t ZSTDMT_rust_initCStream(
|
||||
ZSTDMT_initResetStreamFn resetStream,
|
||||
ZSTDMT_initDictionaryFn updateDictionary,
|
||||
ZSTDMT_initSerialResetFn serialReset);
|
||||
size_t ZSTDMT_rust_initSerialResetResult(int status);
|
||||
typedef void (*ZSTDMT_resetStreamCallbackFn)(void* opaque);
|
||||
typedef struct {
|
||||
void* callbackContext;
|
||||
@@ -2779,12 +2780,10 @@ static size_t ZSTDMT_initCStreamUpdateDictionary(void* opaque)
|
||||
static size_t ZSTDMT_initCStreamSerialReset(void* opaque, size_t targetSectionSize)
|
||||
{
|
||||
ZSTDMT_initCStreamState* const state = (ZSTDMT_initCStreamState*)opaque;
|
||||
if (ZSTDMT_serialState_reset(
|
||||
return ZSTDMT_rust_initSerialResetResult(ZSTDMT_serialState_reset(
|
||||
&state->mtctx->serial, state->mtctx->seqPool, state->params,
|
||||
targetSectionSize, state->dict, state->dictSize,
|
||||
state->dictContentType))
|
||||
return ERROR(memory_allocation);
|
||||
return 0;
|
||||
state->dictContentType));
|
||||
}
|
||||
|
||||
/* ====================================== */
|
||||
|
||||
Reference in New Issue
Block a user