lz4-ruby 0.3.2-java → 0.3.3-java

Sign up to get free protection for your applications and to get access to all the features.
data/ext/lz4ruby/lz4hc.c CHANGED
@@ -54,8 +54,9 @@
54
54
  **************************************/
55
55
  /* 32 or 64 bits ? */
56
56
  #if (defined(__x86_64__) || defined(_M_X64) || defined(_WIN64) \
57
- || defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) \
58
- || defined(__64BIT__) || defined(_LP64) || defined(__LP64__) \
57
+ || defined(__powerpc64__) || defined(__powerpc64le__) \
58
+ || defined(__ppc64__) || defined(__ppc64le__) \
59
+ || defined(__PPC64__) || defined(__PPC64LE__) \
59
60
  || defined(__ia64) || defined(__itanium__) || defined(_M_IA64) ) /* Detects 64 bits mode */
60
61
  # define LZ4_ARCH64 1
61
62
  #else
@@ -66,6 +67,7 @@
66
67
  * Little Endian or Big Endian ?
67
68
  * Overwrite the #define below if you know your architecture endianess
68
69
  */
70
+ #include <stdlib.h> /* Apparently required to detect endianess */
69
71
  #if defined (__GLIBC__)
70
72
  # include <endian.h>
71
73
  # if (__BYTE_ORDER == __BIG_ENDIAN)
data/ext/lz4ruby/lz4hc.h CHANGED
@@ -1,172 +1,173 @@
1
- /*
2
- LZ4 HC - High Compression Mode of LZ4
3
- Header File
4
- Copyright (C) 2011-2013, Yann Collet.
5
- BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6
-
7
- Redistribution and use in source and binary forms, with or without
8
- modification, are permitted provided that the following conditions are
9
- met:
10
-
11
- * Redistributions of source code must retain the above copyright
12
- notice, this list of conditions and the following disclaimer.
13
- * Redistributions in binary form must reproduce the above
14
- copyright notice, this list of conditions and the following disclaimer
15
- in the documentation and/or other materials provided with the
16
- distribution.
17
-
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
-
30
- You can contact the author at :
31
- - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
32
- - LZ4 source repository : http://code.google.com/p/lz4/
33
- */
34
- #pragma once
35
-
36
-
37
- #if defined (__cplusplus)
38
- extern "C" {
39
- #endif
40
-
41
-
42
- int LZ4_compressHC (const char* source, char* dest, int inputSize);
43
- /*
44
- LZ4_compressHC :
45
- return : the number of bytes in compressed buffer dest
46
- or 0 if compression fails.
47
- note : destination buffer must be already allocated.
48
- To avoid any problem, size it to handle worst cases situations (input data not compressible)
49
- Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
50
- */
51
-
52
- int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
53
- /*
54
- LZ4_compress_limitedOutput() :
55
- Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
56
- If it cannot achieve it, compression will stop, and result of the function will be zero.
57
- This function never writes outside of provided output buffer.
58
-
59
- inputSize : Max supported value is 1 GB
60
- maxOutputSize : is maximum allowed size into the destination buffer (which must be already allocated)
61
- return : the number of output bytes written in buffer 'dest'
62
- or 0 if compression fails.
63
- */
64
-
65
-
66
- int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
67
- int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
68
- /*
69
- Same functions as above, but with programmable 'compressionLevel'.
70
- Recommended values are between 4 and 9, although any value between 0 and 16 will work.
71
- 'compressionLevel'==0 means use default 'compressionLevel' value.
72
- Values above 16 behave the same as 16.
73
- Equivalent variants exist for all other compression functions below.
74
- */
75
-
76
- /* Note :
77
- Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license)
78
- */
79
-
80
-
81
- /**************************************
82
- Using an external allocation
83
- **************************************/
84
- int LZ4_sizeofStateHC();
85
- int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
86
- int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
87
-
88
- int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
89
- int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
90
-
91
- /*
92
- These functions are provided should you prefer to allocate memory for compression tables with your own allocation methods.
93
- To know how much memory must be allocated for the compression tables, use :
94
- int LZ4_sizeofStateHC();
95
-
96
- Note that tables must be aligned for pointer (32 or 64 bits), otherwise compression will fail (return code 0).
97
-
98
- The allocated memory can be provided to the compressions functions using 'void* state' parameter.
99
- LZ4_compress_withStateHC() and LZ4_compress_limitedOutput_withStateHC() are equivalent to previously described functions.
100
- They just use the externally allocated memory area instead of allocating their own (on stack, or on heap).
101
- */
102
-
103
-
104
- /**************************************
105
- Streaming Functions
106
- **************************************/
107
- void* LZ4_createHC (const char* inputBuffer);
108
- int LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize);
109
- int LZ4_compressHC_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
110
- char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
111
- int LZ4_freeHC (void* LZ4HC_Data);
112
-
113
- int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
114
- int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
115
-
116
- /*
117
- These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.
118
- In order to achieve this, it is necessary to start creating the LZ4HC Data Structure, thanks to the function :
119
-
120
- void* LZ4_createHC (const char* inputBuffer);
121
- The result of the function is the (void*) pointer on the LZ4HC Data Structure.
122
- This pointer will be needed in all other functions.
123
- If the pointer returned is NULL, then the allocation has failed, and compression must be aborted.
124
- The only parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer.
125
- The input buffer must be already allocated, and size at least 192KB.
126
- 'inputBuffer' will also be the 'const char* source' of the first block.
127
-
128
- All blocks are expected to lay next to each other within the input buffer, starting from 'inputBuffer'.
129
- To compress each block, use either LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue().
130
- Their behavior are identical to LZ4_compressHC() or LZ4_compressHC_limitedOutput(),
131
- but require the LZ4HC Data Structure as their first argument, and check that each block starts right after the previous one.
132
- If next block does not begin immediately after the previous one, the compression will fail (return 0).
133
-
134
- When it's no longer possible to lay the next block after the previous one (not enough space left into input buffer), a call to :
135
- char* LZ4_slideInputBufferHC(void* LZ4HC_Data);
136
- must be performed. It will typically copy the latest 64KB of input at the beginning of input buffer.
137
- Note that, for this function to work properly, minimum size of an input buffer must be 192KB.
138
- ==> The memory position where the next input data block must start is provided as the result of the function.
139
-
140
- Compression can then resume, using LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue(), as usual.
141
-
142
- When compression is completed, a call to LZ4_freeHC() will release the memory used by the LZ4HC Data Structure.
143
- */
144
-
145
- int LZ4_sizeofStreamStateHC();
146
- int LZ4_resetStreamStateHC(void* state, const char* inputBuffer);
147
-
148
- /*
149
- These functions achieve the same result as :
150
- void* LZ4_createHC (const char* inputBuffer);
151
-
152
- They are provided here to allow the user program to allocate memory using its own routines.
153
-
154
- To know how much space must be allocated, use LZ4_sizeofStreamStateHC();
155
- Note also that space must be aligned for pointers (32 or 64 bits).
156
-
157
- Once space is allocated, you must initialize it using : LZ4_resetStreamStateHC(void* state, const char* inputBuffer);
158
- void* state is a pointer to the space allocated.
159
- It must be aligned for pointers (32 or 64 bits), and be large enough.
160
- The parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer.
161
- The input buffer must be already allocated, and size at least 192KB.
162
- 'inputBuffer' will also be the 'const char* source' of the first block.
163
-
164
- The same space can be re-used multiple times, just by initializing it each time with LZ4_resetStreamState().
165
- return value of LZ4_resetStreamStateHC() must be 0 is OK.
166
- Any other value means there was an error (typically, state is not aligned for pointers (32 or 64 bits)).
167
- */
168
-
169
-
170
- #if defined (__cplusplus)
171
- }
172
- #endif
1
+ /*
2
+ LZ4 HC - High Compression Mode of LZ4
3
+ Header File
4
+ Copyright (C) 2011-2014, Yann Collet.
5
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are
9
+ met:
10
+
11
+ * Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+ * Redistributions in binary form must reproduce the above
14
+ copyright notice, this list of conditions and the following disclaimer
15
+ in the documentation and/or other materials provided with the
16
+ distribution.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ You can contact the author at :
31
+ - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
32
+ - LZ4 source repository : http://code.google.com/p/lz4/
33
+ */
34
+ #pragma once
35
+
36
+
37
+ #if defined (__cplusplus)
38
+ extern "C" {
39
+ #endif
40
+
41
+
42
+ int LZ4_compressHC (const char* source, char* dest, int inputSize);
43
+ /*
44
+ LZ4_compressHC :
45
+ return : the number of bytes in compressed buffer dest
46
+ or 0 if compression fails.
47
+ note : destination buffer must be already allocated.
48
+ To avoid any problem, size it to handle worst cases situations (input data not compressible)
49
+ Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")
50
+ */
51
+
52
+ int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
53
+ /*
54
+ LZ4_compress_limitedOutput() :
55
+ Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
56
+ If it cannot achieve it, compression will stop, and result of the function will be zero.
57
+ This function never writes outside of provided output buffer.
58
+
59
+ inputSize : Max supported value is 1 GB
60
+ maxOutputSize : is maximum allowed size into the destination buffer (which must be already allocated)
61
+ return : the number of output bytes written in buffer 'dest'
62
+ or 0 if compression fails.
63
+ */
64
+
65
+
66
+ int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
67
+ int LZ4_compressHC2_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
68
+ /*
69
+ Same functions as above, but with programmable 'compressionLevel'.
70
+ Recommended values are between 4 and 9, although any value between 0 and 16 will work.
71
+ 'compressionLevel'==0 means use default 'compressionLevel' value.
72
+ Values above 16 behave the same as 16.
73
+ Equivalent variants exist for all other compression functions below.
74
+ */
75
+
76
+ /* Note :
77
+ Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license)
78
+ */
79
+
80
+
81
+ /**************************************
82
+ Using an external allocation
83
+ **************************************/
84
+ int LZ4_sizeofStateHC(void);
85
+ int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
86
+ int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
87
+
88
+ int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
89
+ int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
90
+
91
+ /*
92
+ These functions are provided should you prefer to allocate memory for compression tables with your own allocation methods.
93
+ To know how much memory must be allocated for the compression tables, use :
94
+ int LZ4_sizeofStateHC();
95
+
96
+ Note that tables must be aligned for pointer (32 or 64 bits), otherwise compression will fail (return code 0).
97
+
98
+ The allocated memory can be provided to the compressions functions using 'void* state' parameter.
99
+ LZ4_compress_withStateHC() and LZ4_compress_limitedOutput_withStateHC() are equivalent to previously described functions.
100
+ They just use the externally allocated memory area instead of allocating their own (on stack, or on heap).
101
+ */
102
+
103
+
104
+ /**************************************
105
+ Streaming Functions
106
+ **************************************/
107
+ /* Note : these streaming functions still follows the older model */
108
+ void* LZ4_createHC (const char* inputBuffer);
109
+ int LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize);
110
+ int LZ4_compressHC_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);
111
+ char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
112
+ int LZ4_freeHC (void* LZ4HC_Data);
113
+
114
+ int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
115
+ int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
116
+
117
+ /*
118
+ These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.
119
+ In order to achieve this, it is necessary to start creating the LZ4HC Data Structure, thanks to the function :
120
+
121
+ void* LZ4_createHC (const char* inputBuffer);
122
+ The result of the function is the (void*) pointer on the LZ4HC Data Structure.
123
+ This pointer will be needed in all other functions.
124
+ If the pointer returned is NULL, then the allocation has failed, and compression must be aborted.
125
+ The only parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer.
126
+ The input buffer must be already allocated, and size at least 192KB.
127
+ 'inputBuffer' will also be the 'const char* source' of the first block.
128
+
129
+ All blocks are expected to lay next to each other within the input buffer, starting from 'inputBuffer'.
130
+ To compress each block, use either LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue().
131
+ Their behavior are identical to LZ4_compressHC() or LZ4_compressHC_limitedOutput(),
132
+ but require the LZ4HC Data Structure as their first argument, and check that each block starts right after the previous one.
133
+ If next block does not begin immediately after the previous one, the compression will fail (return 0).
134
+
135
+ When it's no longer possible to lay the next block after the previous one (not enough space left into input buffer), a call to :
136
+ char* LZ4_slideInputBufferHC(void* LZ4HC_Data);
137
+ must be performed. It will typically copy the latest 64KB of input at the beginning of input buffer.
138
+ Note that, for this function to work properly, minimum size of an input buffer must be 192KB.
139
+ ==> The memory position where the next input data block must start is provided as the result of the function.
140
+
141
+ Compression can then resume, using LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue(), as usual.
142
+
143
+ When compression is completed, a call to LZ4_freeHC() will release the memory used by the LZ4HC Data Structure.
144
+ */
145
+
146
+ int LZ4_sizeofStreamStateHC(void);
147
+ int LZ4_resetStreamStateHC(void* state, const char* inputBuffer);
148
+
149
+ /*
150
+ These functions achieve the same result as :
151
+ void* LZ4_createHC (const char* inputBuffer);
152
+
153
+ They are provided here to allow the user program to allocate memory using its own routines.
154
+
155
+ To know how much space must be allocated, use LZ4_sizeofStreamStateHC();
156
+ Note also that space must be aligned for pointers (32 or 64 bits).
157
+
158
+ Once space is allocated, you must initialize it using : LZ4_resetStreamStateHC(void* state, const char* inputBuffer);
159
+ void* state is a pointer to the space allocated.
160
+ It must be aligned for pointers (32 or 64 bits), and be large enough.
161
+ The parameter 'const char* inputBuffer' must, obviously, point at the beginning of input buffer.
162
+ The input buffer must be already allocated, and size at least 192KB.
163
+ 'inputBuffer' will also be the 'const char* source' of the first block.
164
+
165
+ The same space can be re-used multiple times, just by initializing it each time with LZ4_resetStreamState().
166
+ return value of LZ4_resetStreamStateHC() must be 0 is OK.
167
+ Any other value means there was an error (typically, state is not aligned for pointers (32 or 64 bits)).
168
+ */
169
+
170
+
171
+ #if defined (__cplusplus)
172
+ }
173
+ #endif
@@ -148,7 +148,7 @@ static VALUE lz4internal_uncompress(VALUE self, VALUE input, VALUE in_size, VALU
148
148
  result = rb_str_new(NULL, buf_size);
149
149
  buf = RSTRING_PTR(result);
150
150
 
151
- read_bytes = LZ4_uncompress_unknownOutputSize(src_p + header_size, buf, src_size - header_size, buf_size);
151
+ read_bytes = LZ4_decompress_safe(src_p + header_size, buf, src_size - header_size, buf_size);
152
152
  if (read_bytes < 0) {
153
153
  rb_raise(lz4_error, "Compressed data is maybe corrupted.");
154
154
  }
data/lib/lz4ruby.jar CHANGED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lz4-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: java
6
6
  authors:
7
7
  - KOMIYA Atsushi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-22 00:00:00.000000000 Z
11
+ date: 2014-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec