Zlib:Z_Partial_flush的deflatePrime数字
在ZLIB手册中,有人说z_partial_flush
始终冲洗一个额外的 10位。,以便我们使用deflateprime
在我们想附加时使用deflateprime
之后。
但是为什么那时gzlog.c
包含逻辑以动态查找位计数如果 *buf
。根据规格,这不需要,仅需要else
将其设置为10?
if (*buf) {
log->back = 1;
while ((*buf & ((uint)1 << (8 - log->back++))) == 0)
; /* guaranteed to terminate, since *buf != 0 */
}
else
log->back = 10;
In the ZLIB Manual it is stated that Z_PARTIAL_FLUSH
always flush an extra 10 bits. So that we correct for that using deflatePrime
when we want to append later.
But why then is gzlog.c
containing logic to find dynamically the bit count if *buf
. According to the specs this is not needed and only the else
is needed to set it to 10?
if (*buf) {
log->back = 1;
while ((*buf & ((uint)1 << (8 - log->back++))) == 0)
; /* guaranteed to terminate, since *buf != 0 */
}
else
log->back = 10;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为在大多数情况下,并非所有十个位都写了。只有在最后一个字节为零的情况下,全部都写了十位,因为偶然的(一个八个机会)在十位空静态块之前待写了六个零件。
Because most of the time not all of the ten bits are written. Only in the case where the last byte is a zero are all ten bits written, because by chance (a one-in-eight chance) there were six bits pending to be written before the ten-bit empty static block.