Zlib:Z_Partial_flush的deflatePrime数字

发布于 2025-02-12 11:44:53 字数 578 浏览 3 评论 0原文

在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

套路撩心 2025-02-19 11:44:53

因为在大多数情况下,并非所有十个位都写了。只有在最后一个字节为零的情况下,全部都写了十位,因为偶然的(一个八个机会)在十位空静态块之前待写了六个零件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文