Path: blob/master/Utilities/cmzstd/lib/deprecated/zbuff_decompress.c
3156 views
/*1* Copyright (c) Meta Platforms, Inc. and affiliates.2* All rights reserved.3*4* This source code is licensed under both the BSD-style license (found in the5* LICENSE file in the root directory of this source tree) and the GPLv2 (found6* in the COPYING file in the root directory of this source tree).7* You may select, at your option, one of the above-listed licenses.8*/9101112/* *************************************13* Dependencies14***************************************/15#define ZSTD_DISABLE_DEPRECATE_WARNINGS /* suppress warning on ZSTD_initDStream_usingDict */16#include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */17#define ZBUFF_STATIC_LINKING_ONLY18#include "zbuff.h"192021ZBUFF_DCtx* ZBUFF_createDCtx(void)22{23return ZSTD_createDStream();24}2526ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)27{28return ZSTD_createDStream_advanced(customMem);29}3031size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)32{33return ZSTD_freeDStream(zbd);34}353637/* *** Initialization *** */3839size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)40{41return ZSTD_initDStream_usingDict(zbd, dict, dictSize);42}4344size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)45{46return ZSTD_initDStream(zbd);47}484950/* *** Decompression *** */5152size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,53void* dst, size_t* dstCapacityPtr,54const void* src, size_t* srcSizePtr)55{56ZSTD_outBuffer outBuff;57ZSTD_inBuffer inBuff;58size_t result;59outBuff.dst = dst;60outBuff.pos = 0;61outBuff.size = *dstCapacityPtr;62inBuff.src = src;63inBuff.pos = 0;64inBuff.size = *srcSizePtr;65result = ZSTD_decompressStream(zbd, &outBuff, &inBuff);66*dstCapacityPtr = outBuff.pos;67*srcSizePtr = inBuff.pos;68return result;69}707172/* *************************************73* Tool functions74***************************************/75size_t ZBUFF_recommendedDInSize(void) { return ZSTD_DStreamInSize(); }76size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }777879