根据 zlib 手册,此错误表示“输出缓冲区中没有足够的空间”。下面是我非常基本的压缩程序。我还确认 nUncompressedBuffer 已正确填充。您还会注意到 nCompressedBuffer 比 nUncompressedBuffer 大得多,并且没有任何缓冲区大小的组合对我有用。请帮忙 :)
CDataBlock* CCompressionManager::Compress2(CDataBlock* pInBlock)
{
U8 nCompressedBuffer[100000];
U8 nUncompressedBuffer[1000];
S8 status = 0;
uLongf compressedBufferLength = 0;
pInBlock->GetData()->GetData( nUncompressedBuffer, 1000 );
status = compress2( nCompressedBuffer,
&compressedBufferLength,
nUncompressedBuffer,
pInBlock->GetData()->GetLength(),
Z_DEFAULT_COMPRESSION );
printf("status is: %i\n", status);
//this always results in -5 Z_BUF_ERROR
}