MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ZSTD_decompressMultiFrame

Function ZSTD_decompressMultiFrame

freebsd/contrib/openzfs/module/zstd/lib/zstd.c:25200–25291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25198}
25199
25200static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx,
25201 void* dst, size_t dstCapacity,
25202 const void* src, size_t srcSize,
25203 const void* dict, size_t dictSize,
25204 const ZSTD_DDict* ddict)
25205{
25206 void* const dststart = dst;
25207 int moreThan1Frame = 0;
25208
25209 DEBUGLOG(5, "ZSTD_decompressMultiFrame");
25210 assert(dict==NULL || ddict==NULL); /* either dict or ddict set, not both */
25211
25212 if (ddict) {
25213 dict = ZSTD_DDict_dictContent(ddict);
25214 dictSize = ZSTD_DDict_dictSize(ddict);
25215 }
25216
25217 while (srcSize >= ZSTD_startingInputLength(dctx->format)) {
25218
25219#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
25220 if (ZSTD_isLegacy(src, srcSize)) {
25221 size_t decodedSize;
25222 size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy(src, srcSize);
25223 if (ZSTD_isError(frameSize)) return frameSize;
25224 RETURN_ERROR_IF(dctx->staticSize, memory_allocation,
25225 "legacy support is not compatible with static dctx");
25226
25227 decodedSize = ZSTD_decompressLegacy(dst, dstCapacity, src, frameSize, dict, dictSize);
25228 if (ZSTD_isError(decodedSize)) return decodedSize;
25229
25230 assert(decodedSize <=- dstCapacity);
25231 dst = (BYTE*)dst + decodedSize;
25232 dstCapacity -= decodedSize;
25233
25234 src = (const BYTE*)src + frameSize;
25235 srcSize -= frameSize;
25236
25237 continue;
25238 }
25239#endif
25240
25241 { U32 const magicNumber = MEM_readLE32(src);
25242 DEBUGLOG(4, "reading magic number %08X (expecting %08X)",
25243 (unsigned)magicNumber, ZSTD_MAGICNUMBER);
25244 if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
25245 size_t const skippableSize = readSkippableFrameSize(src, srcSize);
25246 FORWARD_IF_ERROR(skippableSize, "readSkippableFrameSize failed");
25247 assert(skippableSize <= srcSize);
25248
25249 src = (const BYTE *)src + skippableSize;
25250 srcSize -= skippableSize;
25251 continue;
25252 } }
25253
25254 if (ddict) {
25255 /* we were called from ZSTD_decompress_usingDDict */
25256 FORWARD_IF_ERROR(ZSTD_decompressBegin_usingDDict(dctx, ddict), "");
25257 } else {

Callers 2

Calls 14

ZSTD_DDict_dictContentFunction · 0.70
ZSTD_DDict_dictSizeFunction · 0.70
ZSTD_startingInputLengthFunction · 0.70
ZSTD_isLegacyFunction · 0.70
ZSTD_isErrorFunction · 0.70
ZSTD_decompressLegacyFunction · 0.70
MEM_readLE32Function · 0.70
readSkippableFrameSizeFunction · 0.70
ZSTD_checkContinuityFunction · 0.70

Tested by

no test coverage detected