char* zip_buf=new char[4096]; uLong zip_buf_len = compressBound(nleft_); //计算压缩后的大小 char* buf=new char[zip_buf_len]; //zip_buf 压缩之后的内容 zip_buf_len 压缩之后的大小 buf 要压缩的数据 4096 压缩之前的大小 if (compress((Bytef*)(zip_buf), &zip_buf_len, (const Bytef*)(buf), 4096) != Z_OK) { OutputDebugStringA("compress failed!\n"); return; }
压缩 compress
//un_zip_text是解压之后的内容 text_len 是解压之后的大小 zip_text 是要解压的内容 zip_text_len_是要解压的大小
int ret = uncompress((Bytef*)(un_zip_text_.get()), &un_text_len_, (const Bytef*(zip_text_), zip_text_len_);
if (ret != Z_OK)
{
OutputDebugStringA("uncompress failed!\n");
return;
}
解压 uncompress