mirror of
https://github.com/facebook/zstd.git
synced 2025-09-07 01:06:59 +03:00
fixed compatibility issues
This commit is contained in:
@@ -288,15 +288,14 @@ UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, char*
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ((entry = readdir(dir)) && (*bufStart < bufEnd)) {
|
while ((entry = readdir(dir)) && (*bufStart < bufEnd)) {
|
||||||
if (entry->d_type & DT_DIR) {
|
|
||||||
if (strcmp (entry->d_name, "..") == 0 ||
|
if (strcmp (entry->d_name, "..") == 0 ||
|
||||||
strcmp (entry->d_name, ".") == 0) continue;
|
strcmp (entry->d_name, ".") == 0) continue;
|
||||||
|
|
||||||
pathLength = snprintf(path, PATH_MAX, "%s/%s", dirName, entry->d_name);
|
pathLength = snprintf(path, PATH_MAX, "%s/%s", dirName, entry->d_name);
|
||||||
if (pathLength < 0 || pathLength >= PATH_MAX) {
|
if (pathLength < 0 || pathLength >= PATH_MAX) {
|
||||||
fprintf(stderr, "Path length has got too long.\n");
|
fprintf(stderr, "Path length has got too long.\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (UTIL_isDirectory(path)) {
|
||||||
// printf ("[%s]\n", path);
|
// printf ("[%s]\n", path);
|
||||||
nbFiles += UTIL_prepareFileList(path, bufStart, bufEnd); /* Recursively call "UTIL_prepareFileList" with the new path. */
|
nbFiles += UTIL_prepareFileList(path, bufStart, bufEnd); /* Recursively call "UTIL_prepareFileList" with the new path. */
|
||||||
} else {
|
} else {
|
||||||
@@ -370,7 +369,7 @@ UTIL_STATIC int UTIL_createFileList(const char **inputNames, unsigned nbNames, u
|
|||||||
UTIL_STATIC void UTIL_freeFileList(const char** filenameTable, char* buf)
|
UTIL_STATIC void UTIL_freeFileList(const char** filenameTable, char* buf)
|
||||||
{
|
{
|
||||||
free(buf);
|
free(buf);
|
||||||
free(filenameTable);
|
free((void*)filenameTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -330,6 +330,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
} /* Bench */
|
} /* Bench */
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
|
free(blockTable);
|
||||||
free(compressedBuffer);
|
free(compressedBuffer);
|
||||||
free(resultBuffer);
|
free(resultBuffer);
|
||||||
ZSTD_freeCCtx(refCtx);
|
ZSTD_freeCCtx(refCtx);
|
||||||
@@ -525,7 +526,7 @@ int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
nbFiles = UTIL_createFileList(fileNamesTable, nbFiles, MAX_LIST_SIZE, &filenameTable, &buf);
|
nbFiles = UTIL_createFileList(fileNamesTable, nbFiles, MAX_LIST_SIZE, &filenameTable, &buf);
|
||||||
if (filenameTable) {
|
if (filenameTable) {
|
||||||
for (i=0; i<nbFiles; i++) printf ("%d %s\n", i, filenameTable[i]);
|
for (i=0; i<nbFiles; i++) DISPLAYLEVEL(3, "%d %s\n", i, filenameTable[i]);
|
||||||
BMK_benchFileTable(filenameTable, nbFiles, dictFileName, cLevel, cLevelLast);
|
BMK_benchFileTable(filenameTable, nbFiles, dictFileName, cLevel, cLevelLast);
|
||||||
UTIL_freeFileList(filenameTable, buf);
|
UTIL_freeFileList(filenameTable, buf);
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
/* *************************************
|
/* *************************************
|
||||||
* Compiler Options
|
* Compiler Options
|
||||||
***************************************/
|
***************************************/
|
||||||
#define _POSIX_SOURCE 1 /* enable fileno() within <stdio.h> on unix */
|
#define _POSIX_SOURCE 1 /* enable %llu on Windows */
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
@@ -72,11 +72,9 @@
|
|||||||
# include <fcntl.h> /* _O_BINARY */
|
# include <fcntl.h> /* _O_BINARY */
|
||||||
# include <io.h> /* _setmode, _isatty */
|
# include <io.h> /* _setmode, _isatty */
|
||||||
# define SET_BINARY_MODE(file) { int unused = _setmode(_fileno(file), _O_BINARY); (void)unused; }
|
# define SET_BINARY_MODE(file) { int unused = _setmode(_fileno(file), _O_BINARY); (void)unused; }
|
||||||
# define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream))
|
|
||||||
#else
|
#else
|
||||||
# include <unistd.h> /* isatty */
|
# include <unistd.h> /* isatty */
|
||||||
# define SET_BINARY_MODE(file)
|
# define SET_BINARY_MODE(file)
|
||||||
# define IS_CONSOLE(stdStream) isatty(fileno(stdStream))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user