Rizin
unix-like reverse engineering framework and cli tools
datagen.h File Reference
#include <stddef.h>

Go to the source code of this file.

Functions

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)
 

Function Documentation

◆ RDG_genBuffer()

void RDG_genBuffer ( void *  buffer,
size_t  size,
double  matchProba,
double  litProba,
unsigned  seed 
)

Definition at line 155 of file datagen.c.

156 {
158  if (litProba==0.0) litProba = matchProba / 4.5;
159  RDG_fillLiteralDistrib(lt, litProba);
160  RDG_genBlock(buffer, size, 0, matchProba, lt, &seed);
161 }
void RDG_genBlock(void *buffer, size_t buffSize, size_t prefixSize, double matchProba, litDistribTable lt, unsigned *seedPtr)
Definition: datagen.c:102
BYTE litDistribTable[LTSIZE]
Definition: datagen.c:52
static void RDG_fillLiteralDistrib(litDistribTable lt, double ld)
Definition: datagen.c:72
voidpf void uLong size
Definition: ioapi.h:138
Definition: buffer.h:15

References lt, RDG_fillLiteralDistrib(), and RDG_genBlock().

Referenced by BMK_benchMem(), and BMK_syntheticTest().

◆ RDG_genOut()

void RDG_genOut ( unsigned long long  size,
double  matchProba,
double  litProba,
unsigned  seed 
)

Definition at line 165 of file datagen.c.

166 {
168  U64 total = 0;
169  size_t genBlockSize = RDG_BLOCKSIZE;
171 
172  /* init */
173  if (litProba==0.0) litProba = matchProba / 4.5;
174  RDG_fillLiteralDistrib(lt, litProba);
175  SET_BINARY_MODE(stdout);
176 
177  /* Generate dict */
178  RDG_genBlock(buff, RDG_DICTSIZE, 0, matchProba, lt, &seed);
179 
180  /* Generate compressible data */
181  while (total < size) {
182  RDG_genBlock(buff, RDG_DICTSIZE+RDG_BLOCKSIZE, RDG_DICTSIZE, matchProba, lt, &seed);
183  if (size-total < RDG_BLOCKSIZE) genBlockSize = (size_t)(size-total);
184  total += genBlockSize;
185  fwrite(buff, 1, genBlockSize, stdout); /* should check potential write error */
186  /* update dict */
187  memcpy(buff, buff + RDG_BLOCKSIZE, RDG_DICTSIZE);
188  }
189 }
#define RDG_BLOCKSIZE
Definition: datagen.c:164
#define RDG_DICTSIZE
Definition: datagen.c:99
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
#define SET_BINARY_MODE(file)
Definition: platform.h:145
unsigned long long U64
Definition: lz4.c:290
unsigned char BYTE
Definition: lz4.c:286
int size_t
Definition: sftypes.h:40

References lt, memcpy(), RDG_BLOCKSIZE, RDG_DICTSIZE, RDG_fillLiteralDistrib(), RDG_genBlock(), and SET_BINARY_MODE.

Referenced by main().