2 * Copyright (c) Meta Platforms, Inc. and affiliates.
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
8 * You may select, at your option, one of the above-listed licenses.
13 /* *************************************
15 ***************************************/
16 #define ZSTD_DISABLE_DEPRECATE_WARNINGS /* suppress warning on ZSTD_initDStream_usingDict */
17 #include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
18 #define ZBUFF_STATIC_LINKING_ONLY
22 ZBUFF_DCtx* ZBUFF_createDCtx(void)
24 return ZSTD_createDStream();
27 ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
29 return ZSTD_createDStream_advanced(customMem);
32 size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
34 return ZSTD_freeDStream(zbd);
38 /* *** Initialization *** */
40 size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
42 return ZSTD_initDStream_usingDict(zbd, dict, dictSize);
45 size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
47 return ZSTD_initDStream(zbd);
51 /* *** Decompression *** */
53 size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
54 void* dst, size_t* dstCapacityPtr,
55 const void* src, size_t* srcSizePtr)
57 ZSTD_outBuffer outBuff;
62 outBuff.size = *dstCapacityPtr;
65 inBuff.size = *srcSizePtr;
66 result = ZSTD_decompressStream(zbd, &outBuff, &inBuff);
67 *dstCapacityPtr = outBuff.pos;
68 *srcSizePtr = inBuff.pos;
73 /* *************************************
75 ***************************************/
76 size_t ZBUFF_recommendedDInSize(void) { return ZSTD_DStreamInSize(); }
77 size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }