diff options
author | Rob Landley <rob@landley.net> | 2006-11-26 18:27:33 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-11-26 18:27:33 -0500 |
commit | 28a0dec5dd19458200a18609ba0cc8c2f3b4d22f (patch) | |
tree | 90ce70a9cb2f4b5ef615535ccd335c03fdcfa6b8 /lib | |
parent | 2de8f3e38315f9ce99e6284f9bf7e1a918539fe3 (diff) | |
download | toybox-28a0dec5dd19458200a18609ba0cc8c2f3b4d22f.tar.gz |
Trawling through the archives: a broken test, an unnecessary memset, and a
unrolling a small memmove.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bunzip.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/bunzip.c b/lib/bunzip.c index 974fdf80..48c987a1 100644 --- a/lib/bunzip.c +++ b/lib/bunzip.c @@ -91,7 +91,7 @@ static unsigned int get_bits(bunzip_data *bd, char bits_wanted) // If we need to read more data from file into byte buffer, do so if (bd->inbufPos == bd->inbufCount) { - if (!(bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE))) + if (0 >= (bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE))) longjmp(bd->jmpbuf, RETVAL_UNEXPECTED_INPUT_EOF); bd->inbufPos = 0; } @@ -155,7 +155,6 @@ extern int read_bunzip_data(bunzip_data *bd) // values were present. We make a translation table to convert the symbols // back to the corresponding bytes. t = get_bits(bd, 16); - memset(symToByte,0,256); symTotal = 0; for (i=0; i<16; i++) { if (t&(1<<(15-i))) { @@ -182,7 +181,7 @@ extern int read_bunzip_data(bunzip_data *bd) // Decode MTF to get the next selector uc = mtfSymbol[j]; - memmove(mtfSymbol+1, mtfSymbol, j); + for (k=j; k; k--) mtfSymbol[k] = mtfSymbol[k-1]; mtfSymbol[0] = selectors[i] = uc; } // Read the huffman coding tables for each group, which code for symTotal |