Fixed minor visual analyzer warning

This commit is contained in:
Yann Collet
2015-07-07 17:26:17 -08:00
parent 968f275981
commit 8b48b24821
3 changed files with 16 additions and 11 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ endif
default: zstd default: zstd
all: zstd zstd32 fullbench fullbench32 fuzzer fuzzer32 all: zstd zstd32 fullbench fullbench32 fuzzer fuzzer32 datagen
zstd: $(ZSTDDIR)/zstd.c xxhash.c bench.c fileio.c zstdcli.c zstd: $(ZSTDDIR)/zstd.c xxhash.c bench.c fileio.c zstdcli.c
$(CC) $(FLAGS) $^ -o $@$(EXT) $(CC) $(FLAGS) $^ -o $@$(EXT)
+9 -4
View File
@@ -130,7 +130,6 @@ static BYTE RDG_genChar(U32* seed, const litDistribTable lt)
} }
#define RDG_DICTSIZE (32 KB)
#define RDG_RAND15BITS ((RDG_rand(seed) >> 3) & 32767) #define RDG_RAND15BITS ((RDG_rand(seed) >> 3) & 32767)
#define RDG_RANDLENGTH ( ((RDG_rand(seed) >> 7) & 7) ? (RDG_rand(seed) & 15) : (RDG_rand(seed) & 511) + 15) #define RDG_RANDLENGTH ( ((RDG_rand(seed) >> 7) & 7) ? (RDG_rand(seed) & 15) : (RDG_rand(seed) & 511) + 15)
void RDG_genBlock(void* buffer, size_t buffSize, size_t prefixSize, double matchProba, litDistribTable lt, unsigned* seedPtr) void RDG_genBlock(void* buffer, size_t buffSize, size_t prefixSize, double matchProba, litDistribTable lt, unsigned* seedPtr)
@@ -140,7 +139,7 @@ void RDG_genBlock(void* buffer, size_t buffSize, size_t prefixSize, double match
size_t pos = prefixSize; size_t pos = prefixSize;
U32* seed = seedPtr; U32* seed = seedPtr;
/* special case */ /* special case : sparse content */
while (matchProba >= 1.0) while (matchProba >= 1.0)
{ {
size_t size0 = RDG_rand(seed) & 3; size_t size0 = RDG_rand(seed) & 3;
@@ -154,6 +153,7 @@ void RDG_genBlock(void* buffer, size_t buffSize, size_t prefixSize, double match
memset(buffPtr+pos, 0, size0); memset(buffPtr+pos, 0, size0);
pos += size0; pos += size0;
buffPtr[pos-1] = RDG_genChar(seed, lt); buffPtr[pos-1] = RDG_genChar(seed, lt);
return;
} }
/* init */ /* init */
@@ -198,20 +198,22 @@ void RDG_genBuffer(void* buffer, size_t size, double matchProba, double litProba
} }
#define RDG_DICTSIZE (32 KB)
#define RDG_BLOCKSIZE (128 KB) #define RDG_BLOCKSIZE (128 KB)
void RDG_genOut(unsigned long long size, double matchProba, double litProba, unsigned seed) void RDG_genOut(unsigned long long size, double matchProba, double litProba, unsigned seed)
{ {
BYTE buff[RDG_DICTSIZE + RDG_BLOCKSIZE]; BYTE* buff = (BYTE*)malloc(RDG_DICTSIZE + RDG_BLOCKSIZE);
U64 total = 0; U64 total = 0;
size_t genBlockSize = RDG_BLOCKSIZE; size_t genBlockSize = RDG_BLOCKSIZE;
litDistribTable lt; litDistribTable lt;
/* init */ /* init */
if (buff==NULL) { fprintf(stdout, "not enough memory\n"); exit(1); }
if (litProba==0.0) litProba = matchProba / 4.5; if (litProba==0.0) litProba = matchProba / 4.5;
RDG_fillLiteralDistrib(lt, litProba); RDG_fillLiteralDistrib(lt, litProba);
SET_BINARY_MODE(stdout); SET_BINARY_MODE(stdout);
/* Generate dict */ /* Generate initial dict */
RDG_genBlock(buff, RDG_DICTSIZE, 0, matchProba, lt, &seed); RDG_genBlock(buff, RDG_DICTSIZE, 0, matchProba, lt, &seed);
/* Generate compressible data */ /* Generate compressible data */
@@ -224,4 +226,7 @@ void RDG_genOut(unsigned long long size, double matchProba, double litProba, uns
/* update dict */ /* update dict */
memcpy(buff, buff + RDG_BLOCKSIZE, RDG_DICTSIZE); memcpy(buff, buff + RDG_BLOCKSIZE, RDG_DICTSIZE);
} }
// cleanup
free(buff);
} }
+6 -6
View File
@@ -28,13 +28,13 @@
void RDG_genOut(unsigned long long size, double matchProba, double litProba, unsigned seed); void RDG_genOut(unsigned long long size, double matchProba, double litProba, unsigned seed);
void RDG_genBuffer(void* buffer, size_t size, double matchProba, double litProba, unsigned seed); void RDG_genBuffer(void* buffer, size_t size, double matchProba, double litProba, unsigned seed);
/* RDG_genOut /* RDG_genBuffer
Generate 'size' bytes of compressible data into stdout. Generate 'size' bytes of compressible data into 'buffer'.
Compressibility can be controlled using 'matchProba'. Compressibility can be controlled using 'matchProba'.
'LitProba' is optional, and affect variability of bytes. If litProba==0.0, default value is used. 'LitProba' is optional, and affect variability of individual bytes. If litProba==0.0, default value is used.
Generated data can be selected using 'seed'. Generated data pattern can be modified using different 'seed'.
If (matchProba, litProba and seed) are equal, the function always generate the same content. If (matchProba, litProba and seed) are equal, the function always generate the same content.
RDG_genBuffer RDG_genOut
Same as RDG_genOut, but generate data into provided buffer Same as RDG_genBuffer, but generate data towards stdout
*/ */