我正在尝试使用
LzmaLib的LzmaCompress()和LzmaDecompress()和缓冲区,调整
here提供的示例.
我正在使用~3MB缓冲区进行测试,并且压缩函数似乎工作正常(产生~1.2MB的压缩缓冲区),但是当我尝试解压缩时,它只提取~300字节并返回SZ_ERROR_DATA.
提取的少数字节是正确的,但我不知道为什么它会停在那里.
我的代码:
#include
#include
#include "LzmaLib.h"
void compress(
unsigned char **outBuf, size_t *dstLen,
unsigned char *inBuf, size_t srcLen)
{
unsigned propsSize = LZMA_PROPS_SIZE;
*dstLen = srcLen + srcLen / 3 + 128;
*outBuf = (unsigned char*)malloc(propsSize + *dstLen);
int res = LzmaCompress(
(unsigned char*)(*outBuf + LZMA_PROPS_SIZE), dstLen,
inBuf, srcLen,
*outBuf, &propsSize,
-1, 0, -1, -1, -1, -1, -1);
assert(res == SZ_OK);
*dstLen = *dstLen + LZMA_PROPS_SIZE;
}
void uncompress(