… | |
… | |
47 | * Size of hashtable is (1 << HLOG) * sizeof (char *) |
47 | * Size of hashtable is (1 << HLOG) * sizeof (char *) |
48 | * decompression is independent of the hash table size |
48 | * decompression is independent of the hash table size |
49 | * the difference between 15 and 14 is very small |
49 | * the difference between 15 and 14 is very small |
50 | * for small blocks (and 14 is usually a bit faster). |
50 | * for small blocks (and 14 is usually a bit faster). |
51 | * For a low-memory/faster configuration, use HLOG == 13; |
51 | * For a low-memory/faster configuration, use HLOG == 13; |
52 | * For best compression, use 15 or 16 (or more, up to 23). |
52 | * For best compression, use 15 or 16 (or more, up to 22). |
53 | */ |
53 | */ |
54 | #ifndef HLOG |
54 | #ifndef HLOG |
55 | # define HLOG 16 |
55 | # define HLOG 16 |
56 | #endif |
56 | #endif |
57 | |
57 | |
… | |
… | |
119 | */ |
119 | */ |
120 | #ifndef CHECK_INPUT |
120 | #ifndef CHECK_INPUT |
121 | # define CHECK_INPUT 1 |
121 | # define CHECK_INPUT 1 |
122 | #endif |
122 | #endif |
123 | |
123 | |
|
|
124 | /* |
|
|
125 | * Whether to store pointers or offsets inside the hash table. On |
|
|
126 | * 64 bit architetcures, pointers take up twice as much space, |
|
|
127 | * and might also be slower. Default is to autodetect. |
|
|
128 | */ |
|
|
129 | /*#define LZF_USER_OFFSETS autodetect */ |
|
|
130 | |
124 | /*****************************************************************************/ |
131 | /*****************************************************************************/ |
125 | /* nothing should be changed below */ |
132 | /* nothing should be changed below */ |
126 | |
133 | |
127 | #ifdef __cplusplus |
134 | #ifdef __cplusplus |
128 | # include <cstring> |
135 | # include <cstring> |
|
|
136 | # include <climits> |
129 | using namespace std; |
137 | using namespace std; |
130 | #else |
138 | #else |
131 | # include <string.h> |
139 | # include <string.h> |
|
|
140 | # include <limits.h> |
|
|
141 | #endif |
|
|
142 | |
|
|
143 | #ifndef LZF_USE_OFFSETS |
|
|
144 | # if defined (WIN32) |
|
|
145 | # define LZF_USE_OFFSETS defined(_M_X64) |
|
|
146 | # else |
|
|
147 | # if __cplusplus > 199711L |
|
|
148 | # include <cstdint> |
|
|
149 | # else |
|
|
150 | # include <stdint.h> |
|
|
151 | # endif |
|
|
152 | # define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU) |
|
|
153 | # endif |
132 | #endif |
154 | #endif |
133 | |
155 | |
134 | typedef unsigned char u8; |
156 | typedef unsigned char u8; |
135 | |
157 | |
|
|
158 | #if LZF_USE_OFFSETS |
|
|
159 | # define LZF_HSLOT_BIAS ((const u8 *)in_data) |
|
|
160 | typedef unsigned int LZF_HSLOT; |
|
|
161 | #else |
|
|
162 | # define LZF_HSLOT_BIAS 0 |
|
|
163 | typedef const u8 *LZF_HSLOT; |
|
|
164 | #endif |
|
|
165 | |
136 | typedef const u8 *LZF_STATE[1 << (HLOG)]; |
166 | typedef LZF_HSLOT LZF_STATE[1 << (HLOG)]; |
137 | |
167 | |
138 | #if !STRICT_ALIGN |
168 | #if !STRICT_ALIGN |
139 | /* for unaligned accesses we need a 16 bit datatype. */ |
169 | /* for unaligned accesses we need a 16 bit datatype. */ |
140 | # ifdef __cplusplus |
|
|
141 | # include <climits> |
|
|
142 | # else |
|
|
143 | # include <limits.h> |
|
|
144 | # endif |
|
|
145 | # if USHRT_MAX == 65535 |
170 | # if USHRT_MAX == 65535 |
146 | typedef unsigned short u16; |
171 | typedef unsigned short u16; |
147 | # elif UINT_MAX == 65535 |
172 | # elif UINT_MAX == 65535 |
148 | typedef unsigned int u16; |
173 | typedef unsigned int u16; |
149 | # else |
174 | # else |