Mercurial > hg > toybox
changeset 40:d046f8d1401e
Trawling through the archives: a broken test, an unnecessary memset, and a
unrolling a small memmove.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 26 Nov 2006 18:27:33 -0500 |
parents | 00e73c4dea66 |
children | a43bdc6f53af |
files | lib/bunzip.c |
diffstat | 1 files changed, 2 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/bunzip.c Sun Nov 26 17:19:18 2006 -0500 +++ b/lib/bunzip.c Sun Nov 26 18:27:33 2006 -0500 @@ -91,7 +91,7 @@ // 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 @@ // 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 @@ // 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