#define DEFAULT_DISPLAY_LEVEL 2
#define DISPLAY(...) fprintf(displayOut, __VA_ARGS__)
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
-static int g_displayLevel = DEFAULT_DISPLAY_LEVEL; /* 0 : no display; 1: errors; 2 : + result + interaction + warnings; 3 : + progression; 4 : + information */
+static unsigned g_displayLevel = DEFAULT_DISPLAY_LEVEL; /* 0 : no display; 1: errors; 2 : + result + interaction + warnings; 3 : + progression; 4 : + information */
static FILE* displayOut;
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
{
unsigned result = 0;
while ((**stringPtr >='0') && (**stringPtr <='9'))
- result *= 10, result += **stringPtr - '0', (*stringPtr)++ ;
+ result *= 10, result += (unsigned)(**stringPtr - '0'), (*stringPtr)++ ;
return result;
}
int cLevel = ZSTDCLI_CLEVEL_DEFAULT;
int cLevelLast = 1;
unsigned recursive = 0;
- const char** filenameTable = (const char**)malloc(argCount * sizeof(const char*)); /* argCount >= 1 */
- unsigned filenameIdx = 0;
+ FileNamesTable* filenames = UTIL_allocateFileNamesTable((size_t)argCount);
const char* programName = argv[0];
const char* dictFileName = NULL;
char* dynNameSpace = NULL;
-#ifdef UTIL_HAS_CREATEFILELIST
- const char** fileNamesTable = NULL;
- char* fileNamesBuf = NULL;
- unsigned fileNamesNb;
-#endif
/* init */
- if (filenameTable==NULL) { DISPLAY("zstd: %s \n", strerror(errno)); exit(1); }
+ if (filenames==NULL) { DISPLAY("zstd: %s \n", strerror(errno)); exit(1); }
displayOut = stderr;
/* Pick out program name from path. Don't rely on stdlib because of conflicting behavior */
{ size_t pos;
- for (pos = (int)strlen(programName); pos > 0; pos--) { if (programName[pos] == '/') { pos++; break; } }
+ for (pos = strlen(programName); pos > 0; pos--) { if (programName[pos] == '/') { pos++; break; } }
programName += pos;
}
case 'b':
/* first compression Level */
argument++;
- cLevel = readU32FromChar(&argument);
+ cLevel = (int)readU32FromChar(&argument);
break;
/* range bench (benchmark only) */
case 'e':
/* last compression Level */
argument++;
- cLevelLast = readU32FromChar(&argument);
+ cLevelLast = (int)readU32FromChar(&argument);
break;
/* Modify Nb Iterations (benchmark only) */
/* Pause at the end (-p) or set an additional param (-p#) (hidden option) */
case 'p': argument++;
if ((*argument>='0') && (*argument<='9')) {
- BMK_setAdditionalParam(readU32FromChar(&argument));
+ BMK_setAdditionalParam((int)readU32FromChar(&argument));
} else
main_pause=1;
break;
}
/* add filename to list */
- filenameTable[filenameIdx++] = argument;
+ UTIL_refFilename(filenames, argument);
}
/* Welcome message (if verbose) */
#ifdef UTIL_HAS_CREATEFILELIST
if (recursive) {
- fileNamesTable = UTIL_createFileList(filenameTable, filenameIdx, &fileNamesBuf, &fileNamesNb, 1);
- if (fileNamesTable) {
- unsigned u;
- for (u=0; u<fileNamesNb; u++) DISPLAYLEVEL(4, "%u %s\n", u, fileNamesTable[u]);
- free((void*)filenameTable);
- filenameTable = fileNamesTable;
- filenameIdx = fileNamesNb;
- }
+ filenames = UTIL_expandFileNamesTable(filenames, 1);
}
#endif
BMK_setNotificationLevel(g_displayLevel);
- BMK_benchFiles(filenameTable, filenameIdx, dictFileName, cLevel, cLevelLast);
+ BMK_benchFiles(filenames->fileNames, (unsigned)filenames->tableSize, dictFileName, cLevel, cLevelLast);
_end:
if (main_pause) waitEnter();
free(dynNameSpace);
-#ifdef UTIL_HAS_CREATEFILELIST
- if (fileNamesTable)
- UTIL_freeFileList(fileNamesTable, fileNamesBuf);
- else
-#endif
- free((void*)filenameTable);
+ UTIL_freeFileNamesTable(filenames);
return operationResult;
}