summaryrefslogtreecommitdiffstats
path: root/programs/lz4io.c
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2014-07-14 22:04:10 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2014-07-14 22:04:10 (GMT)
commitfbe14d128e881abb12aaf55d5ff31be0066b69ad (patch)
tree266adb51d292714d52eee37e794eaa2a61cd9437 /programs/lz4io.c
parentd3c43d3251057da84f036c1e43fe015d2731cdd1 (diff)
downloadlz4-fbe14d128e881abb12aaf55d5ff31be0066b69ad.zip
lz4-fbe14d128e881abb12aaf55d5ff31be0066b69ad.tar.gz
lz4-fbe14d128e881abb12aaf55d5ff31be0066b69ad.tar.bz2
Modified : lz4 streaming API, strong types
Diffstat (limited to 'programs/lz4io.c')
-rw-r--r--programs/lz4io.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index 7617cff..8bd10fc 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -202,14 +202,12 @@ int LZ4IO_setBlockSizeID(int bsid)
return blockSizeTable[globalBlockSizeId-minBlockSizeID];
}
-
int LZ4IO_setBlockMode(blockMode_t blockMode)
{
blockIndependence = (blockMode == independentBlocks);
return blockIndependence;
}
-
/* Default setting : no checksum */
int LZ4IO_setBlockChecksumMode(int xxhash)
{
@@ -217,7 +215,6 @@ int LZ4IO_setBlockChecksumMode(int xxhash)
return blockChecksum;
}
-
/* Default setting : checksum enabled */
int LZ4IO_setStreamChecksumMode(int xxhash)
{
@@ -225,7 +222,6 @@ int LZ4IO_setStreamChecksumMode(int xxhash)
return streamChecksum;
}
-
/* Default setting : 0 (no notification) */
int LZ4IO_setNotificationLevel(int level)
{
@@ -367,7 +363,7 @@ int LZ4IO_compressFilename_Legacy(char* input_filename, char* output_filename, i
static void* LZ4IO_LZ4_createStream (const char* inputBuffer)
{
(void)inputBuffer;
- return LZ4_createStream();
+ return calloc(4, LZ4_STREAMSIZE_U32);
}
static int LZ4IO_LZ4_compress_limitedOutput_continue (void* ctx, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel)
@@ -389,6 +385,12 @@ static int LZ4IO_LZ4_slideInputBufferHC (void* ctx, char* buffer, int size)
}
+static int LZ4IO_free (void* ptr)
+{
+ free(ptr);
+ return 0;
+}
+
static int compress_file_blockDependency(char* input_filename, char* output_filename, int compressionlevel)
{
void* (*initFunction) (const char*);
@@ -417,14 +419,14 @@ static int compress_file_blockDependency(char* input_filename, char* output_file
initFunction = LZ4IO_LZ4_createStream;
compressionFunction = LZ4IO_LZ4_compress_limitedOutput_continue;
nextBlockFunction = LZ4IO_LZ4_saveDict;
- freeFunction = LZ4_free;
+ freeFunction = LZ4IO_free;
}
else
{
initFunction = LZ4_createHC;
compressionFunction = LZ4_compressHC2_limitedOutput_continue;
nextBlockFunction = LZ4IO_LZ4_slideInputBufferHC;
- freeFunction = LZ4_free;
+ freeFunction = LZ4IO_free;
}
get_fileHandle(input_filename, output_filename, &finput, &foutput);
@@ -753,7 +755,7 @@ static unsigned long long decodeLZ4S(FILE* finput, FILE* foutput)
size_t sizeCheck;
int blockChecksumFlag, streamChecksumFlag, blockIndependenceFlag;
void* streamChecksumState=NULL;
- int (*decompressionFunction)(void* ctx, const char* src, char* dst, int cSize, int maxOSize) = LZ4_decompress_safe_continue;
+ int (*decompressionFunction)(LZ4_streamDecode_t* ctx, const char* src, char* dst, int cSize, int maxOSize) = LZ4_decompress_safe_continue;
LZ4_streamDecode_t ctx;
// init
@@ -845,7 +847,7 @@ static unsigned long long decodeLZ4S(FILE* finput, FILE* foutput)
{
// handle dictionary for streaming
memcpy(in_buff + blockSize - 64 KB, out_buff, 64 KB);
- LZ4_setDictDecode(&ctx, out_buff, 64 KB);
+ LZ4_setStreamDecode(&ctx, out_buff, 64 KB);
out_start = out_buff + 64 KB;
}
}