使用miniLZO压缩库的好处不多说了。下面是一个在实际使用中需注意的地方:
解压缩函数(下面任何一个):
/* decompression */
LZO_EXTERN(int)
lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ );
/* safe decompression with overrun testing */
LZO_EXTERN(int)
lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ );
实际上,在miniLZO压缩库给的testmini.c中已经看出来:
/*
* Step 4: decompress again, now going from 'out' to 'in'
*/
new_len = in_len;//!!!!
r = lzo1x_decompress(out,out_len,in,&new_len,NULL);
if (r == LZO_E_OK && new_len == in_len)
printf("decompressed %lu bytes back into %lu bytes\n",
(unsigned long) out_len, (unsigned long) in_len);
else
{
/* this should NEVER happen */
printf("internal error - decompression failed: %d\n", r);
return 1;
}