|
58 | 58 | #define LZ4_MEMORY_USAGE 14 |
59 | 59 |
|
60 | 60 | #define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */ |
61 | | -#define LZ4_COMPRESSBOUND(isize) \ |
62 | | - ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? \ |
63 | | - 0 : \ |
| 61 | +#define LZ4_COMPRESSBOUND(isize) \ |
| 62 | + ((unsigned int)(isize) > (unsigned int)LZ4_MAX_INPUT_SIZE ? \ |
| 63 | + 0 : \ |
64 | 64 | (isize) + ((isize) / 255) + 16) |
65 | 65 |
|
66 | 66 | #define LZ4_ACCELERATION_DEFAULT 1 |
|
83 | 83 | /*-************************************************************************ |
84 | 84 | * STREAMING CONSTANTS AND STRUCTURES |
85 | 85 | **************************************************************************/ |
86 | | -#define LZ4_STREAMSIZE \ |
87 | | - ((1UL << LZ4_MEMORY_USAGE) + \ |
| 86 | +#define LZ4_STREAM_MINSIZE \ |
| 87 | + ((1UL << LZ4_MEMORY_USAGE) + \ |
88 | 88 | 32) /* static size, for inter-version compatibility */ |
89 | | -#define LZ4_STREAMSIZE_VOIDP (LZ4_STREAMSIZE / sizeof(void *)) |
90 | | - |
91 | | -#define LZ4_STREAMDECODESIZE_U64 \ |
92 | | - (4 + ((sizeof(void *) == 16) ? 2 : 0) /*AS-400*/) |
93 | | -#define LZ4_STREAMDECODESIZE \ |
94 | | - (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long)) |
95 | 89 |
|
96 | 90 | #define LZ4_STREAMHCSIZE_SIZET (262192 / sizeof(size_t)) |
97 | 91 |
|
| 92 | +/*! LZ4_stream_t : |
| 93 | + * Never ever use below internal definitions directly ! |
| 94 | + * These definitions are not API/ABI safe, and may change in future versions. |
| 95 | + * If you need static allocation, declare or allocate an LZ4_stream_t object. |
| 96 | +**/ |
| 97 | + |
98 | 98 | /* |
99 | 99 | * LZ4_stream_t - information structure to track an LZ4 stream. |
100 | 100 | */ |
101 | 101 | typedef struct LZ4_stream_t_internal LZ4_stream_t_internal; |
102 | 102 | struct LZ4_stream_t_internal { |
103 | 103 | uint32_t hashTable[LZ4_HASH_SIZE_U32]; |
104 | | - uint32_t currentOffset; |
105 | | - uint32_t tableType; |
106 | 104 | const uint8_t *dictionary; |
107 | 105 | const LZ4_stream_t_internal *dictCtx; |
| 106 | + uint32_t currentOffset; |
| 107 | + uint32_t tableType; |
108 | 108 | uint32_t dictSize; |
| 109 | + /* Implicit padding to ensure structure is aligned */ |
109 | 110 | }; |
110 | 111 | typedef union { |
111 | | - void *table[LZ4_STREAMSIZE_VOIDP]; |
| 112 | + char minStateSize[LZ4_STREAM_MINSIZE]; |
112 | 113 | LZ4_stream_t_internal internal_donotuse; |
113 | 114 | } LZ4_stream_t; |
114 | 115 |
|
@@ -143,21 +144,27 @@ typedef union { |
143 | 144 | * |
144 | 145 | * init this structure using LZ4_setStreamDecode (or memset()) before first use |
145 | 146 | */ |
| 147 | +/*! LZ4_streamDecode_t : |
| 148 | + * Never ever use below internal definitions directly ! |
| 149 | + * These definitions are not API/ABI safe, and may change in future versions. |
| 150 | + * If you need static allocation, declare or allocate an LZ4_streamDecode_t object. |
| 151 | +**/ |
146 | 152 | typedef struct { |
147 | 153 | const uint8_t *externalDict; |
148 | | - size_t extDictSize; |
149 | 154 | const uint8_t *prefixEnd; |
| 155 | + size_t extDictSize; |
150 | 156 | size_t prefixSize; |
151 | 157 | } LZ4_streamDecode_t_internal; |
| 158 | +#define LZ4_STREAMDECODE_MINSIZE 32 |
152 | 159 | typedef union { |
153 | | - unsigned long long table[LZ4_STREAMDECODESIZE_U64]; |
| 160 | + char minStateSize[LZ4_STREAMDECODE_MINSIZE]; |
154 | 161 | LZ4_streamDecode_t_internal internal_donotuse; |
155 | 162 | } LZ4_streamDecode_t; |
156 | 163 |
|
157 | 164 | /*-************************************************************************ |
158 | 165 | * SIZE OF STATE |
159 | 166 | **************************************************************************/ |
160 | | -#define LZ4_MEM_COMPRESS LZ4_STREAMSIZE |
| 167 | +#define LZ4_MEM_COMPRESS sizeof(LZ4_stream_t) |
161 | 168 | #define LZ4HC_MEM_COMPRESS LZ4_STREAMHCSIZE |
162 | 169 |
|
163 | 170 | /*-************************************************************************ |
|
0 commit comments