mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Use libzpaq backend for decompression.
This commit is contained in:
parent
f8d05b9a66
commit
a55250cf16
|
|
@ -469,4 +469,11 @@ extern "C" void zpaq_compress(uchar *c_buf, long long *c_len, uchar *s_buf, long
|
|||
compress (&bufR, &bufW, level);
|
||||
}
|
||||
|
||||
extern "C" void zpaq_decompress(uchar *s_buf, long long *d_len, uchar *c_buf, long long c_len) {
|
||||
bufRead bufR(c_buf, &c_len);
|
||||
bufWrite bufW(s_buf, d_len);
|
||||
|
||||
decompress(&bufR, &bufW);
|
||||
}
|
||||
|
||||
#endif // LIBZPAQ_H
|
||||
|
|
|
|||
1
lrzip.h
1
lrzip.h
|
|
@ -43,4 +43,5 @@ bool clear_tmpinfile(rzip_control *control);
|
|||
void close_tmpinbuf(rzip_control *control);
|
||||
bool initialize_control(rzip_control *control);
|
||||
extern void zpaq_compress(uchar *c_buf, long long *c_len, uchar *s_buf, long long s_len, int level);
|
||||
extern void zpaq_decompress(uchar *s_buf, long long *d_len, uchar *c_buf, long long c_len);
|
||||
#endif
|
||||
|
|
|
|||
30
stream.c
30
stream.c
|
|
@ -538,7 +538,36 @@ out_free:
|
|||
|
||||
try to decompress a buffer. Return 0 on success and -1 on failure.
|
||||
*/
|
||||
static int zpaq_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_thread *ucthread, long thread)
|
||||
{
|
||||
i64 dlen = ucthread->u_len;
|
||||
uchar *c_buf;
|
||||
int ret = 0;
|
||||
|
||||
c_buf = ucthread->s_buf;
|
||||
ucthread->s_buf = malloc(dlen);
|
||||
if (unlikely(!ucthread->s_buf)) {
|
||||
print_err("Failed to allocate %ld bytes for decompression\n", dlen);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
dlen = 0;
|
||||
zpaq_decompress(ucthread->s_buf, &dlen, c_buf, ucthread->c_len);
|
||||
|
||||
if (unlikely(dlen != ucthread->u_len)) {
|
||||
print_err("Inconsistent length after decompression. Got %ld bytes, expected %lld\n", dlen, ucthread->u_len);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
free(c_buf);
|
||||
out:
|
||||
if (ret == -1)
|
||||
ucthread->s_buf = c_buf;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int zpaq_decompress_buf(rzip_control *control, struct uncomp_thread *ucthread, long thread)
|
||||
{
|
||||
uchar *c_buf = NULL;
|
||||
|
|
@ -578,6 +607,7 @@ static int zpaq_decompress_buf(rzip_control *control, struct uncomp_thread *ucth
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int bzip2_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_thread *ucthread)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue