Constifying, malloc check and naming nit

This commit is contained in:
Bimba Shrestha 2019-12-17 17:16:51 -08:00
parent 989ce13e19
commit 56415efc76
2 changed files with 11 additions and 10 deletions

View File

@ -2568,7 +2568,7 @@ static size_t ZSTD_compress_frameChunk (ZSTD_CCtx* cctx,
* greater than the optimistic number of blocks we still have remaining. * greater than the optimistic number of blocks we still have remaining.
* This might be UNset when data is uncompressable and we're streaming. */ * This might be UNset when data is uncompressable and we're streaming. */
int enoughDstCapacityForNoCompressSuperBlocks = const int enoughDstCapacityForNoCompressSuperBlocks =
(dstCapacity / (blockSize + 7 /* header + checksum */)) > (srcSize / blockSize); (dstCapacity / (blockSize + 7 /* header + checksum */)) > (srcSize / blockSize);
assert(cctx->appliedParams.cParams.windowLog <= ZSTD_WINDOWLOG_MAX); assert(cctx->appliedParams.cParams.windowLog <= ZSTD_WINDOWLOG_MAX);

View File

@ -489,10 +489,10 @@ static int basicUnitTests(U32 const seed, double compressibility)
} }
DISPLAYLEVEL(3, "OK \n"); DISPLAYLEVEL(3, "OK \n");
DISPLAYLEVEL(3, "test%3d: superblock uncompressable data, too many nocompress superblocks : ", testNb++) DISPLAYLEVEL(3, "test%3d: superblock uncompressible data, too many nocompress superblocks : ", testNb++)
{ {
ZSTD_CCtx* cctx = ZSTD_createCCtx(); ZSTD_CCtx* const cctx = ZSTD_createCCtx();
BYTE* src = (BYTE*)CNBuffer; BYTE* dst = (BYTE*)compressedBuffer; const BYTE* src = (BYTE*)CNBuffer; BYTE* dst = (BYTE*)compressedBuffer;
size_t srcSize = 321656; size_t dstCapacity = ZSTD_compressBound(srcSize); size_t srcSize = 321656; size_t dstCapacity = ZSTD_compressBound(srcSize);
/* This is the number of bytes to stream before ending. This value /* This is the number of bytes to stream before ending. This value
@ -501,20 +501,21 @@ static int basicUnitTests(U32 const seed, double compressibility)
const size_t streamCompressThreshold = 161792; const size_t streamCompressThreshold = 161792;
const size_t streamCompressDelta = 1024; const size_t streamCompressDelta = 1024;
/* The first 1/3 of the buffer is compressable and the last 2/3 is /* The first 1/3 of the buffer is compressible and the last 2/3 is
* uncompressable. This is an approximation of the type of data * uncompressible. This is an approximation of the type of data
* the fuzzer generated to catch this bug. Streams like this were making * the fuzzer generated to catch this bug. Streams like this were making
* zstd generate noCompress superblocks (which are larger than the src * zstd generate noCompress superblocks (which are larger than the src
* they come from). Do this enough times, and we'll run out of room * they come from). Do this enough times, and we'll run out of room
* and throw a dstSize_tooSmall error. */ * and throw a dstSize_tooSmall error. */
const size_t compressablePartSize = srcSize/3; const size_t compressiblePartSize = srcSize/3;
const size_t uncompressablePartSize = srcSize-compressablePartSize; const size_t uncompressiblePartSize = srcSize-compressiblePartSize;
RDG_genBuffer(CNBuffer, compressablePartSize, 0.5, 0.5, seed); RDG_genBuffer(CNBuffer, compressiblePartSize, 0.5, 0.5, seed);
RDG_genBuffer((BYTE*)CNBuffer+compressablePartSize, uncompressablePartSize, 0, 0, seed); RDG_genBuffer((BYTE*)CNBuffer+compressiblePartSize, uncompressiblePartSize, 0, 0, seed);
/* Setting target block size so that superblock is used */ /* Setting target block size so that superblock is used */
assert(cctx != NULL);
ZSTD_CCtx_setParameter(cctx, ZSTD_c_targetCBlockSize, 81); ZSTD_CCtx_setParameter(cctx, ZSTD_c_targetCBlockSize, 81);
{ size_t read; { size_t read;