Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\decompress_unlz4.c Create Date:2022-07-28 06:17:51
Last Modify:2020-03-15 22:50:34 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:unlz4

Proto:STATIC inline int __attribute__((__section__(".init.text"))) __attribute__((__cold__))unlz4(u8 *input, long in_len, long (*fill)(void *, unsigned long ), long (*flush)(void *, unsigned long ), u8 *output, long *posp, void (*error)(char *x))

Type:int

Parameter:

TypeParameterName
u8 *input
longin_len
long (*fill
long (*flush
u8 *output
long *posp
void (*error
37  ret = -1
38  chunksize = 0
39  uncomp_chunksize = Note: Uncompressed chunk size is used in the compressor side* (userspace side for compression).* It is hardcoded because there is not proper way to extract it* from the binary stream which is generated by the preliminary* version of LZ4 tool so far.
43  size = in_len
45  out_len = get_unaligned_le32(input + in_len)
50  If output Then
51  outp = output
52  Else if Not flush Then
53  error("NULL output pointer and no flush function provided")
54  Go to exit_0
55  Else
56  outp = large_malloc(uncomp_chunksize)
57  If Not outp Then
58  error("Could not allocate output buffer")
59  Go to exit_0
63  If input && fill Then
64  error("Both input pointer and fill function provided,")
65  Go to exit_1
66  Else if input Then
67  inp = input
68  Else if Not fill Then
69  error("NULL input pointer and missing fill function")
70  Go to exit_1
71  Else
72  inp = large_malloc(LZ4_compressBound() - Max. output size in worst case szenarios*@isize: Size of the input data* Return: Max. size LZ4 may output in a "worst case" szenario* (data not compressible))
73  If Not inp Then
74  error("Could not allocate input buffer")
75  Go to exit_1
78  inp_start = inp
80  If posp Then posp = 0
83  If fill Then
84  size = fill(inp, 4)
85  If size < 4 Then
86  error("data corrupted")
87  Go to exit_2
91  chunksize = get_unaligned_le32(inp)
92  If chunksize == ARCHIVE_MAGICNUMBER Then
93  If Not fill Then
94  inp += 4
95  size -= 4
97  Else
98  error("invalid header")
99  Go to exit_2
102  If posp Then posp += 4
105  cycle
107  If fill Then
108  size = fill(inp, 4)
109  If size == 0 Then Break
111  If size < 4 Then
112  error("data corrupted")
113  Go to exit_2
117  chunksize = get_unaligned_le32(inp)
118  If chunksize == ARCHIVE_MAGICNUMBER Then
119  If Not fill Then
120  inp += 4
121  size -= 4
123  If posp Then posp += 4
125  Continue
129  If posp Then posp += 4
132  If Not fill Then
133  inp += 4
134  size -= 4
135  Else
137  error("chunk length is longer than allocated")
138  Go to exit_2
140  size = fill(inp, chunksize)
141  If size < chunksize Then
142  error("data corrupted")
143  Go to exit_2
147  If out_len >= uncomp_chunksize Then
149  out_len -= dest_len
150  Else dest_len = out_len
153  ret = LZ4_decompress_fast(inp, outp, dest_len)
154  chunksize = ret
161  If ret < 0 Then
162  error("Decoding failed")
163  Go to exit_2
166  ret = -1
167  If flush && flush(outp, dest_len) != dest_len Then Go to exit_2
169  If output Then outp += dest_len
171  If posp Then posp += chunksize
174  If Not fill Then
175  size -= chunksize
177  If size == 0 Then Break
179  Else if size < 0 Then
180  error("data corrupted")
181  Go to exit_2
183  inp += chunksize
187  ret = 0
188  exit_2 :
189  If Not input Then large_free(inp_start)
191  exit_1 :
192  If Not output Then large_free(outp)
194  exit_0 :
195  Return ret
Caller
NameDescribe
__decompress