mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
minor refactor
This commit is contained in:
@ -193,26 +193,26 @@ void RDG_genBuffer(void* buffer, size_t size, double matchProba, double litProba
|
|||||||
|
|
||||||
#define RDG_DICTSIZE (32 KB)
|
#define RDG_DICTSIZE (32 KB)
|
||||||
#define RDG_BLOCKSIZE (128 KB)
|
#define RDG_BLOCKSIZE (128 KB)
|
||||||
|
#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
|
||||||
void RDG_genStdout(unsigned long long size, double matchProba, double litProba, unsigned seed)
|
void RDG_genStdout(unsigned long long size, double matchProba, double litProba, unsigned seed)
|
||||||
{
|
{
|
||||||
BYTE* buff = (BYTE*)malloc(RDG_DICTSIZE + RDG_BLOCKSIZE);
|
BYTE* buff = (BYTE*)malloc(RDG_DICTSIZE + RDG_BLOCKSIZE);
|
||||||
U64 total = 0;
|
U64 total = 0;
|
||||||
size_t genBlockSize = RDG_BLOCKSIZE;
|
litDistribTable ldt;
|
||||||
litDistribTable lt;
|
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
if (buff==NULL) { fprintf(stdout, "not enough memory\n"); exit(1); }
|
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(ldt, litProba);
|
||||||
SET_BINARY_MODE(stdout);
|
SET_BINARY_MODE(stdout);
|
||||||
|
|
||||||
/* Generate initial dict */
|
/* Generate initial dict */
|
||||||
RDG_genBlock(buff, RDG_DICTSIZE, 0, matchProba, lt, &seed);
|
RDG_genBlock(buff, RDG_DICTSIZE, 0, matchProba, ldt, &seed);
|
||||||
|
|
||||||
/* Generate compressible data */
|
/* Generate compressible data */
|
||||||
while (total < size) {
|
while (total < size) {
|
||||||
RDG_genBlock(buff, RDG_DICTSIZE+RDG_BLOCKSIZE, RDG_DICTSIZE, matchProba, lt, &seed);
|
size_t const genBlockSize = MIN (RDG_BLOCKSIZE, size-total);
|
||||||
if (size-total < RDG_BLOCKSIZE) genBlockSize = (size_t)(size-total);
|
RDG_genBlock(buff, RDG_DICTSIZE+RDG_BLOCKSIZE, RDG_DICTSIZE, matchProba, ldt, &seed);
|
||||||
total += genBlockSize;
|
total += genBlockSize;
|
||||||
{ size_t const unused = fwrite(buff, 1, genBlockSize, stdout); (void)unused; }
|
{ size_t const unused = fwrite(buff, 1, genBlockSize, stdout); (void)unused; }
|
||||||
/* update dict */
|
/* update dict */
|
||||||
|
Reference in New Issue
Block a user