summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3.c
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r--xdelta3/xdelta3.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index 58fb8b5..88de13a 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -2629,15 +2629,14 @@ xd3_set_source (xd3_stream *stream,
2629 xd3_source *src) 2629 xd3_source *src)
2630{ 2630{
2631 xoff_t blk_num; 2631 xoff_t blk_num;
2632 xoff_t tail_size; 2632 usize_t tail_size;
2633 2633
2634 IF_DEBUG1 (DP(RINT "[set source] size %"Q"u\n", src->size)); 2634 IF_DEBUG1 (DP(RINT "[set source] size %"Q"u\n", src->size));
2635 2635
2636 if (src == NULL || src->size < stream->smatcher.large_look) { return 0; } 2636 if (src == NULL || src->size < stream->smatcher.large_look) { return 0; }
2637 2637
2638 stream->src = src; 2638 stream->src = src;
2639 blk_num = src->size / src->blksize; 2639 xd3_blksize_div (src->size, src, &blk_num, &tail_size);
2640 tail_size = src->size - (blk_num * src->blksize);
2641 src->blocks = blk_num + (tail_size > 0); 2640 src->blocks = blk_num + (tail_size > 0);
2642 src->onlastblk = xd3_bytes_on_srcblk (src, src->blocks - 1); 2641 src->onlastblk = xd3_bytes_on_srcblk (src, src->blocks - 1);
2643 src->srclen = 0; 2642 src->srclen = 0;
@@ -4416,8 +4415,7 @@ xd3_source_extend_match (xd3_stream *stream)
4416 * match_fwd/match_back and direction. Consolidate? */ 4415 * match_fwd/match_back and direction. Consolidate? */
4417 matchoff = stream->match_srcpos - stream->match_back; 4416 matchoff = stream->match_srcpos - stream->match_back;
4418 streamoff = stream->input_position - stream->match_back; 4417 streamoff = stream->input_position - stream->match_back;
4419 tryblk = matchoff / src->blksize; 4418 xd3_blksize_div (matchoff, src, &tryblk, &tryoff);
4420 tryoff = matchoff - (tryblk * src->blksize);
4421 4419
4422 /* this loops backward over source blocks */ 4420 /* this loops backward over source blocks */
4423 while (stream->match_back < stream->match_maxback) 4421 while (stream->match_back < stream->match_maxback)
@@ -4465,8 +4463,7 @@ xd3_source_extend_match (xd3_stream *stream)
4465 4463
4466 matchoff = stream->match_srcpos + stream->match_fwd; 4464 matchoff = stream->match_srcpos + stream->match_fwd;
4467 streamoff = stream->input_position + stream->match_fwd; 4465 streamoff = stream->input_position + stream->match_fwd;
4468 tryblk = matchoff / src->blksize; 4466 xd3_blksize_div (matchoff, src, & tryblk, & tryoff);
4469 tryoff = matchoff - (tryblk * src->blksize);
4470 4467
4471 /* Note: practically the same code as backwards case above: same comments */ 4468 /* Note: practically the same code as backwards case above: same comments */
4472 while (stream->match_fwd < stream->match_maxfwd) 4469 while (stream->match_fwd < stream->match_maxfwd)
@@ -4839,11 +4836,16 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point)
4839 while (stream->srcwin_cksum_pos < logical_input_cksum_pos && 4836 while (stream->srcwin_cksum_pos < logical_input_cksum_pos &&
4840 stream->srcwin_cksum_pos < stream->src->size) 4837 stream->srcwin_cksum_pos < stream->src->size)
4841 { 4838 {
4842 xoff_t blkno = stream->srcwin_cksum_pos / stream->src->blksize; 4839 xoff_t blkno;
4843 xoff_t blkbaseoffset = blkno * stream->src->blksize; 4840 xoff_t blkbaseoffset;
4844 ssize_t oldpos = stream->srcwin_cksum_pos - blkbaseoffset; 4841 usize_t blkrem;
4845 ssize_t blkpos = xd3_bytes_on_srcblk_fast (stream->src, blkno); 4842 ssize_t oldpos;
4843 ssize_t blkpos;
4846 int ret; 4844 int ret;
4845 xd3_blksize_div (stream->srcwin_cksum_pos,
4846 stream->src, &blkno, &blkrem);
4847 oldpos = blkrem;
4848 blkpos = xd3_bytes_on_srcblk_fast (stream->src, blkno);
4847 4849
4848 if (oldpos + stream->smatcher.large_look > blkpos) 4850 if (oldpos + stream->smatcher.large_look > blkpos)
4849 { 4851 {