assembleFNT() can no longer fail
This commit is contained in:
parent
aaab618ae9
commit
96ee20758c
@ -366,7 +366,7 @@ FileNamesTable*
|
||||
UTIL_assembleFileNamesTable(const char** filenames, size_t tableSize, char* buf)
|
||||
{
|
||||
FileNamesTable* const table = (FileNamesTable*) malloc(sizeof(*table));
|
||||
if(!table) return NULL;
|
||||
CONTROL(table != NULL);
|
||||
table->fileNames = filenames;
|
||||
table->buf = buf;
|
||||
table->tableSize = tableSize;
|
||||
@ -665,7 +665,8 @@ UTIL_createExpandedFNT(const char** inputNames, size_t nbIfns, int followLinks)
|
||||
pos += strlen(fileNamesTable[ifnNb]) + 1;
|
||||
}
|
||||
{ FileNamesTable* const fnt = UTIL_assembleFileNamesTable(fileNamesTable, nbFiles, buf);
|
||||
#ifdef __clang_analyzer__
|
||||
#if 0 && defined(__clang_analyzer__)
|
||||
/* note : this trick might not be necessary anymore */
|
||||
/* scan-build does not understand ownership transfer.
|
||||
* In _some_ versions, it believes that there is a leak of @buf and @fileNamesTable
|
||||
* on leaving the function, which is not the case,
|
||||
@ -761,8 +762,7 @@ int UTIL_countPhysicalCores(void)
|
||||
}
|
||||
} else {
|
||||
done = TRUE;
|
||||
}
|
||||
}
|
||||
} }
|
||||
|
||||
ptr = buffer;
|
||||
|
||||
@ -874,8 +874,7 @@ int UTIL_countPhysicalCores(void)
|
||||
} else if (ferror(cpuinfo)) {
|
||||
/* fall back on the sysconf value */
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
} }
|
||||
if (siblings && cpu_cores) {
|
||||
ratio = siblings / cpu_cores;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ extern "C" {
|
||||
#include <sys/stat.h> /* stat, chmod */
|
||||
#include "mem.h" /* U64 */
|
||||
|
||||
|
||||
/*-************************************************************
|
||||
* Avoid fseek()'s 2GiB barrier with MSVC, macOS, *BSD, MinGW
|
||||
***************************************************************/
|
||||
@ -126,17 +127,8 @@ const char* UTIL_getFileExtension(const char* infilename);
|
||||
* Lists of Filenames
|
||||
******************************************/
|
||||
|
||||
#ifdef _WIN32
|
||||
# define UTIL_HAS_CREATEFILELIST
|
||||
#elif defined(__linux__) || (PLATFORM_POSIX_VERSION >= 200112L) /* opendir, readdir require POSIX.1-2001 */
|
||||
# define UTIL_HAS_CREATEFILELIST
|
||||
#else
|
||||
/* do not define UTIL_HAS_CREATEFILELIST */
|
||||
#endif /* #ifdef _WIN32 */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char** fileNames;
|
||||
{ const char** fileNames;
|
||||
char* buf; /* fileNames are stored in this buffer (or are read-only) */
|
||||
size_t tableSize; /* nb of fileNames */
|
||||
size_t tableCapacity;
|
||||
@ -153,7 +145,9 @@ UTIL_createFileNamesTable_fromFileName(const char* inputFileName);
|
||||
/*! UTIL_assembleFileNamesTable() :
|
||||
* This function takes ownership of its arguments, @filenames and @buf,
|
||||
* and store them inside the created object.
|
||||
* @return : FileNamesTable*, or NULL, if allocation fails.
|
||||
* note : this function never fails,
|
||||
* it will rather exit() the program if internal allocation fails.
|
||||
* @return : resulting FileNamesTable* object.
|
||||
*/
|
||||
FileNamesTable*
|
||||
UTIL_assembleFileNamesTable(const char** filenames, size_t tableSize, char* buf);
|
||||
@ -185,15 +179,8 @@ void UTIL_expandFNT(FileNamesTable** fnt, int followLinks);
|
||||
* @return : a FileNamesTable* object,
|
||||
* or NULL in case of error
|
||||
*/
|
||||
FileNamesTable* UTIL_createFNT_fromROTable(const char** filenames, size_t nbFilenames);
|
||||
|
||||
/*! UTIL_createExpandedFNT() :
|
||||
* read names from @filenames, and expand those corresponding to directories
|
||||
* @return : an expanded FileNamesTable*, where each name is a file
|
||||
* or NULL in case of error
|
||||
*/
|
||||
FileNamesTable* UTIL_createExpandedFNT(const char** filenames, size_t nbFilenames, int followLinks);
|
||||
|
||||
FileNamesTable*
|
||||
UTIL_createFNT_fromROTable(const char** filenames, size_t nbFilenames);
|
||||
|
||||
/*! UTIL_allocateFileNamesTable() :
|
||||
* Allocates a table of const char*, to insert read-only names later on.
|
||||
@ -212,6 +199,28 @@ FileNamesTable* UTIL_allocateFileNamesTable(size_t tableSize);
|
||||
void UTIL_refFilename(FileNamesTable* fnt, const char* filename);
|
||||
|
||||
|
||||
/* UTIL_createExpandedFNT() is only active if UTIL_HAS_CREATEFILELIST is defined.
|
||||
* Otherwise, UTIL_createExpandedFNT() is a shell function which does nothing
|
||||
* apart from displaying a warning message.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
# define UTIL_HAS_CREATEFILELIST
|
||||
#elif defined(__linux__) || (PLATFORM_POSIX_VERSION >= 200112L) /* opendir, readdir require POSIX.1-2001 */
|
||||
# define UTIL_HAS_CREATEFILELIST
|
||||
#else
|
||||
/* do not define UTIL_HAS_CREATEFILELIST */
|
||||
#endif
|
||||
|
||||
/*! UTIL_createExpandedFNT() :
|
||||
* read names from @filenames, and expand those corresponding to directories.
|
||||
* links are followed or not depending on @followLinks directive.
|
||||
* @return : an expanded FileNamesTable*, where each name is a file
|
||||
* or NULL in case of error
|
||||
*/
|
||||
FileNamesTable*
|
||||
UTIL_createExpandedFNT(const char** filenames, size_t nbFilenames, int followLinks);
|
||||
|
||||
|
||||
/*-****************************************
|
||||
* System
|
||||
******************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user