summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LZ4.c1
-rw-r--r--LZ4.h12
-rw-r--r--main.c16
3 files changed, 18 insertions, 11 deletions
diff --git a/LZ4.c b/LZ4.c
index deefbb0..b848eea 100644
--- a/LZ4.c
+++ b/LZ4.c
@@ -1,6 +1,7 @@
/*
LZ4 - Fast LZ compression algorithm
Copyright (C) 2011, Yann Collet.
+ BSD License
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
diff --git a/LZ4.h b/LZ4.h
index 7da4db8..dc9474c 100644
--- a/LZ4.h
+++ b/LZ4.h
@@ -2,6 +2,7 @@
LZ4 - Fast LZ compression algorithm
Header File
Copyright (C) 2011, Yann Collet.
+ BSD License
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -36,9 +37,9 @@ extern "C" {
// Instructions
//****************************
-// Uncomment next line to ensure that LZ4_Decode will never write in destination buffer more than "originalSize" bytes
-// If commented, the decoder may write up to 3 bytes more than originalSize, so provide extra room in dest buffer for that
-// Recommendation : commented, for improved performance; ensure that destination buffer is at least originalSize + 3 Bytes
+// Uncomment next line to ensure that LZ4_Decode will never write in destination buffer more than "decompressedSize" bytes
+// If commented, the decoder may write up to 3 bytes more than decompressedSize, so provide extra room in dest buffer for that
+// Recommendation : keep commented, for improved performance; ensure that destination buffer is at least decompressedSize + 3 Bytes
// #define SAFEWRITEBUFFER
@@ -52,10 +53,13 @@ int LZ4_decode (char* source, char* dest, int isize);
/*
LZ4_compress :
return : the number of bytes in compressed buffer dest
- note : this simple function explicitly allocate/deallocate memory **at each call**
+ note : destination buffer must be already allocated.
+ To avoid any problem, size it to handle worst cases situations (input data not compressible)
+ Worst case size is : "inputsize + 0.4%", with "0.4%" being at least 8 bytes.
LZ4_decode :
return : the number of bytes in decoded buffer dest
+ note : destination buffer must be already allocated.
*/
diff --git a/main.c b/main.c
index 97b6fc0..781c7e3 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,5 @@
/*
- LZ4 Demo program
- Main file I/O
+ Demo compression program using LZ4 compression
Copyright (C) Yann Collet 2011,
This program is free software; you can redistribute it and/or modify
@@ -17,7 +16,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+/*
+ Note : this is *only* a demo program, an example to show how LZ4 can be used.
+ It is not considered part of LZ4 compression library.
+ The license of the demo program is GPL.
+ The license of LZ4 is BSD.
+*/
//****************************
// Includes
@@ -30,7 +34,7 @@
//****************************
// Constants
//****************************
-#define COMPRESSOR_NAME "LZ4 - Demo program"
+#define COMPRESSOR_NAME "Demo compression program using LZ4"
#define COMPRESSOR_VERSION "v1.0"
#define COMPILED __DATE__
#define AUTHOR "Yann Collet"
@@ -41,7 +45,6 @@
#define CHUNKSIZE (8<<20) // 8 MB
#define CACHELINE 64
#define OUT_CHUNKSIZE (CHUNKSIZE + CHUNKSIZE/256 + CACHELINE)
-#define PRIME 181
#define ARCHIVE_MAGICNUMBER 0x184C2102
#define ARCHIVE_MAGICNUMBER_SIZE 4
@@ -103,7 +106,7 @@ compress_file(char* input_filename, char* output_filename)
// Compress Block
outSize = LZ4_compress(in_buff, out_buff+4, inSize);
* (unsigned long*) out_buff = outSize;
- compressedfilesize += outSize;
+ compressedfilesize += outSize+4;
// Write Block
fwrite(out_buff, 1, outSize+4, foutput);
@@ -206,7 +209,6 @@ int main(int argc, char** argv)
// Forced Decoding
if( argument[0] =='d' )
{ decode=1; continue; }
-
}
// first provided filename is input