flate

deflate implementation
git clone git://git.suckless.org/flate
Log | Files | Refs | README

commit d374cb0ffda5de8dbdf8d084f37d3118e582a282
parent 64ad43df7e9e67bde4f4008a233578ec63ef60cf
Author: nsz <nszabolcs@gmail.com>
Date:   Tue, 18 Aug 2009 14:58:57 +0200

+LzEnd, -accidental p4 opt
Diffstat:
Makefile | 2+-
deflate.c | 3++-
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ #CFLAGS=-g -Wall -ansi -pedantic -CFLAGS=-O3 -march=pentium4 -Wall -ansi -pedantic +CFLAGS=-O3 -Wall -ansi -pedantic LDFLAGS= SRC=inflate.c inflate_example.c inflate_simple.c \ deflate.c deflate_example.c diff --git a/deflate.c b/deflate.c @@ -24,6 +24,7 @@ enum { HistSize = 2*WinSize, /* history buffer size (64K, indexed with ushort) */ DstSize = WinSize + MaxMatch + 6, /* worst case compressed block size */ LzSize = 1 << 13, /* lz buffer size */ + LzEnd = LzSize - 2, /* guard that lzbuf does not overflow in the next iteration */ LzLitFlag = 1 << 15 /* marks literal run length in lz buffer */ }; @@ -539,7 +540,7 @@ static void startblock(State *s) { static int endblock(State *s) { int n; - if (s->pos >= EndPos || s->lz - s->lzbuf > LzSize - 3 || (s->eof && s->avail == 0)) { + if (s->pos >= EndPos || s->lz - s->lzbuf >= LzEnd || (s->eof && s->avail == 0)) { /* deflate block */ flushlit(s); if (s->prevm.len)