comparison contrib/python-zstandard/zstd/deprecated/zbuff_decompress.c @ 37495:b1fb341d8a61

zstandard: vendor python-zstandard 0.9.0 This was just released. It features a number of goodies. More info at https://gregoryszorc.com/blog/2018/04/09/release-of-python-zstandard-0.9/. The clang-format ignore list was updated to reflect the new source of files. The project contains a vendored copy of zstandard 1.3.4. The old version was 1.1.3. One of the changes between those versions is that zstandard is now dual licensed BSD + GPLv2 and the patent rights grant has been removed. Good riddance. The API should be backwards compatible. So no changes in core should be needed. However, there were a number of changes in the library that we'll want to adapt to. Those will be addressed in subsequent commits. Differential Revision: https://phab.mercurial-scm.org/D3198
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 09 Apr 2018 10:13:29 -0700
parents
children
comparison
equal deleted inserted replaced
37494:1ce7a55b09d1 37495:b1fb341d8a61
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
20 ZBUFF_DCtx* ZBUFF_createDCtx(void)
21 {
22 return ZSTD_createDStream();
23 }
24
25 ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
26 {
27 return ZSTD_createDStream_advanced(customMem);
28 }
29
30 size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
31 {
32 return ZSTD_freeDStream(zbd);
33 }
34
35
36 /* *** Initialization *** */
37
38 size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
39 {
40 return ZSTD_initDStream_usingDict(zbd, dict, dictSize);
41 }
42
43 size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
44 {
45 return ZSTD_initDStream(zbd);
46 }
47
48
49 /* *** Decompression *** */
50
51 size_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 ***************************************/
74 size_t ZBUFF_recommendedDInSize(void) { return ZSTD_DStreamInSize(); }
75 size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }