4
File modified for the Linux Kernel by
5
Zeev Tarantov <zeev.tarantov@gmail.com>
11
#define CSNAPPY_VERSION 4
13
#define CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO 15
14
#define CSNAPPY_WORKMEM_BYTES (1 << CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO)
17
#define __attribute__(x) /*NOTHING*/
21
* Returns the maximal size of the compressed representation of
22
* input data that is "source_len" bytes in length;
25
csnappy_max_compressed_length(uint32_t source_len) __attribute__((const));
28
* Flat array compression that does not emit the "uncompressed length"
29
* prefix. Compresses "input" array to the "output" array.
31
* REQUIRES: "input" is at most 32KiB long.
32
* REQUIRES: "output" points to an array of memory that is at least
33
* "csnappy_max_compressed_length(input_length)" in size.
34
* REQUIRES: working_memory has (1 << workmem_bytes_power_of_two) bytes.
35
* REQUIRES: 9 <= workmem_bytes_power_of_two <= 15.
37
* Returns an "end" pointer into "output" buffer.
38
* "end - output" is the compressed size of "input".
41
csnappy_compress_fragment(
43
const uint32_t input_length,
46
const int workmem_bytes_power_of_two);
49
* REQUIRES: "compressed" must point to an area of memory that is at
50
* least "csnappy_max_compressed_length(input_length)" bytes in length.
51
* REQUIRES: working_memory has (1 << workmem_bytes_power_of_two) bytes.
52
* REQUIRES: 9 <= workmem_bytes_power_of_two <= 15.
54
* Takes the data stored in "input[0..input_length-1]" and stores
55
* it in the array pointed to by "compressed".
57
* "*out_compressed_length" is set to the length of the compressed output.
62
uint32_t input_length,
64
uint32_t *out_compressed_length,
66
const int workmem_bytes_power_of_two);
69
* Reads header of compressed data to get stored length of uncompressed data.
70
* REQUIRES: start points to compressed data.
71
* REQUIRES: n is length of available compressed data.
73
* Returns SNAPPY_E_HEADER_BAD on error.
74
* Returns number of bytes read from input on success.
75
* Stores decoded length into *result.
78
csnappy_get_uncompressed_length(
84
* Safely decompresses all data from array "src" of length "src_len" containing
85
* entire compressed stream (with header) into array "dst" of size "dst_len".
86
* REQUIRES: dst_len is at least csnappy_get_uncompressed_length(...).
88
* Iff successful, returns CSNAPPY_E_OK.
89
* If recorded length in header is greater than dst_len, returns
90
* CSNAPPY_E_OUTPUT_INSUF.
91
* If compressed data is malformed, does not write more than dst_len into dst.
101
* Safely decompresses stream src_len bytes long read from src to dst.
102
* Amount of available space at dst must be provided in *dst_len by caller.
103
* If compressed stream needs more space, it will not overflow and return
104
* CSNAPPY_E_OUTPUT_OVERRUN.
105
* On success, sets *dst_len to actal number of bytes decompressed.
106
* Iff successful, returns CSNAPPY_E_OK.
109
csnappy_decompress_noheader(
116
* Return values (< 0 = Error)
118
#define CSNAPPY_E_OK 0
119
#define CSNAPPY_E_HEADER_BAD (-1)
120
#define CSNAPPY_E_OUTPUT_INSUF (-2)
121
#define CSNAPPY_E_OUTPUT_OVERRUN (-3)
122
#define CSNAPPY_E_INPUT_NOT_CONSUMED (-4)
123
#define CSNAPPY_E_DATA_MALFORMED (-5)