summaryrefslogtreecommitdiffstats
path: root/contrib/libs/zstd/lib/legacy/zstd_v07.c
diff options
context:
space:
mode:
authorAlexey Bykov <[email protected]>2022-02-10 16:47:16 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:47:16 +0300
commit4cadece7a57ab767e762a0bea1995a596aefeb11 (patch)
tree7649c16cf4b52e994709f6c9e1716c993ca28759 /contrib/libs/zstd/lib/legacy/zstd_v07.c
parent143876304996506751ade0b80b3c47f188b9834f (diff)
Restoring authorship annotation for Alexey Bykov <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/zstd/lib/legacy/zstd_v07.c')
-rw-r--r--contrib/libs/zstd/lib/legacy/zstd_v07.c120
1 files changed, 60 insertions, 60 deletions
diff --git a/contrib/libs/zstd/lib/legacy/zstd_v07.c b/contrib/libs/zstd/lib/legacy/zstd_v07.c
index 189f6ede69f..f6c5bcaa4c5 100644
--- a/contrib/libs/zstd/lib/legacy/zstd_v07.c
+++ b/contrib/libs/zstd/lib/legacy/zstd_v07.c
@@ -2628,7 +2628,7 @@ const char* ZBUFFv07_getErrorName(size_t errorCode) { return ERR_getErrorName(er
-static void* ZSTDv07_defaultAllocFunction(void* opaque, size_t size)
+static void* ZSTDv07_defaultAllocFunction(void* opaque, size_t size)
{
void* address = malloc(size);
(void)opaque;
@@ -2636,7 +2636,7 @@ static void* ZSTDv07_defaultAllocFunction(void* opaque, size_t size)
return address;
}
-static void ZSTDv07_defaultFreeFunction(void* opaque, void* address)
+static void ZSTDv07_defaultFreeFunction(void* opaque, void* address)
{
(void)opaque;
/* if (address) printf("free %p opaque=%p \n", address, opaque); */
@@ -2740,8 +2740,8 @@ typedef enum { lbt_huffman, lbt_repeat, lbt_raw, lbt_rle } litBlockType_t;
#define FSEv07_ENCODING_STATIC 2
#define FSEv07_ENCODING_DYNAMIC 3
-#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
-
+#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
+
static const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 2, 2, 3, 3, 4, 6, 7, 8, 9,10,11,12,
13,14,15,16 };
@@ -3152,7 +3152,7 @@ size_t ZSTDv07_getFrameParams(ZSTDv07_frameParams* fparamsPtr, const void* src,
const BYTE* ip = (const BYTE*)src;
if (srcSize < ZSTDv07_frameHeaderSize_min) return ZSTDv07_frameHeaderSize_min;
- memset(fparamsPtr, 0, sizeof(*fparamsPtr));
+ memset(fparamsPtr, 0, sizeof(*fparamsPtr));
if (MEM_readLE32(src) != ZSTDv07_MAGICNUMBER) {
if ((MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTDv07_MAGIC_SKIPPABLE_START) {
if (srcSize < ZSTDv07_skippableHeaderSize) return ZSTDv07_skippableHeaderSize; /* magic number + skippable frame length */
@@ -3177,13 +3177,13 @@ size_t ZSTDv07_getFrameParams(ZSTDv07_frameParams* fparamsPtr, const void* src,
U32 windowSize = 0;
U32 dictID = 0;
U64 frameContentSize = 0;
- if ((fhdByte & 0x08) != 0) /* reserved bits, which must be zero */
- return ERROR(frameParameter_unsupported);
+ if ((fhdByte & 0x08) != 0) /* reserved bits, which must be zero */
+ return ERROR(frameParameter_unsupported);
if (!directMode) {
BYTE const wlByte = ip[pos++];
U32 const windowLog = (wlByte >> 3) + ZSTDv07_WINDOWLOG_ABSOLUTEMIN;
- if (windowLog > ZSTDv07_WINDOWLOG_MAX)
- return ERROR(frameParameter_unsupported);
+ if (windowLog > ZSTDv07_WINDOWLOG_MAX)
+ return ERROR(frameParameter_unsupported);
windowSize = (1U << windowLog);
windowSize += (windowSize >> 3) * (wlByte&7);
}
@@ -3205,8 +3205,8 @@ size_t ZSTDv07_getFrameParams(ZSTDv07_frameParams* fparamsPtr, const void* src,
case 3 : frameContentSize = MEM_readLE64(ip+pos); break;
}
if (!windowSize) windowSize = (U32)frameContentSize;
- if (windowSize > windowSizeMax)
- return ERROR(frameParameter_unsupported);
+ if (windowSize > windowSizeMax)
+ return ERROR(frameParameter_unsupported);
fparamsPtr->frameContentSize = frameContentSize;
fparamsPtr->windowSize = windowSize;
fparamsPtr->dictID = dictID;
@@ -3225,10 +3225,10 @@ size_t ZSTDv07_getFrameParams(ZSTDv07_frameParams* fparamsPtr, const void* src,
- frame header not completely provided (`srcSize` too small) */
unsigned long long ZSTDv07_getDecompressedSize(const void* src, size_t srcSize)
{
- ZSTDv07_frameParams fparams;
- size_t const frResult = ZSTDv07_getFrameParams(&fparams, src, srcSize);
- if (frResult!=0) return 0;
- return fparams.frameContentSize;
+ ZSTDv07_frameParams fparams;
+ size_t const frResult = ZSTDv07_getFrameParams(&fparams, src, srcSize);
+ if (frResult!=0) return 0;
+ return fparams.frameContentSize;
}
@@ -3252,7 +3252,7 @@ typedef struct
/*! ZSTDv07_getcBlockSize() :
* Provides the size of compressed block from block header `src` */
-static size_t ZSTDv07_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr)
+static size_t ZSTDv07_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr)
{
const BYTE* const in = (const BYTE*)src;
U32 cSize;
@@ -3281,7 +3281,7 @@ static size_t ZSTDv07_copyRawBlock(void* dst, size_t dstCapacity, const void* sr
/*! ZSTDv07_decodeLiteralsBlock() :
@return : nb of bytes read from src (< srcSize ) */
-static size_t ZSTDv07_decodeLiteralsBlock(ZSTDv07_DCtx* dctx,
+static size_t ZSTDv07_decodeLiteralsBlock(ZSTDv07_DCtx* dctx,
const void* src, size_t srcSize) /* note : srcSize < BLOCKSIZE */
{
const BYTE* const istart = (const BYTE*) src;
@@ -3415,7 +3415,7 @@ static size_t ZSTDv07_decodeLiteralsBlock(ZSTDv07_DCtx* dctx,
@return : nb bytes read from src,
or an error code if it fails, testable with ZSTDv07_isError()
*/
-static size_t ZSTDv07_buildSeqTable(FSEv07_DTable* DTable, U32 type, U32 max, U32 maxLog,
+static size_t ZSTDv07_buildSeqTable(FSEv07_DTable* DTable, U32 type, U32 max, U32 maxLog,
const void* src, size_t srcSize,
const S16* defaultNorm, U32 defaultLog, U32 flagRepeatTable)
{
@@ -3445,7 +3445,7 @@ static size_t ZSTDv07_buildSeqTable(FSEv07_DTable* DTable, U32 type, U32 max, U3
}
-static size_t ZSTDv07_decodeSeqHeaders(int* nbSeqPtr,
+static size_t ZSTDv07_decodeSeqHeaders(int* nbSeqPtr,
FSEv07_DTable* DTableLL, FSEv07_DTable* DTableML, FSEv07_DTable* DTableOffb, U32 flagRepeatTable,
const void* src, size_t srcSize)
{
@@ -3633,7 +3633,7 @@ size_t ZSTDv07_execSequence(BYTE* op,
if (sequence.offset < 8) {
/* close range match, overlap */
static const U32 dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; /* added */
- static const int dec64table[] = { 8, 8, 8, 7, 8, 9,10,11 }; /* subtracted */
+ static const int dec64table[] = { 8, 8, 8, 7, 8, 9,10,11 }; /* subtracted */
int const sub2 = dec64table[sequence.offset];
op[0] = match[0];
op[1] = match[1];
@@ -3777,7 +3777,7 @@ ZSTDLIBv07_API size_t ZSTDv07_insertBlock(ZSTDv07_DCtx* dctx, const void* blockS
}
-static size_t ZSTDv07_generateNxBytes(void* dst, size_t dstCapacity, BYTE byte, size_t length)
+static size_t ZSTDv07_generateNxBytes(void* dst, size_t dstCapacity, BYTE byte, size_t length)
{
if (length > dstCapacity) return ERROR(dstSize_tooSmall);
if (length > 0) {
@@ -3859,7 +3859,7 @@ static size_t ZSTDv07_decompressFrame(ZSTDv07_DCtx* dctx,
* It avoids reloading the dictionary each time.
* `preparedDCtx` must have been properly initialized using ZSTDv07_decompressBegin_usingDict().
* Requires 2 contexts : 1 for reference (preparedDCtx), which will not be modified, and 1 to run the decompression operation (dctx) */
-static size_t ZSTDv07_decompress_usingPreparedDCtx(ZSTDv07_DCtx* dctx, const ZSTDv07_DCtx* refDCtx,
+static size_t ZSTDv07_decompress_usingPreparedDCtx(ZSTDv07_DCtx* dctx, const ZSTDv07_DCtx* refDCtx,
void* dst, size_t dstCapacity,
const void* src, size_t srcSize)
{
@@ -3901,40 +3901,40 @@ size_t ZSTDv07_decompress(void* dst, size_t dstCapacity, const void* src, size_t
#endif
}
-/* ZSTD_errorFrameSizeInfoLegacy() :
- assumes `cSize` and `dBound` are _not_ NULL */
-static void ZSTD_errorFrameSizeInfoLegacy(size_t* cSize, unsigned long long* dBound, size_t ret)
-{
- *cSize = ret;
- *dBound = ZSTD_CONTENTSIZE_ERROR;
-}
-
-void ZSTDv07_findFrameSizeInfoLegacy(const void *src, size_t srcSize, size_t* cSize, unsigned long long* dBound)
+/* ZSTD_errorFrameSizeInfoLegacy() :
+ assumes `cSize` and `dBound` are _not_ NULL */
+static void ZSTD_errorFrameSizeInfoLegacy(size_t* cSize, unsigned long long* dBound, size_t ret)
{
+ *cSize = ret;
+ *dBound = ZSTD_CONTENTSIZE_ERROR;
+}
+
+void ZSTDv07_findFrameSizeInfoLegacy(const void *src, size_t srcSize, size_t* cSize, unsigned long long* dBound)
+{
const BYTE* ip = (const BYTE*)src;
size_t remainingSize = srcSize;
- size_t nbBlocks = 0;
+ size_t nbBlocks = 0;
/* check */
- if (srcSize < ZSTDv07_frameHeaderSize_min+ZSTDv07_blockHeaderSize) {
- ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(srcSize_wrong));
- return;
- }
+ if (srcSize < ZSTDv07_frameHeaderSize_min+ZSTDv07_blockHeaderSize) {
+ ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(srcSize_wrong));
+ return;
+ }
/* Frame Header */
{ size_t const frameHeaderSize = ZSTDv07_frameHeaderSize(src, srcSize);
- if (ZSTDv07_isError(frameHeaderSize)) {
- ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, frameHeaderSize);
- return;
- }
- if (MEM_readLE32(src) != ZSTDv07_MAGICNUMBER) {
- ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(prefix_unknown));
- return;
- }
- if (srcSize < frameHeaderSize+ZSTDv07_blockHeaderSize) {
- ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(srcSize_wrong));
- return;
- }
+ if (ZSTDv07_isError(frameHeaderSize)) {
+ ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, frameHeaderSize);
+ return;
+ }
+ if (MEM_readLE32(src) != ZSTDv07_MAGICNUMBER) {
+ ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(prefix_unknown));
+ return;
+ }
+ if (srcSize < frameHeaderSize+ZSTDv07_blockHeaderSize) {
+ ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(srcSize_wrong));
+ return;
+ }
ip += frameHeaderSize; remainingSize -= frameHeaderSize;
}
@@ -3942,28 +3942,28 @@ void ZSTDv07_findFrameSizeInfoLegacy(const void *src, size_t srcSize, size_t* cS
while (1) {
blockProperties_t blockProperties;
size_t const cBlockSize = ZSTDv07_getcBlockSize(ip, remainingSize, &blockProperties);
- if (ZSTDv07_isError(cBlockSize)) {
- ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, cBlockSize);
- return;
- }
+ if (ZSTDv07_isError(cBlockSize)) {
+ ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, cBlockSize);
+ return;
+ }
ip += ZSTDv07_blockHeaderSize;
remainingSize -= ZSTDv07_blockHeaderSize;
if (blockProperties.blockType == bt_end) break;
- if (cBlockSize > remainingSize) {
- ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(srcSize_wrong));
- return;
- }
+ if (cBlockSize > remainingSize) {
+ ZSTD_errorFrameSizeInfoLegacy(cSize, dBound, ERROR(srcSize_wrong));
+ return;
+ }
ip += cBlockSize;
remainingSize -= cBlockSize;
- nbBlocks++;
+ nbBlocks++;
}
- *cSize = ip - (const BYTE*)src;
- *dBound = nbBlocks * ZSTDv07_BLOCKSIZE_ABSOLUTEMAX;
+ *cSize = ip - (const BYTE*)src;
+ *dBound = nbBlocks * ZSTDv07_BLOCKSIZE_ABSOLUTEMAX;
}
/*_******************************
@@ -4183,7 +4183,7 @@ struct ZSTDv07_DDict_s {
ZSTDv07_DCtx* refContext;
}; /* typedef'd tp ZSTDv07_CDict within zstd.h */
-static ZSTDv07_DDict* ZSTDv07_createDDict_advanced(const void* dict, size_t dictSize, ZSTDv07_customMem customMem)
+static ZSTDv07_DDict* ZSTDv07_createDDict_advanced(const void* dict, size_t dictSize, ZSTDv07_customMem customMem)
{
if (!customMem.customAlloc && !customMem.customFree)
customMem = defaultCustomMem;