1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-29 11:21:22 +03:00

fixing some warning

This commit is contained in:
Ahmed Abdellah
2019-10-24 14:42:37 +01:00
parent 5e206fdd53
commit cddb05ef8c
3 changed files with 27 additions and 9 deletions

View File

@ -261,7 +261,7 @@ UTIL_createFileNamesTable_fromFileName(const char* inputFileName) {
} }
nbFiles = ret_nbFiles; nbFiles = ret_nbFiles;
filesTable = (FileNamesTable*) malloc(sizeof(FileNamesTable)); filesTable = UTIL_createFileNamesTable(NULL, NULL, 0);
if(!filesTable) { if(!filesTable) {
free(buf); free(buf);
UTIL_DISPLAYLEVEL(1, "[ERROR][UTIL_readFileNamesTableFromFile] Can't create table for files.\n"); UTIL_DISPLAYLEVEL(1, "[ERROR][UTIL_readFileNamesTableFromFile] Can't create table for files.\n");
@ -290,6 +290,18 @@ UTIL_createFileNamesTable_fromFileName(const char* inputFileName) {
return filesTable; return filesTable;
} }
FileNamesTable*
UTIL_createFileNamesTable(const char** filenames, char* buf, size_t tableSize){
FileNamesTable* table = (FileNamesTable*) malloc(sizeof(FileNamesTable));
if(!table) {
return NULL;
}
table->fileNames = filenames;
table->buf = buf;
table->tableSize = tableSize;
return table;
}
void UTIL_freeFileNamesTable(FileNamesTable* table) { void UTIL_freeFileNamesTable(FileNamesTable* table) {
if(table) { if(table) {
if(table->fileNames) { if(table->fileNames) {
@ -324,7 +336,7 @@ UTIL_concatenateTwoTables(FileNamesTable* table1, FileNamesTable* table2) {
char* buf = NULL; char* buf = NULL;
newTable = (FileNamesTable*) malloc(sizeof(FileNamesTable)); newTable = UTIL_createFileNamesTable(NULL, NULL, 0);
if(!newTable) { if(!newTable) {
UTIL_DISPLAYLEVEL(1, "[ERROR][UTIL_concatenateTwoTables] Can't create new table for concatenation output.\n"); UTIL_DISPLAYLEVEL(1, "[ERROR][UTIL_concatenateTwoTables] Can't create new table for concatenation output.\n");

View File

@ -151,8 +151,8 @@ int UTIL_readLineFromFile(char* buf, size_t len, FILE* file);
/*Note: tableSize is denotes the total capacity of table*/ /*Note: tableSize is denotes the total capacity of table*/
typedef struct typedef struct
{ {
const char** fileNames = NULL; const char** fileNames;
char* buf = NULL; char* buf;
size_t tableSize; size_t tableSize;
} FileNamesTable; } FileNamesTable;
@ -163,6 +163,16 @@ typedef struct
*/ */
FileNamesTable* UTIL_createFileNamesTable_fromFileName(const char* inputFileName); FileNamesTable* UTIL_createFileNamesTable_fromFileName(const char* inputFileName);
/*! UTIL_freeFileNamesTable(const char** filenames, char* buf, size_t tableSize) :
* This function takes an buffered based filename, buf and tableSize to create its object.
* @return : FileNamesTable*
*/
FileNamesTable*
UTIL_createFileNamesTable(const char** filenames, char* buf, size_t tableSize);
/*! UTIL_freeFileNamesTable(FileNamesTable* table) : /*! UTIL_freeFileNamesTable(FileNamesTable* table) :
* This function takes an buffered based table and frees it. * This function takes an buffered based table and frees it.
* @return : void. * @return : void.

View File

@ -818,17 +818,13 @@ int main(int argCount, const char* argv[])
filenameTable[filenameIdx] = NULL; // marking end of table filenameTable[filenameIdx] = NULL; // marking end of table
curTable = (FileNamesTable*) malloc(sizeof(FileNamesTable)); curTable = UTIL_createFileNamesTable(filenameTable, tableBuf, filenameTableSize);
if(!curTable) { if(!curTable) {
UTIL_freeFileNamesTable(extendedTable); UTIL_freeFileNamesTable(extendedTable);
CLEAN_RETURN(badusage(programName)); CLEAN_RETURN(badusage(programName));
} }
curTable->fileNames = filenameTable;
curTable->tableSize = filenameTableSize;
curTable->buf = tableBuf;
concatenatedTables = UTIL_concatenateTwoTables(curTable, extendedTable); concatenatedTables = UTIL_concatenateTwoTables(curTable, extendedTable);
if(!concatenatedTables) { if(!concatenatedTables) {
UTIL_freeFileNamesTable(curTable); UTIL_freeFileNamesTable(curTable);