mirror of
https://github.com/facebook/zstd.git
synced 2024-12-05 03:58:44 +02:00
Compare commits
8 Commits
125e23d8fe
...
9fbe0ecb32
Author | SHA1 | Date | |
---|---|---|---|
|
9fbe0ecb32 | ||
|
2b36d4bc1c | ||
|
7f11e6d2b6 | ||
|
fcf88ae39b | ||
|
1958fff050 | ||
|
10beb7cb53 | ||
|
194062a4e7 | ||
|
bfeb456fcd |
@ -1120,7 +1120,7 @@ For the purpose of counting total allocated probability points, it counts as one
|
||||
|
||||
Symbols probabilities are read one by one, in order.
|
||||
After each probability is decoded, the total nb of probability points is updated.
|
||||
This is used to dermine how many bits must be read to decode the probability of next symbol.
|
||||
This is used to determine how many bits must be read to decode the probability of next symbol.
|
||||
|
||||
When a symbol has a __probability__ of `zero` (decoded from reading a Value `1`),
|
||||
it is followed by a 2-bits repeat flag.
|
||||
|
@ -75,7 +75,7 @@ unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
|
||||
const void* src, size_t srcSize);
|
||||
|
||||
/*! HIST_add() :
|
||||
* Lowest level: just add nb of occurences of characters from @src into @count.
|
||||
* Lowest level: just add nb of occurrences of characters from @src into @count.
|
||||
* @count is not reset. @count array is presumed large enough (i.e. 1 KB).
|
||||
@ This function does not need any additional stack memory.
|
||||
*/
|
||||
|
@ -224,7 +224,7 @@ ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize)
|
||||
* it's recommended to provide @dstCapacity >= ZSTD_compressBound(srcSize)
|
||||
* as it eliminates one potential failure scenario,
|
||||
* aka not enough room in dst buffer to write the compressed frame.
|
||||
* Note : ZSTD_compressBound() itself can fail, if @srcSize > ZSTD_MAX_INPUT_SIZE .
|
||||
* Note : ZSTD_compressBound() itself can fail, if @srcSize >= ZSTD_MAX_INPUT_SIZE .
|
||||
* In which case, ZSTD_compressBound() will return an error code
|
||||
* which can be tested using ZSTD_isError().
|
||||
*
|
||||
|
@ -64,12 +64,17 @@ extern "C" {
|
||||
* It's designed for failures that may happen rarely,
|
||||
* but we don't want to maintain a specific error code path for them,
|
||||
* such as a malloc() returning NULL for example.
|
||||
* Since it's always active, this macro can trigger side effects.
|
||||
*/
|
||||
#define CONTROL(c) { \
|
||||
#define CONTROL(c) CONTROL_EXIT(c, {})
|
||||
|
||||
/* CONTROL_EXIT:
|
||||
* Same as CONTROL, but can also run a last action before exit()
|
||||
*/
|
||||
#define CONTROL_EXIT(c, _action) { \
|
||||
if (!(c)) { \
|
||||
UTIL_DISPLAYLEVEL(1, "Error : %s, %i : %s", \
|
||||
UTIL_DISPLAYLEVEL(1, "Error : %s, %i : %s not respected", \
|
||||
__FILE__, __LINE__, #c); \
|
||||
{ _action; } \
|
||||
exit(1); \
|
||||
} }
|
||||
|
||||
@ -700,7 +705,7 @@ UTIL_createFileNamesTable_fromFileName(const char* inputFileName)
|
||||
}
|
||||
|
||||
{ const char** filenamesTable = (const char**) malloc(nbFiles * sizeof(*filenamesTable));
|
||||
CONTROL(filenamesTable != NULL);
|
||||
CONTROL_EXIT(filenamesTable != NULL, free(buf));
|
||||
|
||||
{ size_t fnb, pos = 0;
|
||||
for (fnb = 0; fnb < nbFiles; fnb++) {
|
||||
@ -790,12 +795,12 @@ UTIL_mergeFileNamesTable(FileNamesTable* table1, FileNamesTable* table2)
|
||||
newTotalTableSize = getTotalTableSize(table1) + getTotalTableSize(table2);
|
||||
|
||||
buf = (char*) calloc(newTotalTableSize, sizeof(*buf));
|
||||
CONTROL ( buf != NULL );
|
||||
CONTROL_EXIT ( buf != NULL, UTIL_freeFileNamesTable(newTable) );
|
||||
|
||||
newTable->buf = buf;
|
||||
newTable->tableSize = table1->tableSize + table2->tableSize;
|
||||
newTable->fileNames = (const char **) calloc(newTable->tableSize, sizeof(*(newTable->fileNames)));
|
||||
CONTROL ( newTable->fileNames != NULL );
|
||||
CONTROL_EXIT ( newTable->fileNames != NULL, { free(buf); UTIL_freeFileNamesTable(newTable); } );
|
||||
|
||||
{ unsigned idx1;
|
||||
for( idx1=0 ; (idx1 < table1->tableSize) && table1->fileNames[idx1] && (pos < newTotalTableSize); ++idx1, ++newTableIdx) {
|
||||
@ -1279,7 +1284,7 @@ void UTIL_mirrorSourceFilesDirectories(const char** inFileNames, unsigned int nb
|
||||
for (i = 0; i < nbFile; ++i) {
|
||||
if (isFileNameValidForMirroredOutput(inFileNames[i])) {
|
||||
char* fname = STRDUP(inFileNames[i]);
|
||||
CONTROL(fname != NULL);
|
||||
CONTROL_EXIT(fname != NULL, free(srcFileNames));
|
||||
srcFileNames[validFilenamesNr++] = fname;
|
||||
}
|
||||
}
|
||||
|
@ -696,7 +696,7 @@ static void printDefaultCParams(const char* filename, const char* dictFileName,
|
||||
unsigned long long fileSize = UTIL_getFileSize(filename);
|
||||
const size_t dictSize = dictFileName != NULL ? (size_t)UTIL_getFileSize(dictFileName) : 0;
|
||||
const ZSTD_compressionParameters cParams = ZSTD_getCParams(cLevel, fileSize, dictSize);
|
||||
if (fileSize != UTIL_FILESIZE_UNKNOWN) DISPLAY("%s (%u bytes)\n", filename, (unsigned)fileSize);
|
||||
if (fileSize != UTIL_FILESIZE_UNKNOWN) DISPLAY("%s (%llu bytes)\n", filename, fileSize);
|
||||
else DISPLAY("%s (src size unknown)\n", filename);
|
||||
DISPLAY(" - windowLog : %u\n", cParams.windowLog);
|
||||
DISPLAY(" - chainLog : %u\n", cParams.chainLog);
|
||||
|
Loading…
Reference in New Issue
Block a user