[hackers] [flate] deflate clean up || nsz

From: <hg_AT_suckless.org>
Date: Fri, 21 Aug 2009 13:50:12 +0000 (UTC)

changeset: 101:33793714fbe1
user: nsz <nszabolcs_AT_gmail.com>
date: Sun Aug 16 13:53:56 2009 +0200
files: deflate.c
description:
deflate clean up

diff -r 7d681e91154a -r 33793714fbe1 deflate.c
--- a/deflate.c Sun Aug 16 11:03:32 2009 +0200
+++ b/deflate.c Sun Aug 16 13:53:56 2009 +0200
@@ -2,8 +2,6 @@
 #include <string.h>
 #include "flate.h"
 
-#include <stdio.h>
-
 enum {
         CodeBits = 16, /* max number of bits in a code + 1 */
         EOB = 256, /* end of block symbol */
@@ -328,7 +326,7 @@
         uchar *h;
         int dynsize, fixsize, uncsize;
         int blocklen = s->pos - s->startpos;
-int dyntree;
+/* int dyntree; */
 
         /* calc dynamic codes */
         hufflens(llen, s->lfreq, Nlitlen, CodeBits-1);
@@ -359,7 +357,7 @@
                 if (c == 18)
                         dynsize += 7;
         }
-dyntree = dynsize - 3;
+/* dyntree = dynsize - 3; */
         for (lz = s->lzbuf, h = s->hist + s->startpos; lz != s->lz; lz++)
                 if (lz->bits & LzLitFlag)
                         for (n = lz->n; n > 0; n--, h++) {
@@ -416,11 +414,11 @@
                 memcpy(s->dst, s->hist + s->startpos, blocklen);
                 s->dst += blocklen;
         }
-
+/*
 fprintf(stderr, "blen:%d [%d,%d] lzlen:%d dynlen:%d (tree:%d rate:%.3f) fixlen:%d (rate:%.3f) unclen:%d (rate:%.3f) avail:%d\n",
         blocklen, s->startpos, s->pos, s->lz - s->lzbuf, dynsize, dyntree, dynsize/(float)blocklen,
         fixsize, fixsize/(float)blocklen, uncsize, uncsize/(float)blocklen, s->avail);
-
+*/
 }
 
 /* find n in base */
@@ -539,7 +537,7 @@
 correctness assertions:
         - pos < 64K in updatechain (head and chain is ushort)
         - updatechain has at least MinMatch input (except at eof)
- - getmatch has at least MaxMatch input
+ - getmatch has at least MaxMatch input in hist
         - getmatch has at least HistSafe history
         - lzbuf does not overflow before endblock
         - dstbuf does not overflow before endblock
@@ -551,8 +549,6 @@
 static int updatehist(State *s) {
         int n, k;
 
- if (s->avail > HistEnd)
- return 1;
         if (s->pos >= HistSize - HistEnd) {
                 /* shift hist */
                 memcpy(s->hist, s->hist + WinSize, HistSize - WinSize);
@@ -563,10 +559,10 @@
                 s->startpos -= WinSize;
                 s->pos -= WinSize;
         }
- if (!s->eof) {
+ if (s->avail <= HistEnd && !s->eof) {
                 /* fill hist */
                 k = s->srcend - s->src;
- n = HistSize - s->pos - s->avail; /* s->avail + n >= MaxMatch */
+ n = HistSize - s->pos - s->avail; /* s->avail + n > HistEnd */
                 if (k > n)
                         k = n;
                 memcpy(s->hist + s->pos + s->avail, s->src, k);
Received on Fri Aug 21 2009 - 13:50:12 UTC

This archive was generated by hypermail 2.2.0 : Fri Aug 21 2009 - 14:00:07 UTC