refactor(cdict): move static initializer error policy to Rust
Keep the private static-CDict initializer in C, but return its native size_t status through the callback boundary. Rust now owns the public success-or-NULL mapping, preserving the original workspace validation, callback order, and private layout ownership while making initializer failures explicit and unit-testable. Test Plan: ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings; cargo +nightly fmt --manifest-path rust/Cargo.toml --all -- --check; GCC and Clang syntax-only checks; make -j1 -C tests test (all 41 shell tests, fuzzer, zstd tester, and zstream tester passed).
This commit is contained in:
@@ -463,7 +463,7 @@ typedef void (*ZSTD_rust_initStaticCDictMoveWorkspace_f)(
|
||||
void* context, void* cdict);
|
||||
typedef void (*ZSTD_rust_initStaticCDictInitialize_f)(
|
||||
void* context, void* cdict, int useRowMatchFinder);
|
||||
typedef void* (*ZSTD_rust_initStaticCDictInit_f)(
|
||||
typedef size_t (*ZSTD_rust_initStaticCDictInit_f)(
|
||||
void* context, void* cdict);
|
||||
typedef struct {
|
||||
void* callbackContext;
|
||||
@@ -7306,16 +7306,14 @@ static void ZSTD_rust_initStaticCDict_initialize(
|
||||
dictionary->compressionLevel = ZSTD_NO_CLEVEL;
|
||||
}
|
||||
|
||||
static void* ZSTD_rust_initStaticCDict_init(void* opaque, void* cdict)
|
||||
static size_t ZSTD_rust_initStaticCDict_init(void* opaque, void* cdict)
|
||||
{
|
||||
ZSTD_rust_initStaticCDictContext const* const context =
|
||||
(const ZSTD_rust_initStaticCDictContext*)opaque;
|
||||
if (ZSTD_isError( ZSTD_initCDict_internal(
|
||||
return ZSTD_initCDict_internal(
|
||||
(ZSTD_CDict*)cdict, context->dict, context->dictSize,
|
||||
context->dictLoadMethod, context->dictContentType,
|
||||
context->params) ))
|
||||
return NULL;
|
||||
return cdict;
|
||||
context->params);
|
||||
}
|
||||
|
||||
const ZSTD_CDict* ZSTD_initStaticCDict(
|
||||
|
||||
Reference in New Issue
Block a user