summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3.c
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2009-11-03 01:50:13 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2009-11-03 01:50:13 +0000
commit7f7ac45b750fe90bc0572c1a53981910d24b878a (patch)
treefedb4169e6e2e4babf3e59bb82684e6d762f90ab /xdelta3/xdelta3.c
parent9c3c0e573dd63bd1a0345d38f46594293d58c9d2 (diff)
Fixes for issue 94.
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r--xdelta3/xdelta3.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index 868c2ca..435e8d8 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -2583,17 +2583,16 @@ xd3_set_source (xd3_stream *stream,
2583 2583
2584 // If src->blksize is a power-of-two, xd3_blksize_div() will use 2584 // If src->blksize is a power-of-two, xd3_blksize_div() will use
2585 // shift and mask rather than divide. Check that here. 2585 // shift and mask rather than divide. Check that here.
2586 if (xd3_check_pow2 (src->blksize, &shiftby) == 0) 2586 if (!xd3_check_pow2 (src->blksize, &shiftby) == 0)
2587 {
2588 src->shiftby = shiftby;
2589 src->maskby = (1 << shiftby) - 1;
2590 }
2591 else
2592 { 2587 {
2588 int check;
2593 src->blksize = xd3_pow2_roundup(src->blksize); 2589 src->blksize = xd3_pow2_roundup(src->blksize);
2594 xd3_check_pow2 (src->blksize, &shiftby); 2590 check = xd3_check_pow2 (src->blksize, &shiftby);
2591 XD3_ASSERT (check == 0);
2595 } 2592 }
2596 2593
2594 src->shiftby = shiftby;
2595 src->maskby = (1 << shiftby) - 1;
2597 return 0; 2596 return 0;
2598} 2597}
2599 2598
@@ -2777,14 +2776,14 @@ xd3_iopt_finish_encoding (xd3_stream *stream, xd3_rinst *inst)
2777 XD3_ASSERT (inst->addr + inst->size <= src->srcbase + src->srclen); 2776 XD3_ASSERT (inst->addr + inst->size <= src->srcbase + src->srclen);
2778 addr = (inst->addr - src->srcbase); 2777 addr = (inst->addr - src->srcbase);
2779 stream->n_scpy += 1; 2778 stream->n_scpy += 1;
2780 stream->l_scpy += inst->size; 2779 stream->l_scpy += (xoff_t) inst->size;
2781 } 2780 }
2782 else 2781 else
2783 { 2782 {
2784 /* with source window: target copy address is offset by taroff. */ 2783 /* with source window: target copy address is offset by taroff. */
2785 addr = stream->taroff + (usize_t) inst->addr; 2784 addr = stream->taroff + (usize_t) inst->addr;
2786 stream->n_tcpy += 1; 2785 stream->n_tcpy += 1;
2787 stream->l_tcpy += inst->size; 2786 stream->l_tcpy += (xoff_t) inst->size;
2788 } 2787 }
2789 } 2788 }
2790 else 2789 else
@@ -3483,10 +3482,11 @@ xd3_emit_hdr (xd3_stream *stream)
3483 a32 = stream->recode_adler32; 3482 a32 = stream->recode_adler32;
3484 } 3483 }
3485 3484
3486 send[0] = (a32 >> 24); 3485 /* Four bytes. */
3487 send[1] = (a32 >> 16); 3486 send[0] = (uint8_t) (a32 >> 24);
3488 send[2] = (a32 >> 8); 3487 send[1] = (uint8_t) (a32 >> 16);
3489 send[3] = (a32 & 0xff); 3488 send[2] = (uint8_t) (a32 >> 8);
3489 send[3] = (uint8_t) (a32 & 0x000000FFU);
3490 3490
3491 if ((ret = xd3_emit_bytes (stream, & HDR_TAIL (stream), send, 4))) 3491 if ((ret = xd3_emit_bytes (stream, & HDR_TAIL (stream), send, 4)))
3492 { 3492 {
@@ -4374,7 +4374,7 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos)
4374 * src->size/srcpos values and take the min. */ 4374 * src->size/srcpos values and take the min. */
4375 if (srcpos < (xoff_t) stream->match_maxback) 4375 if (srcpos < (xoff_t) stream->match_maxback)
4376 { 4376 {
4377 stream->match_maxback = srcpos; 4377 stream->match_maxback = (usize_t) srcpos;
4378 } 4378 }
4379 4379
4380 if (stream->src->eof_known) 4380 if (stream->src->eof_known)
@@ -4383,7 +4383,7 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos)
4383 4383
4384 if (srcavail < (xoff_t) stream->match_maxfwd) 4384 if (srcavail < (xoff_t) stream->match_maxfwd)
4385 { 4385 {
4386 stream->match_maxfwd = srcavail; 4386 stream->match_maxfwd = (usize_t) srcavail;
4387 } 4387 }
4388 } 4388 }
4389 4389