mirror of
https://github.com/facebook/zstd.git
synced 2025-07-29 11:21:22 +03:00
changed name from createX to assembleX
shows that the resulting object just takes ownership of provided buffer.
This commit is contained in:
@ -770,7 +770,7 @@ int main (int argc, const char** argv)
|
|||||||
|
|
||||||
if (argc < 2) return bad_usage(exeName);
|
if (argc < 2) return bad_usage(exeName);
|
||||||
|
|
||||||
const char** nameTable = (const char**)malloc(argc * sizeof(const char*));
|
const char** nameTable = (const char**)malloc((size_t)argc * sizeof(const char*));
|
||||||
assert(nameTable != NULL);
|
assert(nameTable != NULL);
|
||||||
unsigned nameIdx = 0;
|
unsigned nameIdx = 0;
|
||||||
|
|
||||||
@ -805,7 +805,7 @@ int main (int argc, const char** argv)
|
|||||||
#endif
|
#endif
|
||||||
filenameTable = UTIL_createExpandedFNT(nameTable, nameIdx, 1 /* follow_links */);
|
filenameTable = UTIL_createExpandedFNT(nameTable, nameIdx, 1 /* follow_links */);
|
||||||
} else {
|
} else {
|
||||||
filenameTable = UTIL_createFileNamesTable(nameTable, nameIdx, NULL);
|
filenameTable = UTIL_assembleFileNamesTable(nameTable, nameIdx, NULL);
|
||||||
nameTable = NULL; /* UTIL_createFileNamesTable() takes ownership of nameTable */
|
nameTable = NULL; /* UTIL_createFileNamesTable() takes ownership of nameTable */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,12 +323,12 @@ UTIL_createFileNamesTable_fromFileName(const char* inputFileName)
|
|||||||
} }
|
} }
|
||||||
assert(pos <= bufSize);
|
assert(pos <= bufSize);
|
||||||
|
|
||||||
return UTIL_createFileNamesTable(filenamesTable, nbFiles, buf);
|
return UTIL_assembleFileNamesTable(filenamesTable, nbFiles, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileNamesTable*
|
FileNamesTable*
|
||||||
UTIL_createFileNamesTable(const char** filenames, size_t tableSize, char* buf)
|
UTIL_assembleFileNamesTable(const char** filenames, size_t tableSize, char* buf)
|
||||||
{
|
{
|
||||||
FileNamesTable* const table = (FileNamesTable*) malloc(sizeof(*table));
|
FileNamesTable* const table = (FileNamesTable*) malloc(sizeof(*table));
|
||||||
if(!table) return NULL;
|
if(!table) return NULL;
|
||||||
@ -352,7 +352,7 @@ FileNamesTable* UTIL_allocateFileNamesTable(size_t tableSize)
|
|||||||
const char** const fnTable = (const char**)malloc(tableSize * sizeof(*fnTable));
|
const char** const fnTable = (const char**)malloc(tableSize * sizeof(*fnTable));
|
||||||
FileNamesTable* fnt;
|
FileNamesTable* fnt;
|
||||||
if (fnTable==NULL) return NULL;
|
if (fnTable==NULL) return NULL;
|
||||||
fnt = UTIL_createFileNamesTable(fnTable, tableSize, NULL);
|
fnt = UTIL_assembleFileNamesTable(fnTable, tableSize, NULL);
|
||||||
fnt->tableSize = 0; /* the table is empty */
|
fnt->tableSize = 0; /* the table is empty */
|
||||||
return fnt;
|
return fnt;
|
||||||
}
|
}
|
||||||
@ -381,7 +381,7 @@ UTIL_mergeFileNamesTable(FileNamesTable* table1, FileNamesTable* table2)
|
|||||||
size_t newTotalTableSize;
|
size_t newTotalTableSize;
|
||||||
char* buf;
|
char* buf;
|
||||||
|
|
||||||
FileNamesTable* const newTable = UTIL_createFileNamesTable(NULL, 0, NULL);
|
FileNamesTable* const newTable = UTIL_assembleFileNamesTable(NULL, 0, NULL);
|
||||||
CONTROL( newTable != NULL );
|
CONTROL( newTable != NULL );
|
||||||
|
|
||||||
newTotalTableSize = getTotalTableSize(table1) + getTotalTableSize(table2);
|
newTotalTableSize = getTotalTableSize(table1) + getTotalTableSize(table2);
|
||||||
@ -630,7 +630,7 @@ UTIL_createExpandedFNT(const char** inputNames, size_t nbIfns, int followLinks)
|
|||||||
pos += strlen(fileNamesTable[ifnNb]) + 1;
|
pos += strlen(fileNamesTable[ifnNb]) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UTIL_createFileNamesTable(fileNamesTable, nbFiles, buf);
|
return UTIL_assembleFileNamesTable(fileNamesTable, nbFiles, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ FileNamesTable* UTIL_createFNT_fromROTable(const char** filenames, size_t nbFile
|
|||||||
const char** const newFNTable = (const char**)malloc(sizeof_FNTable);
|
const char** const newFNTable = (const char**)malloc(sizeof_FNTable);
|
||||||
if (newFNTable==NULL) return NULL;
|
if (newFNTable==NULL) return NULL;
|
||||||
memcpy((void*)newFNTable, filenames, sizeof_FNTable); /* void* : mitigate a Visual compiler bug or limitation */
|
memcpy((void*)newFNTable, filenames, sizeof_FNTable); /* void* : mitigate a Visual compiler bug or limitation */
|
||||||
return UTIL_createFileNamesTable(newFNTable, nbFilenames, NULL);
|
return UTIL_assembleFileNamesTable(newFNTable, nbFilenames, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,13 +175,13 @@ typedef struct
|
|||||||
FileNamesTable*
|
FileNamesTable*
|
||||||
UTIL_createFileNamesTable_fromFileName(const char* inputFileName);
|
UTIL_createFileNamesTable_fromFileName(const char* inputFileName);
|
||||||
|
|
||||||
/*! UTIL_createFileNamesTable() :
|
/*! UTIL_assembleFileNamesTable() :
|
||||||
* This function takes ownership of its arguments, @filenames and @buf,
|
* This function takes ownership of its arguments, @filenames and @buf,
|
||||||
* and store them inside the created object.
|
* and store them inside the created object.
|
||||||
* @return : FileNamesTable*, or NULL, if allocation fails.
|
* @return : FileNamesTable*, or NULL, if allocation fails.
|
||||||
*/
|
*/
|
||||||
FileNamesTable*
|
FileNamesTable*
|
||||||
UTIL_createFileNamesTable(const char** filenames, size_t tableSize, char* buf);
|
UTIL_assembleFileNamesTable(const char** filenames, size_t tableSize, char* buf);
|
||||||
|
|
||||||
/*! UTIL_freeFileNamesTable() :
|
/*! UTIL_freeFileNamesTable() :
|
||||||
* This function is compatible with NULL argument and never fails.
|
* This function is compatible with NULL argument and never fails.
|
||||||
|
Reference in New Issue
Block a user