Skip to content

Commit 2cba504

Browse files
xNombrecyberknight777
authored andcommitted
lz4: Update to version 1.9.4
Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com> Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
1 parent 7da05b6 commit 2cba504

3 files changed

Lines changed: 302 additions & 203 deletions

File tree

include/linux/lz4.h

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
#define LZ4_MEMORY_USAGE 14
5959

6060
#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 : \
6464
(isize) + ((isize) / 255) + 16)
6565

6666
#define LZ4_ACCELERATION_DEFAULT 1
@@ -83,32 +83,33 @@
8383
/*-************************************************************************
8484
* STREAMING CONSTANTS AND STRUCTURES
8585
**************************************************************************/
86-
#define LZ4_STREAMSIZE \
87-
((1UL << LZ4_MEMORY_USAGE) + \
86+
#define LZ4_STREAM_MINSIZE \
87+
((1UL << LZ4_MEMORY_USAGE) + \
8888
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))
9589

9690
#define LZ4_STREAMHCSIZE_SIZET (262192 / sizeof(size_t))
9791

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+
9898
/*
9999
* LZ4_stream_t - information structure to track an LZ4 stream.
100100
*/
101101
typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
102102
struct LZ4_stream_t_internal {
103103
uint32_t hashTable[LZ4_HASH_SIZE_U32];
104-
uint32_t currentOffset;
105-
uint32_t tableType;
106104
const uint8_t *dictionary;
107105
const LZ4_stream_t_internal *dictCtx;
106+
uint32_t currentOffset;
107+
uint32_t tableType;
108108
uint32_t dictSize;
109+
/* Implicit padding to ensure structure is aligned */
109110
};
110111
typedef union {
111-
void *table[LZ4_STREAMSIZE_VOIDP];
112+
char minStateSize[LZ4_STREAM_MINSIZE];
112113
LZ4_stream_t_internal internal_donotuse;
113114
} LZ4_stream_t;
114115

@@ -143,21 +144,27 @@ typedef union {
143144
*
144145
* init this structure using LZ4_setStreamDecode (or memset()) before first use
145146
*/
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+
**/
146152
typedef struct {
147153
const uint8_t *externalDict;
148-
size_t extDictSize;
149154
const uint8_t *prefixEnd;
155+
size_t extDictSize;
150156
size_t prefixSize;
151157
} LZ4_streamDecode_t_internal;
158+
#define LZ4_STREAMDECODE_MINSIZE 32
152159
typedef union {
153-
unsigned long long table[LZ4_STREAMDECODESIZE_U64];
160+
char minStateSize[LZ4_STREAMDECODE_MINSIZE];
154161
LZ4_streamDecode_t_internal internal_donotuse;
155162
} LZ4_streamDecode_t;
156163

157164
/*-************************************************************************
158165
* SIZE OF STATE
159166
**************************************************************************/
160-
#define LZ4_MEM_COMPRESS LZ4_STREAMSIZE
167+
#define LZ4_MEM_COMPRESS sizeof(LZ4_stream_t)
161168
#define LZ4HC_MEM_COMPRESS LZ4_STREAMHCSIZE
162169

163170
/*-************************************************************************

lib/lz4/lz4_compress.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,8 @@ int LZ4_saveDict(LZ4_stream_t *LZ4_dict, char *safeBuffer, int dictSize)
10681068
const BYTE *const previousDictEnd =
10691069
dict->dictionary + dict->dictSize;
10701070
assert(dict->dictionary);
1071-
LZ4_memmove(safeBuffer, previousDictEnd - dictSize, dictSize);
1071+
LZ4_memmove(safeBuffer, previousDictEnd - dictSize,
1072+
(size_t)dictSize);
10721073
}
10731074

10741075
dict->dictionary = (const BYTE *)safeBuffer;

0 commit comments

Comments
 (0)