C zlib:如何标注有效值

C zlib:如何标注有效值,c,compression,buffer,zlib,deflate,C,Compression,Buffer,Zlib,Deflate,我想缩小一小块内存(zlib有一个函数,可以计算缓冲区缩小到的最大大小。您的假设是正确的-返回值是输入缓冲区的大小+头大小。缩小后,您可以重新定位缓冲区以回收“浪费”的内存。 从zlib.h: ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); /* deflateBound() returns an upper bound on the compressed size after def

我想缩小一小块内存(zlib有一个函数,可以计算缓冲区缩小到的最大大小。您的假设是正确的-返回值是输入缓冲区的大小+头大小。缩小后,您可以重新定位缓冲区以回收“浪费”的内存。
从zlib.h:

ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen));
/*
   deflateBound() returns an upper bound on the compressed size after
   deflation of sourceLen bytes.  It must be called after deflateInit() or
   deflateInit2(), and after deflateSetHeader(), if used.  This would be used
   to allocate an output buffer for deflation in a single pass, and so would be
   called before deflate().
*/