dedup

deduplicating backup program
git clone git://git.2f30.org/dedup
Log | Files | Refs | README | LICENSE

commit 99e39cb4a6a9a5b21bae79d2e8c304019565ad93
parent 8a5d9a252075a8eeec32c53f362746e91386ef2b
Author: sin <sin@2f30.org>
Date:   Fri,  5 Apr 2019 17:44:55 +0100

Rename some vars

Diffstat:
Mchunker.c | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/chunker.c b/chunker.c @@ -96,14 +96,14 @@ match_pattern(struct chunker *chunker, size_t chunk_size, uint32_t sum) static size_t get_chunk_size(struct chunker *chunker) { - size_t chunk_size, win_size, i; + size_t max_chunk_size, win_size, i; uint32_t sum; uint8_t *bp; - chunk_size = chunker->wpos - chunker->rpos; + max_chunk_size = chunker->wpos - chunker->rpos; win_size = chunker->win_size; - if (chunk_size < win_size) - return chunk_size; + if (max_chunk_size < win_size) + return max_chunk_size; /* * To achieve better deduplication, we chunk blocks based on a @@ -115,18 +115,20 @@ get_chunk_size(struct chunker *chunker) */ bp = &chunker->buf[chunker->rpos]; sum = buzh_init(bp, win_size); - for (i = 0; i < chunk_size - win_size; i++) { + for (i = 0; i < max_chunk_size - win_size; i++) { + size_t chunk_size = i + win_size; + if (i > 0) { uint8_t out = bp[i - 1]; - uint8_t in = bp[i + win_size - 1]; + uint8_t in = bp[chunk_size - 1]; sum = buzh_update(sum, out, in, win_size); } - if (match_pattern(chunker, i + win_size, sum)) - return i + win_size; + if (match_pattern(chunker, chunk_size, sum)) + return chunk_size; } - return chunk_size; + return max_chunk_size; } struct chunker *