| 227 | |
| 228 | private: |
| 229 | Result<CCtxPtr> CreateCCtx() const { |
| 230 | CCtxPtr cctx{ZSTD_createCCtx(), ZSTD_freeCCtx}; |
| 231 | if (cctx == nullptr) { |
| 232 | return Status::OutOfMemory("ZSTD_CCtx create failed"); |
| 233 | } |
| 234 | auto ret = |
| 235 | ZSTD_CCtx_setParameter(cctx.get(), ZSTD_c_compressionLevel, compression_level_); |
| 236 | if (ZSTD_isError(ret)) { |
| 237 | return ZSTDError(ret, "ZSTD_CCtx create failed: "); |
| 238 | } |
| 239 | for (auto& [key, value] : compression_context_params_) { |
| 240 | ret = ZSTD_CCtx_setParameter(cctx.get(), static_cast<ZSTD_cParameter>(key), value); |
| 241 | if (ZSTD_isError(ret)) { |
| 242 | return ZSTDError(ret, "ZSTD_CCtx create failed: "); |
| 243 | } |
| 244 | } |
| 245 | return cctx; |
| 246 | } |
| 247 | |
| 248 | Result<DCtxPtr> CreateDCtx() const { |
| 249 | DCtxPtr dctx{ZSTD_createDCtx(), ZSTD_freeDCtx}; |
nothing calls this directly
no test coverage detected