dctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid());
ZSTD_DCtx_resetParameters(dctx);
dctx->validateChecksum = 1;
+ dctx->refMultipleDDicts = 0;
+ dctx->ddictSet = NULL;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
dctx->dictContentEndForFuzzing = NULL;
#endif
if (dctx->legacyContext)
ZSTD_freeLegacyStreamContext(dctx->legacyContext, dctx->previousLegacyVersion);
#endif
+ if (dctx->ddictSet) {
+ ZSTD_freeDDictHashSet(dctx->ddictSet, cMem);
+ dctx->ddictSet = NULL;
+ }
ZSTD_customFree(dctx, cMem);
return 0;
}
return ret;
}
+static void ZSTD_freeDDictHashSet(ZSTD_DDictHashSet* hashSet, ZSTD_customMem customMem) {
+ if (hashSet->ddictPtrTable) ZSTD_customFree(hashSet->ddictPtrTable, customMem);
+ ZSTD_customFree(hashSet, customMem);
+}
size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx,
const void* dict, size_t dictSize,
case ZSTD_d_refMultipleDDicts:
CHECK_DBOUNDS(ZSTD_d_refMultipleDDicts, value);
dctx->refMultipleDDicts = (ZSTD_refMultipleDDicts_e)value;
+ if (dctx->refMultipleDDicts == ZSTD_d_refMultipleDicts) {
+ if (dctx->ddictSet == NULL) {
+ if (dctx->staticSize != 0) {
+ RETURN_ERROR(memory_allocation, "Multiple DDicts are not allowed with static dctx!");
+ }
+ dctx->ddictSet = ZSTD_createDDictHashSet(dctx->customMem);
+ }
+ } else {
+ ZSTD_freeDDictHashSet(dctx->ddictSet, dctx->customMem);
+ dctx->ddictSet = NULL;
+ }
+ return 0;
default:;
}
RETURN_ERROR(parameter_unsupported, "");
U32 dictID;
int ddictIsCold; /* if == 1 : dictionary is "new" for working context, and presumed "cold" (not in cpu cache) */
ZSTD_dictUses_e dictUses;
+ ZSTD_DDictHashSet* ddictSet; /* Hash set for multiple ddicts */
ZSTD_refMultipleDDicts_e refMultipleDDicts; /* User specified: if == 1, will allow references to multiple DDicts. Default == 0 (disabled) */
/* streaming */