summaryrefslogtreecommitdiffstats
path: root/programs/lz4io.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2020-11-14 00:44:39 (GMT)
committerYann Collet <cyan@fb.com>2020-11-14 00:44:39 (GMT)
commitf81f3a254e2dc0a2f951340c9723c7bc504118b6 (patch)
tree5f3a2ff2e3f521dffd4392bbf5443b198b85fc2f /programs/lz4io.c
parent22729ecb8b062fc7d6c7f3e7f19fd31e70d78fa0 (diff)
downloadlz4-f81f3a254e2dc0a2f951340c9723c7bc504118b6.zip
lz4-f81f3a254e2dc0a2f951340c9723c7bc504118b6.tar.gz
lz4-f81f3a254e2dc0a2f951340c9723c7bc504118b6.tar.bz2
LZ4IO_fwriteSparse doesn't need writable prefs
Diffstat (limited to 'programs/lz4io.c')
-rw-r--r--programs/lz4io.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index baebd17..2bd0401 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -325,6 +325,7 @@ static FILE* LZ4IO_openSrcFile(const char* srcFileName)
}
/** FIO_openDstFile() :
+ * prefs is writable, because sparseFileSupport might be updated
* condition : `dstFileName` must be non-NULL.
* @result : FILE* to `dstFileName`, or NULL if it fails */
static FILE* LZ4IO_openDstFile(LZ4IO_prefs_t* const prefs, const char* dstFileName)
@@ -858,7 +859,11 @@ static unsigned LZ4IO_readLE32 (const void* s)
}
-static unsigned LZ4IO_fwriteSparse(LZ4IO_prefs_t* const prefs, FILE* file, const void* buffer, size_t bufferSize, unsigned storedSkips)
+static unsigned
+LZ4IO_fwriteSparse(FILE* file,
+ const void* buffer, size_t bufferSize,
+ int sparseFileSupport,
+ unsigned storedSkips)
{
const size_t sizeT = sizeof(size_t);
const size_t maskT = sizeT -1 ;
@@ -868,7 +873,7 @@ static unsigned LZ4IO_fwriteSparse(LZ4IO_prefs_t* const prefs, FILE* file, const
const size_t* const bufferTEnd = bufferT + bufferSizeT;
const size_t segmentSizeT = (32 KB) / sizeT;
- if (!prefs->sparseFileSupport) { /* normal write */
+ if (!sparseFileSupport) { /* normal write */
size_t const sizeCheck = fwrite(buffer, 1, bufferSize, file);
if (sizeCheck != bufferSize) EXM_THROW(70, "Write error : cannot write decoded block");
return 0;
@@ -971,7 +976,7 @@ static unsigned long long LZ4IO_decodeLegacyStream(LZ4IO_prefs_t* const prefs, F
if (decodeSize < 0) EXM_THROW(53, "Decoding Failed ! Corrupted input detected !");
streamSize += (unsigned long long)decodeSize;
/* Write Block */
- storedSkips = LZ4IO_fwriteSparse(prefs, foutput, out_buff, (size_t)decodeSize, storedSkips); /* success or die */
+ storedSkips = LZ4IO_fwriteSparse(foutput, out_buff, (size_t)decodeSize, prefs->sparseFileSupport, storedSkips); /* success or die */
} }
if (ferror(finput)) EXM_THROW(54, "Read error : ferror");
@@ -1076,7 +1081,7 @@ static unsigned long long LZ4IO_decompressLZ4F(LZ4IO_prefs_t* const prefs, dRess
/* Write Block */
if (decodedBytes) {
if (!prefs->testMode)
- storedSkips = LZ4IO_fwriteSparse(prefs, dstFile, ress.dstBuffer, decodedBytes, storedSkips);
+ storedSkips = LZ4IO_fwriteSparse(dstFile, ress.dstBuffer, decodedBytes, prefs->sparseFileSupport, storedSkips);
filesize += decodedBytes;
DISPLAYUPDATE(2, "\rDecompressed : %u MB ", (unsigned)(filesize>>20));
}
@@ -1112,7 +1117,7 @@ LZ4IO_passThrough(LZ4IO_prefs_t* const prefs,
while (readBytes) {
readBytes = fread(buffer, 1, PTSIZE, finput);
total += readBytes;
- storedSkips = LZ4IO_fwriteSparse(prefs, foutput, buffer, readBytes, storedSkips);
+ storedSkips = LZ4IO_fwriteSparse(foutput, buffer, readBytes, prefs->sparseFileSupport, storedSkips);
}
if (ferror(finput)) EXM_THROW(51, "Read Error");