flate

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

commit 37a3362288c663677776c3c4cbe16411db7c81e1
parent 5e6d3c053b63218135c0fbfea835b18b225ec483
Author: nsz <nszabolcs@gmail.com>
Date:   Thu, 23 Apr 2009 11:51:18 +0200

inflate_simple -blocktype
Diffstat:
inflate_simple.c | 9+++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/inflate_simple.c b/inflate_simple.c @@ -222,9 +222,9 @@ static void decode_block(FlateStream *s, HuffTree *lt, HuffTree *dt) { static void inflate_uncompressed_block(FlateStream *s) { uint len; + s->nbits = 0; /* start block on a byte boundary */ len = (s->src[1] << 8) | s->src[0]; s->src += 4; - s->nbits = 0; /* start next block on a byte boundary */ while (len--) *s->dst++ = *s->src++; } @@ -243,8 +243,8 @@ static void inflate_dynamic_block(FlateStream *s) { /* initialize global (static) data */ void inflate_init(void) { - init_fixed_trees(); init_base_tables(); + init_fixed_trees(); } /* inflate stream from src to dst, return end pointer */ @@ -256,11 +256,8 @@ void *inflate(void *dst, void *src) { s.dst = dst; s.nbits = 0; do { - uint blocktype; - final = getbit(&s); - blocktype = getbits(&s, 2); - switch (blocktype) { + switch (getbits(&s, 2)) { case 0: inflate_uncompressed_block(&s); break;