Source
65
65
66
66
if (input && fill) {
67
67
error("Both input pointer and fill function provided,");
68
68
goto exit_1;
69
69
} else if (input) {
70
70
inp = input;
71
71
} else if (!fill) {
72
72
error("NULL input pointer and missing fill function");
73
73
goto exit_1;
74
74
} else {
75
-
inp = large_malloc(lz4_compressbound(uncomp_chunksize));
75
+
inp = large_malloc(LZ4_compressBound(uncomp_chunksize));
76
76
if (!inp) {
77
77
error("Could not allocate input buffer");
78
78
goto exit_1;
79
79
}
80
80
}
81
81
inp_start = inp;
82
82
83
83
if (posp)
84
84
*posp = 0;
85
85
129
129
}
130
130
131
131
132
132
if (posp)
133
133
*posp += 4;
134
134
135
135
if (!fill) {
136
136
inp += 4;
137
137
size -= 4;
138
138
} else {
139
-
if (chunksize > lz4_compressbound(uncomp_chunksize)) {
139
+
if (chunksize > LZ4_compressBound(uncomp_chunksize)) {
140
140
error("chunk length is longer than allocated");
141
141
goto exit_2;
142
142
}
143
143
size = fill(inp, chunksize);
144
144
if (size < chunksize) {
145
145
error("data corrupted");
146
146
goto exit_2;
147
147
}
148
148
}
149
149
#ifdef PREBOOT
150
150
if (out_len >= uncomp_chunksize) {
151
151
dest_len = uncomp_chunksize;
152
152
out_len -= dest_len;
153
153
} else
154
154
dest_len = out_len;
155
-
ret = lz4_decompress(inp, &chunksize, outp, dest_len);
155
+
156
+
ret = LZ4_decompress_fast(inp, outp, dest_len);
157
+
chunksize = ret;
156
158
#else
157
159
dest_len = uncomp_chunksize;
158
-
ret = lz4_decompress_unknownoutputsize(inp, chunksize, outp,
159
-
&dest_len);
160
+
161
+
ret = LZ4_decompress_safe(inp, outp, chunksize, dest_len);
162
+
dest_len = ret;
160
163
#endif
161
164
if (ret < 0) {
162
165
error("Decoding failed");
163
166
goto exit_2;
164
167
}
165
168
166
169
ret = -1;
167
170
if (flush && flush(outp, dest_len) != dest_len)
168
171
goto exit_2;
169
172
if (output)