根据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
}