Coverage Report

Created: 2026-04-01 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/perfetto/buildtools/zstd/lib/deprecated/zbuff_decompress.c
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
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 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
19
#include "zbuff.h"
20
21
22
ZBUFF_DCtx* ZBUFF_createDCtx(void)
23
0
{
24
0
    return ZSTD_createDStream();
25
0
}
26
27
ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
28
0
{
29
0
    return ZSTD_createDStream_advanced(customMem);
30
0
}
31
32
size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
33
0
{
34
0
    return ZSTD_freeDStream(zbd);
35
0
}
36
37
38
/* *** Initialization *** */
39
40
size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
41
0
{
42
0
    return ZSTD_initDStream_usingDict(zbd, dict, dictSize);
43
0
}
44
45
size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
46
0
{
47
0
    return ZSTD_initDStream(zbd);
48
0
}
49
50
51
/* *** Decompression *** */
52
53
size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
54
                                void* dst, size_t* dstCapacityPtr,
55
                          const void* src, size_t* srcSizePtr)
56
0
{
57
0
    ZSTD_outBuffer outBuff;
58
0
    ZSTD_inBuffer inBuff;
59
0
    size_t result;
60
0
    outBuff.dst  = dst;
61
0
    outBuff.pos  = 0;
62
0
    outBuff.size = *dstCapacityPtr;
63
0
    inBuff.src  = src;
64
0
    inBuff.pos  = 0;
65
0
    inBuff.size = *srcSizePtr;
66
0
    result = ZSTD_decompressStream(zbd, &outBuff, &inBuff);
67
0
    *dstCapacityPtr = outBuff.pos;
68
0
    *srcSizePtr = inBuff.pos;
69
0
    return result;
70
0
}
71
72
73
/* *************************************
74
*  Tool functions
75
***************************************/
76
0
size_t ZBUFF_recommendedDInSize(void)  { return ZSTD_DStreamInSize(); }
77
0
size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }