zds 722 include/linux/zstd.h size_t ZSTD_resetDStream(ZSTD_DStream *zds); zds 743 include/linux/zstd.h size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, zds 2194 lib/zstd/decompress.c ZSTD_DStream *zds; zds 2199 lib/zstd/decompress.c zds = (ZSTD_DStream *)ZSTD_malloc(sizeof(ZSTD_DStream), customMem); zds 2200 lib/zstd/decompress.c if (zds == NULL) zds 2202 lib/zstd/decompress.c memset(zds, 0, sizeof(ZSTD_DStream)); zds 2203 lib/zstd/decompress.c memcpy(&zds->customMem, &customMem, sizeof(ZSTD_customMem)); zds 2204 lib/zstd/decompress.c zds->dctx = ZSTD_createDCtx_advanced(customMem); zds 2205 lib/zstd/decompress.c if (zds->dctx == NULL) { zds 2206 lib/zstd/decompress.c ZSTD_freeDStream(zds); zds 2209 lib/zstd/decompress.c zds->stage = zdss_init; zds 2210 lib/zstd/decompress.c zds->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT; zds 2211 lib/zstd/decompress.c return zds; zds 2217 lib/zstd/decompress.c ZSTD_DStream *zds = ZSTD_createDStream_advanced(stackMem); zds 2218 lib/zstd/decompress.c if (!zds) { zds 2222 lib/zstd/decompress.c zds->maxWindowSize = maxWindowSize; zds 2223 lib/zstd/decompress.c zds->stage = zdss_loadHeader; zds 2224 lib/zstd/decompress.c zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0; zds 2225 lib/zstd/decompress.c ZSTD_freeDDict(zds->ddictLocal); zds 2226 lib/zstd/decompress.c zds->ddictLocal = NULL; zds 2227 lib/zstd/decompress.c zds->ddict = zds->ddictLocal; zds 2228 lib/zstd/decompress.c zds->legacyVersion = 0; zds 2229 lib/zstd/decompress.c zds->hostageByte = 0; zds 2232 lib/zstd/decompress.c size_t const blockSize = MIN(zds->maxWindowSize, ZSTD_BLOCKSIZE_ABSOLUTEMAX); zds 2233 lib/zstd/decompress.c size_t const neededOutSize = zds->maxWindowSize + blockSize + WILDCOPY_OVERLENGTH * 2; zds 2235 lib/zstd/decompress.c zds->inBuff = (char *)ZSTD_malloc(blockSize, zds->customMem); zds 2236 lib/zstd/decompress.c zds->inBuffSize = blockSize; zds 2237 lib/zstd/decompress.c zds->outBuff = (char *)ZSTD_malloc(neededOutSize, zds->customMem); zds 2238 lib/zstd/decompress.c zds->outBuffSize = neededOutSize; zds 2239 lib/zstd/decompress.c if (zds->inBuff == NULL || zds->outBuff == NULL) { zds 2240 lib/zstd/decompress.c ZSTD_freeDStream(zds); zds 2244 lib/zstd/decompress.c return zds; zds 2249 lib/zstd/decompress.c ZSTD_DStream *zds = ZSTD_initDStream(maxWindowSize, workspace, workspaceSize); zds 2250 lib/zstd/decompress.c if (zds) { zds 2251 lib/zstd/decompress.c zds->ddict = ddict; zds 2253 lib/zstd/decompress.c return zds; zds 2256 lib/zstd/decompress.c size_t ZSTD_freeDStream(ZSTD_DStream *zds) zds 2258 lib/zstd/decompress.c if (zds == NULL) zds 2261 lib/zstd/decompress.c ZSTD_customMem const cMem = zds->customMem; zds 2262 lib/zstd/decompress.c ZSTD_freeDCtx(zds->dctx); zds 2263 lib/zstd/decompress.c zds->dctx = NULL; zds 2264 lib/zstd/decompress.c ZSTD_freeDDict(zds->ddictLocal); zds 2265 lib/zstd/decompress.c zds->ddictLocal = NULL; zds 2266 lib/zstd/decompress.c ZSTD_free(zds->inBuff, cMem); zds 2267 lib/zstd/decompress.c zds->inBuff = NULL; zds 2268 lib/zstd/decompress.c ZSTD_free(zds->outBuff, cMem); zds 2269 lib/zstd/decompress.c zds->outBuff = NULL; zds 2270 lib/zstd/decompress.c ZSTD_free(zds, cMem); zds 2280 lib/zstd/decompress.c size_t ZSTD_resetDStream(ZSTD_DStream *zds) zds 2282 lib/zstd/decompress.c zds->stage = zdss_loadHeader; zds 2283 lib/zstd/decompress.c zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0; zds 2284 lib/zstd/decompress.c zds->legacyVersion = 0; zds 2285 lib/zstd/decompress.c zds->hostageByte = 0; zds 2298 lib/zstd/decompress.c size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input) zds 2309 lib/zstd/decompress.c switch (zds->stage) { zds 2311 lib/zstd/decompress.c ZSTD_resetDStream(zds); /* transparent reset on starting decoding a new frame */ zds 2315 lib/zstd/decompress.c size_t const hSize = ZSTD_getFrameParams(&zds->fParams, zds->headerBuffer, zds->lhSize); zds 2319 lib/zstd/decompress.c size_t const toLoad = hSize - zds->lhSize; /* if hSize!=0, hSize > zds->lhSize */ zds 2321 lib/zstd/decompress.c memcpy(zds->headerBuffer + zds->lhSize, ip, iend - ip); zds 2322 lib/zstd/decompress.c zds->lhSize += iend - ip; zds 2324 lib/zstd/decompress.c return (MAX(ZSTD_frameHeaderSize_min, hSize) - zds->lhSize) + zds 2327 lib/zstd/decompress.c memcpy(zds->headerBuffer + zds->lhSize, ip, toLoad); zds 2328 lib/zstd/decompress.c zds->lhSize = hSize; zds 2334 lib/zstd/decompress.c if (zds->fParams.frameContentSize && zds->fParams.windowSize /* skippable frame if == 0 */ zds 2335 lib/zstd/decompress.c && (U64)(size_t)(oend - op) >= zds->fParams.frameContentSize) { zds 2338 lib/zstd/decompress.c size_t const decompressedSize = ZSTD_decompress_usingDDict(zds->dctx, op, oend - op, istart, cSize, zds->ddict); zds 2343 lib/zstd/decompress.c zds->dctx->expected = 0; zds 2344 lib/zstd/decompress.c zds->stage = zdss_init; zds 2351 lib/zstd/decompress.c ZSTD_refDDict(zds->dctx, zds->ddict); zds 2353 lib/zstd/decompress.c size_t const h1Size = ZSTD_nextSrcSizeToDecompress(zds->dctx); /* == ZSTD_frameHeaderSize_prefix */ zds 2354 lib/zstd/decompress.c CHECK_F(ZSTD_decompressContinue(zds->dctx, NULL, 0, zds->headerBuffer, h1Size)); zds 2356 lib/zstd/decompress.c size_t const h2Size = ZSTD_nextSrcSizeToDecompress(zds->dctx); zds 2357 lib/zstd/decompress.c CHECK_F(ZSTD_decompressContinue(zds->dctx, NULL, 0, zds->headerBuffer + h1Size, h2Size)); zds 2361 lib/zstd/decompress.c zds->fParams.windowSize = MAX(zds->fParams.windowSize, 1U << ZSTD_WINDOWLOG_ABSOLUTEMIN); zds 2362 lib/zstd/decompress.c if (zds->fParams.windowSize > zds->maxWindowSize) zds 2367 lib/zstd/decompress.c size_t const blockSize = MIN(zds->maxWindowSize, ZSTD_BLOCKSIZE_ABSOLUTEMAX); zds 2368 lib/zstd/decompress.c size_t const neededOutSize = zds->maxWindowSize + blockSize + WILDCOPY_OVERLENGTH * 2; zds 2369 lib/zstd/decompress.c if (zds->inBuffSize < blockSize) { zds 2372 lib/zstd/decompress.c if (zds->outBuffSize < neededOutSize) { zds 2375 lib/zstd/decompress.c zds->blockSize = blockSize; zds 2377 lib/zstd/decompress.c zds->stage = zdss_read; zds 2382 lib/zstd/decompress.c size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds->dctx); zds 2384 lib/zstd/decompress.c zds->stage = zdss_init; zds 2389 lib/zstd/decompress.c const int isSkipFrame = ZSTD_isSkipFrame(zds->dctx); zds 2390 lib/zstd/decompress.c size_t const decodedSize = ZSTD_decompressContinue(zds->dctx, zds->outBuff + zds->outStart, zds 2391 lib/zstd/decompress.c (isSkipFrame ? 0 : zds->outBuffSize - zds->outStart), ip, neededInSize); zds 2397 lib/zstd/decompress.c zds->outEnd = zds->outStart + decodedSize; zds 2398 lib/zstd/decompress.c zds->stage = zdss_flush; zds 2405 lib/zstd/decompress.c zds->stage = zdss_load; zds 2411 lib/zstd/decompress.c size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds->dctx); zds 2412 lib/zstd/decompress.c size_t const toLoad = neededInSize - zds->inPos; /* should always be <= remaining space within inBuff */ zds 2414 lib/zstd/decompress.c if (toLoad > zds->inBuffSize - zds->inPos) zds 2416 lib/zstd/decompress.c loadedSize = ZSTD_limitCopy(zds->inBuff + zds->inPos, toLoad, ip, iend - ip); zds 2418 lib/zstd/decompress.c zds->inPos += loadedSize; zds 2426 lib/zstd/decompress.c const int isSkipFrame = ZSTD_isSkipFrame(zds->dctx); zds 2427 lib/zstd/decompress.c size_t const decodedSize = ZSTD_decompressContinue(zds->dctx, zds->outBuff + zds->outStart, zds->outBuffSize - zds->outStart, zds 2428 lib/zstd/decompress.c zds->inBuff, neededInSize); zds 2431 lib/zstd/decompress.c zds->inPos = 0; /* input is consumed */ zds 2433 lib/zstd/decompress.c zds->stage = zdss_read; zds 2436 lib/zstd/decompress.c zds->outEnd = zds->outStart + decodedSize; zds 2437 lib/zstd/decompress.c zds->stage = zdss_flush; zds 2444 lib/zstd/decompress.c size_t const toFlushSize = zds->outEnd - zds->outStart; zds 2445 lib/zstd/decompress.c size_t const flushedSize = ZSTD_limitCopy(op, oend - op, zds->outBuff + zds->outStart, toFlushSize); zds 2447 lib/zstd/decompress.c zds->outStart += flushedSize; zds 2449 lib/zstd/decompress.c zds->stage = zdss_read; zds 2450 lib/zstd/decompress.c if (zds->outStart + zds->blockSize > zds->outBuffSize) zds 2451 lib/zstd/decompress.c zds->outStart = zds->outEnd = 0; zds 2467 lib/zstd/decompress.c size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress(zds->dctx); zds 2469 lib/zstd/decompress.c if (zds->outEnd == zds->outStart) { /* output fully flushed */ zds 2470 lib/zstd/decompress.c if (zds->hostageByte) { zds 2472 lib/zstd/decompress.c zds->stage = zdss_read; zds 2479 lib/zstd/decompress.c if (!zds->hostageByte) { /* output not fully flushed; keep last byte as hostage; will be released when all output is flushed */ zds 2481 lib/zstd/decompress.c zds->hostageByte = 1; zds 2485 lib/zstd/decompress.c nextSrcSizeHint += ZSTD_blockHeaderSize * (ZSTD_nextInputType(zds->dctx) == ZSTDnit_block); /* preload header of next block */ zds 2486 lib/zstd/decompress.c if (zds->inPos > nextSrcSizeHint) zds 2488 lib/zstd/decompress.c nextSrcSizeHint -= zds->inPos; /* already loaded*/ zds 261 lib/zstd/zstd_internal.h size_t ZSTD_freeDStream(ZSTD_DStream *zds);