diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2016-06-29 13:53:21 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2016-06-29 14:01:24 (GMT) |
commit | bc342ab94c9df9af8093d3b1c99be944b9685b9e (patch) | |
tree | f01c8946298e327b0259550bfa420304793c79de | |
parent | c8a573d32c3347285d09154ed6d1a55af52655bc (diff) | |
download | lz4-bc342ab94c9df9af8093d3b1c99be944b9685b9e.zip lz4-bc342ab94c9df9af8093d3b1c99be944b9685b9e.tar.gz lz4-bc342ab94c9df9af8093d3b1c99be944b9685b9e.tar.bz2 |
minor refactoring
-rw-r--r-- | lib/lz4.c | 19 | ||||
-rw-r--r-- | programs/.gitignore | 5 |
2 files changed, 14 insertions, 10 deletions
@@ -1150,8 +1150,7 @@ FORCE_INLINE int LZ4_decompress_generic( if ((endOnInput) && (unlikely(outputSize==0))) return ((inputSize==1) && (*ip==0)) ? 0 : -1; /* Empty output buffer */ if ((!endOnInput) && (unlikely(outputSize==0))) return (*ip==0?1:-1); - - /* Main Loop */ + /* Main Loop : decode sequences */ while (1) { unsigned token; size_t length; @@ -1214,21 +1213,21 @@ FORCE_INLINE int LZ4_decompress_generic( if (length <= (size_t)(lowPrefix-match)) { /* match can be copied as a single segment from external dictionary */ - match = dictEnd - (lowPrefix-match); - memmove(op, match, length); op += length; + memmove(op, dictEnd - (lowPrefix-match), length); + op += length; } else { /* match encompass external dictionary and current block */ - size_t copySize = (size_t)(lowPrefix-match); + size_t const copySize = (size_t)(lowPrefix-match); + size_t const restSize = length - copySize; memcpy(op, dictEnd - copySize, copySize); op += copySize; - copySize = length - copySize; - if (copySize > (size_t)(op-lowPrefix)) { /* overlap copy */ - BYTE* const endOfMatch = op + copySize; + if (restSize > (size_t)(op-lowPrefix)) { /* overlap copy */ + BYTE* const endOfMatch = op + restSize; const BYTE* copyFrom = lowPrefix; while (op < endOfMatch) *op++ = *copyFrom++; } else { - memcpy(op, lowPrefix, copySize); - op += copySize; + memcpy(op, lowPrefix, restSize); + op += restSize; } } continue; diff --git a/programs/.gitignore b/programs/.gitignore index bba3110..b9798c6 100644 --- a/programs/.gitignore +++ b/programs/.gitignore @@ -1,4 +1,9 @@ # local binary (Makefile) lz4 lz4c32 +datagen +fuzzer *.exe + +# tests files +tmp* |