1/*
2 * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3 * All rights reserved.
4 *
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.
9 */
10
11
12
13/* *************************************
14* Dependencies
15***************************************/
16#define ZBUFF_STATIC_LINKING_ONLY
17#include "zbuff.h"
18
19
20ZBUFF_DCtx* ZBUFF_createDCtx(void)
21{
22 return ZSTD_createDStream();
23}
24
25ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
26{
27 return ZSTD_createDStream_advanced(customMem);
28}
29
30size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
31{
32 return ZSTD_freeDStream(zbd);
33}
34
35
36/* *** Initialization *** */
37
38size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
39{
40 return ZSTD_initDStream_usingDict(zbd, dict, dictSize);
41}
42
43size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
44{
45 return ZSTD_initDStream(zbd);
46}
47
48
49/* *** Decompression *** */
50
51size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
52 void* dst, size_t* dstCapacityPtr,
53 const void* src, size_t* srcSizePtr)
54{
55 ZSTD_outBuffer outBuff;
56 ZSTD_inBuffer inBuff;
57 size_t result;
58 outBuff.dst = dst;
59 outBuff.pos = 0;
60 outBuff.size = *dstCapacityPtr;
61 inBuff.src = src;
62 inBuff.pos = 0;
63 inBuff.size = *srcSizePtr;
64 result = ZSTD_decompressStream(zbd, &outBuff, &inBuff);
65 *dstCapacityPtr = outBuff.pos;
66 *srcSizePtr = inBuff.pos;
67 return result;
68}
69
70
71/* *************************************
72* Tool functions
73***************************************/
74size_t ZBUFF_recommendedDInSize(void) { return ZSTD_DStreamInSize(); }
75size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }
76