Function zstd_sys::ZSTD_estimateCCtxSize
source · [−]Expand description
ZSTD_estimate*() : These functions make it possible to estimate memory usage of a future {D,C}Ctx, before its creation.
ZSTD_estimateCCtxSize() will provide a memory budget large enough for any compression level up to selected one. Note : Unlike ZSTD_estimateCStreamSize*(), this estimate does not include space for a window buffer. Therefore, the estimation is only guaranteed for single-shot compressions, not streaming. The estimate will assume the input may be arbitrarily large, which is the worst case.
When srcSize can be bound by a known and rather “small” value, this fact can be used to provide a tighter estimation because the CCtx compression context will need less memory. This tighter estimation can be provided by more advanced functions ZSTD_estimateCCtxSize_usingCParams(), which can be used in tandem with ZSTD_getCParams(), and ZSTD_estimateCCtxSize_usingCCtxParams(), which can be used in tandem with ZSTD_CCtxParams_setParameter(). Both can be used to estimate memory using custom compression parameters and arbitrary srcSize limits.
Note 2 : only single-threaded compression is supported. ZSTD_estimateCCtxSize_usingCCtxParams() will return an error code if ZSTD_c_nbWorkers is >= 1.