* Initializes the local dict using the requested parameters. * NOTE: This does not use the pledged src size, because it may be used for more * than one compression. */
| 13940 | * than one compression. |
| 13941 | */ |
| 13942 | static size_t ZSTD_initLocalDict(ZSTD_CCtx* cctx) |
| 13943 | { |
| 13944 | ZSTD_localDict* const dl = &cctx->localDict; |
| 13945 | ZSTD_compressionParameters const cParams = ZSTD_getCParamsFromCCtxParams( |
| 13946 | &cctx->requestedParams, ZSTD_CONTENTSIZE_UNKNOWN, dl->dictSize); |
| 13947 | if (dl->dict == NULL) { |
| 13948 | /* No local dictionary. */ |
| 13949 | assert(dl->dictBuffer == NULL); |
| 13950 | assert(dl->cdict == NULL); |
| 13951 | assert(dl->dictSize == 0); |
| 13952 | return 0; |
| 13953 | } |
| 13954 | if (dl->cdict != NULL) { |
| 13955 | assert(cctx->cdict == dl->cdict); |
| 13956 | /* Local dictionary already initialized. */ |
| 13957 | return 0; |
| 13958 | } |
| 13959 | assert(dl->dictSize > 0); |
| 13960 | assert(cctx->cdict == NULL); |
| 13961 | assert(cctx->prefixDict.dict == NULL); |
| 13962 | |
| 13963 | dl->cdict = ZSTD_createCDict_advanced( |
| 13964 | dl->dict, |
| 13965 | dl->dictSize, |
| 13966 | ZSTD_dlm_byRef, |
| 13967 | dl->dictContentType, |
| 13968 | cParams, |
| 13969 | cctx->customMem); |
| 13970 | RETURN_ERROR_IF(!dl->cdict, memory_allocation, "ZSTD_createCDict_advanced failed"); |
| 13971 | cctx->cdict = dl->cdict; |
| 13972 | return 0; |
| 13973 | } |
| 13974 | |
| 13975 | size_t ZSTD_CCtx_loadDictionary_advanced( |
| 13976 | ZSTD_CCtx* cctx, const void* dict, size_t dictSize, |
no test coverage detected