for loop declaration not allowed
This commit is contained in:
parent
791352ad0e
commit
147ef05f12
@ -1442,59 +1442,62 @@ static int generateCorpusWithDict(U32 seed, unsigned numFiles, const char* const
|
|||||||
outputBuffer(fullDict, dictSize, outPath);
|
outputBuffer(fullDict, dictSize, outPath);
|
||||||
|
|
||||||
/* generate random compressed/decompressed files */
|
/* generate random compressed/decompressed files */
|
||||||
for (unsigned fnum = 0; fnum < numFiles; fnum++) {
|
{
|
||||||
frame_t fr;
|
unsigned fnum;
|
||||||
DISPLAYUPDATE("\r%u/%u ", fnum, numFiles);
|
for (fnum = 0; fnum < numFiles; fnum++) {
|
||||||
{
|
frame_t fr;
|
||||||
size_t dictContentSize = dictSize-dictSize/4;
|
DISPLAYUPDATE("\r%u/%u ", fnum, numFiles);
|
||||||
BYTE* const dictContent = fullDict+dictSize/4;
|
{
|
||||||
dictInfo const info = initDictInfo(1, dictContentSize, dictContent, dictID);
|
size_t dictContentSize = dictSize-dictSize/4;
|
||||||
seed = generateFrame(seed, &fr, info);
|
BYTE* const dictContent = fullDict+dictSize/4;
|
||||||
}
|
dictInfo const info = initDictInfo(1, dictContentSize, dictContent, dictID);
|
||||||
if (snprintf(outPath, MAX_PATH, "%s/z%06u.zst", path, fnum) + 1 > MAX_PATH) {
|
seed = generateFrame(seed, &fr, info);
|
||||||
DISPLAY("Error: path too long\n");
|
}
|
||||||
errorDetected = 1;
|
if (snprintf(outPath, MAX_PATH, "%s/z%06u.zst", path, fnum) + 1 > MAX_PATH) {
|
||||||
goto dictCleanup;
|
|
||||||
}
|
|
||||||
outputBuffer(fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart, outPath);
|
|
||||||
|
|
||||||
if (origPath) {
|
|
||||||
if (snprintf(outPath, MAX_PATH, "%s/z%06u", origPath, fnum) + 1 > MAX_PATH) {
|
|
||||||
DISPLAY("Error: path too long\n");
|
DISPLAY("Error: path too long\n");
|
||||||
errorDetected = 1;
|
errorDetected = 1;
|
||||||
goto dictCleanup;
|
goto dictCleanup;
|
||||||
}
|
}
|
||||||
outputBuffer(fr.srcStart, (BYTE*)fr.src - (BYTE*)fr.srcStart, outPath);
|
outputBuffer(fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart, outPath);
|
||||||
}
|
|
||||||
|
|
||||||
/* check the output to make sure that decompressed versions match official zstd */
|
if (origPath) {
|
||||||
{
|
if (snprintf(outPath, MAX_PATH, "%s/z%06u", origPath, fnum) + 1 > MAX_PATH) {
|
||||||
ZSTD_DCtx* const dctx = ZSTD_createDCtx();
|
DISPLAY("Error: path too long\n");
|
||||||
BYTE* const decompressedPtr = malloc(MAX_DECOMPRESSED_SIZE);
|
errorDetected = 1;
|
||||||
if (decompressedPtr == NULL) {
|
goto dictCleanup;
|
||||||
DISPLAY("Error: could not allocate memory for decompressed pointer\n");
|
|
||||||
errorDetected = 1;
|
|
||||||
goto dictCleanup;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
size_t const returnValue = ZSTD_decompress_usingDict(dctx, decompressedPtr, MAX_DECOMPRESSED_SIZE,
|
|
||||||
fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart,
|
|
||||||
fullDict, dictSize);
|
|
||||||
if (ZSTD_isError(returnValue)) {
|
|
||||||
DISPLAY("Error: %s\n", ZSTD_getErrorName(returnValue));
|
|
||||||
}
|
}
|
||||||
|
outputBuffer(fr.srcStart, (BYTE*)fr.src - (BYTE*)fr.srcStart, outPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print differences if any */
|
/* check the output to make sure that decompressed versions match official zstd */
|
||||||
{
|
{
|
||||||
size_t checkDiff = (BYTE*)fr.src - (BYTE*)fr.srcStart;
|
ZSTD_DCtx* const dctx = ZSTD_createDCtx();
|
||||||
for (size_t i = 0; i < checkDiff; i++) {
|
BYTE* const decompressedPtr = malloc(MAX_DECOMPRESSED_SIZE);
|
||||||
if (*((BYTE*)(fr.srcStart + i)) != *((BYTE*)(decompressedPtr + i))) {
|
if (decompressedPtr == NULL) {
|
||||||
DISPLAY("i: %zu, fr: %u, decomp: %u\n", i, *((BYTE*)(fr.srcStart + i)), *((BYTE*)(decompressedPtr + i)));
|
DISPLAY("Error: could not allocate memory for decompressed pointer\n");
|
||||||
|
errorDetected = 1;
|
||||||
|
goto dictCleanup;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
size_t const returnValue = ZSTD_decompress_usingDict(dctx, decompressedPtr, MAX_DECOMPRESSED_SIZE,
|
||||||
|
fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart,
|
||||||
|
fullDict, dictSize);
|
||||||
|
if (ZSTD_isError(returnValue)) {
|
||||||
|
DISPLAY("Error: %s\n", ZSTD_getErrorName(returnValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* print differences if any */
|
||||||
|
{
|
||||||
|
size_t checkDiff = (BYTE*)fr.src - (BYTE*)fr.srcStart;
|
||||||
|
for (size_t i = 0; i < checkDiff; i++) {
|
||||||
|
if (*((BYTE*)(fr.srcStart + i)) != *((BYTE*)(decompressedPtr + i))) {
|
||||||
|
DISPLAY("i: %zu, fr: %u, decomp: %u\n", i, *((BYTE*)(fr.srcStart + i)), *((BYTE*)(decompressedPtr + i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(decompressedPtr);
|
||||||
}
|
}
|
||||||
free(decompressedPtr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user