Added some comments for better clarity
git-svn-id: https://lz4.googlecode.com/svn/trunk@6 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
parent
f03375468c
commit
06abb77c00
1
LZ4.c
1
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
|
||||
|
12
LZ4.h
12
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.
|
||||
*/
|
||||
|
||||
|
||||
|
16
main.c
16
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
|
||||
|
Loading…
Reference in New Issue
Block a user