in csharp/src/ZStdDecompress.cs [2096:2160]
static size_t DecompressMultiFrame(ZSTD_DCtx dctx,
void* dst, size_t dstCapacity,
void* src, size_t srcSize,
void* dict, size_t dictSize
/*,ZSTD_DDict ddict is constant null*/)
{
void* dststart = dst;
Debug.Assert(dict == null /*|| ddict == null*/); /* either dict or ddict set, not both */
//if (ddict != 0)
//{
// dict = ZSTD_DDictDictContent(ddict);
// dictSize = ZSTD_DDictDictSize(ddict);
//}
while (srcSize >= ZSTD_frameHeaderSize_prefix)
{
U32 magicNumber;
magicNumber = MEM_readLE32(src);
if (magicNumber != ZSTD_MAGICNUMBER)
{
if ((magicNumber & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START)
{
size_t skippableSize;
if (srcSize < ZSTD_skippableHeaderSize)
return ERROR(Error.srcSize_wrong);
skippableSize = MEM_readLE32((BYTE*)src + ZSTD_frameIdSize) + ZSTD_skippableHeaderSize;
if (srcSize < skippableSize)
return ERROR(Error.srcSize_wrong);
src = (BYTE*)src + skippableSize;
srcSize -= skippableSize;
continue;
}
return ERROR(Error.prefix_unknown);
}
//if (ddict)
//{
// /* we were called from ZSTD_decompress_usingDDict */
// { size_t errcod = ZSTD_decompressBegin_usingDDict(dctx, ddict); if ( IsError(errcod)) return errcod; }
//}
//else
{
/* this will initialize correctly with no dict if dict == null, so
* use this in all cases but ddict */
{ size_t errcod = ZSTD_decompressBegin_usingDict(dctx, dict, dictSize); if (IsError(errcod)) return errcod; }
}
CheckContinuity(dctx, dst);
{
size_t res = DecompressFrame(dctx, dst, dstCapacity, &src, &srcSize);
if (IsError(res)) return res;
/* no need to bound check, ZSTD_decompressFrame already has */
dst = (BYTE*)dst + res;
dstCapacity -= res;
}
} /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */
if (srcSize != 0)
return ERROR(Error.srcSize_wrong); /* input not entirely consumed */
return (size_t)((BYTE*)dst - (BYTE*)dststart);
}