(U32)(count.totalMalloc >> 10));
}
--static int FUZ_mallocTests(unsigned seed, double compressibility, unsigned part)
++static int FUZ_mallocTests_internal(unsigned seed, double compressibility, unsigned part,
++ void* inBuffer, size_t inSize, void* outBuffer, size_t outSize)
{
-- size_t const inSize = 64 MB + 16 MB + 4 MB + 1 MB + 256 KB + 64 KB; /* 85.3 MB */
-- size_t const outSize = ZSTD_compressBound(inSize);
-- void* const inBuffer = malloc(inSize);
-- void* const outBuffer = malloc(outSize);
--
/* test only played in verbose mode, as they are long */
if (g_displayLevel<3) return 0;
return 0;
}
++static int FUZ_mallocTests(unsigned seed, double compressibility, unsigned part)
++{
++ size_t const inSize = 64 MB + 16 MB + 4 MB + 1 MB + 256 KB + 64 KB; /* 85.3 MB */
++ size_t const outSize = ZSTD_compressBound(inSize);
++ void* const inBuffer = malloc(inSize);
++ void* const outBuffer = malloc(outSize);
++ int result;
++
++ /* Create compressible noise */
++ if (!inBuffer || !outBuffer) {
++ DISPLAY("Not enough memory, aborting \n");
++ exit(1);
++ }
++
++ result = FUZ_mallocTests_internal(seed, compressibility, part,
++ inBuffer, inSize, outBuffer, outSize);
++
++ free(inBuffer);
++ free(outBuffer);
++ return result;
++}
++
#else
static int FUZ_mallocTests(unsigned seed, double compressibility, unsigned part)
size_t const dstBufferSize = (size_t)1<<maxSampleLog;
size_t const cBufferSize = ZSTD_compressBound(dstBufferSize);
BYTE* cNoiseBuffer[5];
-- BYTE* srcBuffer; /* jumping pointer */
BYTE* const cBuffer = (BYTE*) malloc (cBufferSize);
BYTE* const dstBuffer = (BYTE*) malloc (dstBufferSize);
BYTE* const mirrorBuffer = (BYTE*) malloc (dstBufferSize);
ZSTD_DCtx* const dctx = ZSTD_createDCtx();
U32 result = 0;
U32 testNb = 0;
-- U32 coreSeed = seed, lseed = 0;
++ U32 coreSeed = seed;
UTIL_time_t const startClock = UTIL_getTime();
U64 const maxClockSpan = maxDurationS * SEC_TO_MICRO;
int const cLevelLimiter = bigTests ? 3 : 2;
RDG_genBuffer(cNoiseBuffer[2], srcBufferSize, compressibility, 0., coreSeed);
RDG_genBuffer(cNoiseBuffer[3], srcBufferSize, 0.95, 0., coreSeed); /* highly compressible */
RDG_genBuffer(cNoiseBuffer[4], srcBufferSize, 1.00, 0., coreSeed); /* sparse content */
-- srcBuffer = cNoiseBuffer[2];
/* catch up testNb */
for (testNb=1; testNb < startTest; testNb++) FUZ_rand(&coreSeed);
/* main test loop */
for ( ; (testNb <= nbTests) || (UTIL_clockSpanMicro(startClock) < maxClockSpan); testNb++ ) {
++ BYTE* srcBuffer; /* jumping pointer */
++ U32 lseed;
size_t sampleSize, maxTestSize, totalTestSize;
size_t cSize, totalCSize, totalGenSize;
U64 crcOrig;
CHECK (totalGenSize != totalTestSize, "streaming decompressed data : wrong size")
CHECK (totalCSize != cSize, "compressed data should be fully read")
{ U64 const crcDest = XXH64(dstBuffer, totalTestSize, 0);
-- if (crcDest!=crcOrig) {
-- size_t const errorPos = findDiff(mirrorBuffer, dstBuffer, totalTestSize);
-- CHECK (1, "streaming decompressed data corrupted : byte %u / %u (%02X!=%02X)",
-- (U32)errorPos, (U32)totalTestSize, dstBuffer[errorPos], mirrorBuffer[errorPos]);
-- } }
++ CHECK(crcOrig != crcDest, "streaming decompressed data corrupted (pos %u / %u)",
++ (U32)findDiff(mirrorBuffer, dstBuffer, totalTestSize), (U32)totalTestSize);
++ }
} /* for ( ; (testNb <= nbTests) */
DISPLAY("\r%u fuzzer tests completed \n", testNb-1);
size_t const initError = ZSTD_initCStream_usingCDict(zc, cdict);
DISPLAYLEVEL(5, "ZSTD_initCStream_usingCDict result : %u ", (U32)initError);
if (ZSTD_isError(initError)) goto _output_error;
-- cSize = 0;
outBuff.dst = compressedBuffer;
outBuff.size = compressedBufferSize;
outBuff.pos = 0;
ZSTD_CDict* const cdict = ZSTD_createCDict_advanced(dictionary.start, dictionary.filled, ZSTD_dlm_byRef, ZSTD_dct_auto, cParams, ZSTD_defaultCMem);
size_t const initError = ZSTD_initCStream_usingCDict_advanced(zc, cdict, fParams, CNBufferSize);
if (ZSTD_isError(initError)) goto _output_error;
-- cSize = 0;
outBuff.dst = compressedBuffer;
outBuff.size = compressedBufferSize;
outBuff.pos = 0;