diff options
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r-- | xdelta3/xdelta3.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 8513aac..3dcf80c 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -1265,7 +1265,7 @@ xd3_decode_bytes (xd3_stream *stream, uint8_t *buf, usize_t *pos, usize_t size) | |||
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | want = size - *pos; | 1267 | want = size - *pos; |
1268 | take = min (want, stream->avail_in); | 1268 | take = xd3_min (want, stream->avail_in); |
1269 | 1269 | ||
1270 | memcpy (buf + *pos, stream->next_in, (size_t) take); | 1270 | memcpy (buf + *pos, stream->next_in, (size_t) take); |
1271 | 1271 | ||
@@ -1325,7 +1325,7 @@ xd3_emit_bytes (xd3_stream *stream, | |||
1325 | output = (*outputp) = aoutput; | 1325 | output = (*outputp) = aoutput; |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | take = min (output->avail - output->next, size); | 1328 | take = xd3_min (output->avail - output->next, size); |
1329 | 1329 | ||
1330 | memcpy (output->base + output->next, base, (size_t) take); | 1330 | memcpy (output->base + output->next, base, (size_t) take); |
1331 | 1331 | ||
@@ -2237,7 +2237,7 @@ xd3_set_source (xd3_stream *stream, | |||
2237 | src->max_winsize = xd3_xoff_roundup(src->max_winsize); | 2237 | src->max_winsize = xd3_xoff_roundup(src->max_winsize); |
2238 | IF_DEBUG1 (DP(RINT "raising src_maxsize to %u\n", src->blksize)); | 2238 | IF_DEBUG1 (DP(RINT "raising src_maxsize to %u\n", src->blksize)); |
2239 | } | 2239 | } |
2240 | src->max_winsize = max(src->max_winsize, XD3_ALLOCSIZE); | 2240 | src->max_winsize = xd3_max (src->max_winsize, XD3_ALLOCSIZE); |
2241 | 2241 | ||
2242 | return 0; | 2242 | return 0; |
2243 | } | 2243 | } |
@@ -2683,7 +2683,7 @@ xd3_iopt_flush_instructions (xd3_stream *stream, int force) | |||
2683 | /* Try to balance the length of both instructions, but avoid | 2683 | /* Try to balance the length of both instructions, but avoid |
2684 | * making both longer than MAX_MATCH_SPLIT . */ | 2684 | * making both longer than MAX_MATCH_SPLIT . */ |
2685 | average = gap / 2; | 2685 | average = gap / 2; |
2686 | newsize = min (MAX_MATCH_SPLIT, gap - average); | 2686 | newsize = xd3_min (MAX_MATCH_SPLIT, gap - average); |
2687 | 2687 | ||
2688 | /* Should be possible to simplify this code. */ | 2688 | /* Should be possible to simplify this code. */ |
2689 | if (newsize > r1->size) | 2689 | if (newsize > r1->size) |
@@ -3160,7 +3160,7 @@ xd3_encode_buffer_leftover (xd3_stream *stream) | |||
3160 | 3160 | ||
3161 | /* Copy into the buffer. */ | 3161 | /* Copy into the buffer. */ |
3162 | room = stream->winsize - stream->buf_avail; | 3162 | room = stream->winsize - stream->buf_avail; |
3163 | take = min (room, stream->avail_in); | 3163 | take = xd3_min (room, stream->avail_in); |
3164 | 3164 | ||
3165 | memcpy (stream->buf_in + stream->buf_avail, stream->next_in, take); | 3165 | memcpy (stream->buf_in + stream->buf_avail, stream->next_in, take); |
3166 | 3166 | ||
@@ -3239,7 +3239,7 @@ xd3_encode_init (xd3_stream *stream, int full_init) | |||
3239 | 3239 | ||
3240 | if (small_comp) | 3240 | if (small_comp) |
3241 | { | 3241 | { |
3242 | /* TODO: This is under devel: used to have min(sprevsz) here, which sort | 3242 | /* TODO: This is under devel: used to have min (sprevsz) here, which sort |
3243 | * of makes sense, but observed fast performance w/ larger tables, which | 3243 | * of makes sense, but observed fast performance w/ larger tables, which |
3244 | * also sort of makes sense. @@@ */ | 3244 | * also sort of makes sense. @@@ */ |
3245 | usize_t hash_values = stream->winsize; | 3245 | usize_t hash_values = stream->winsize; |
@@ -3580,7 +3580,7 @@ xd3_process_stream (int is_encode, | |||
3580 | usize_t output_size_max) | 3580 | usize_t output_size_max) |
3581 | { | 3581 | { |
3582 | usize_t ipos = 0; | 3582 | usize_t ipos = 0; |
3583 | usize_t n = min(stream->winsize, input_size); | 3583 | usize_t n = xd3_min (stream->winsize, input_size); |
3584 | 3584 | ||
3585 | (*output_size) = 0; | 3585 | (*output_size) = 0; |
3586 | 3586 | ||
@@ -3596,7 +3596,7 @@ xd3_process_stream (int is_encode, | |||
3596 | { | 3596 | { |
3597 | case XD3_OUTPUT: { /* memcpy below */ break; } | 3597 | case XD3_OUTPUT: { /* memcpy below */ break; } |
3598 | case XD3_INPUT: { | 3598 | case XD3_INPUT: { |
3599 | n = min(stream->winsize, input_size - ipos); | 3599 | n = xd3_min(stream->winsize, input_size - ipos); |
3600 | if (n == 0) | 3600 | if (n == 0) |
3601 | { | 3601 | { |
3602 | goto done; | 3602 | goto done; |
@@ -3672,7 +3672,7 @@ xd3_process_memory (int is_encode, | |||
3672 | 3672 | ||
3673 | if (is_encode) | 3673 | if (is_encode) |
3674 | { | 3674 | { |
3675 | config.winsize = min(input_size, (usize_t) XD3_DEFAULT_WINSIZE); | 3675 | config.winsize = xd3_min(input_size, (usize_t) XD3_DEFAULT_WINSIZE); |
3676 | config.sprevsz = xd3_pow2_roundup (config.winsize); | 3676 | config.sprevsz = xd3_pow2_roundup (config.winsize); |
3677 | } | 3677 | } |
3678 | 3678 | ||
@@ -3927,8 +3927,8 @@ xd3_srcwin_setup (xd3_stream *stream) | |||
3927 | * issued, but we have to decide the source window base and length | 3927 | * issued, but we have to decide the source window base and length |
3928 | * now. */ | 3928 | * now. */ |
3929 | src->srcbase = stream->match_minaddr; | 3929 | src->srcbase = stream->match_minaddr; |
3930 | src->srclen = max ((usize_t) length, | 3930 | src->srclen = xd3_max ((usize_t) length, |
3931 | stream->avail_in + (stream->avail_in >> 2)); | 3931 | stream->avail_in + (stream->avail_in >> 2)); |
3932 | 3932 | ||
3933 | if (src->eof_known) | 3933 | if (src->eof_known) |
3934 | { | 3934 | { |
@@ -3936,7 +3936,7 @@ xd3_srcwin_setup (xd3_stream *stream) | |||
3936 | * code that expects to pass a single block w/ getblk == NULL | 3936 | * code that expects to pass a single block w/ getblk == NULL |
3937 | * will not function, as the code will return GETSRCBLK asking | 3937 | * will not function, as the code will return GETSRCBLK asking |
3938 | * for the second block. */ | 3938 | * for the second block. */ |
3939 | src->srclen = min (src->srclen, xd3_source_eof(src) - src->srcbase); | 3939 | src->srclen = xd3_min (src->srclen, xd3_source_eof(src) - src->srcbase); |
3940 | } | 3940 | } |
3941 | 3941 | ||
3942 | IF_DEBUG1 (DP(RINT "[srcwin_setup_constrained] base %llu len %llu\n", | 3942 | IF_DEBUG1 (DP(RINT "[srcwin_setup_constrained] base %llu len %llu\n", |
@@ -4200,7 +4200,7 @@ xd3_source_extend_match (xd3_stream *stream) | |||
4200 | return ret; | 4200 | return ret; |
4201 | } | 4201 | } |
4202 | 4202 | ||
4203 | tryrem = min (tryoff, stream->match_maxback - stream->match_back); | 4203 | tryrem = xd3_min (tryoff, stream->match_maxback - stream->match_back); |
4204 | 4204 | ||
4205 | IF_DEBUG2(DP(RINT "[maxback] maxback %u trysrc %"Q"u/%u tgt %u tryrem %u\n", | 4205 | IF_DEBUG2(DP(RINT "[maxback] maxback %u trysrc %"Q"u/%u tgt %u tryrem %u\n", |
4206 | stream->match_maxback, tryblk, tryoff, streamoff, tryrem)); | 4206 | stream->match_maxback, tryblk, tryoff, streamoff, tryrem)); |
@@ -4245,7 +4245,7 @@ xd3_source_extend_match (xd3_stream *stream) | |||
4245 | return ret; | 4245 | return ret; |
4246 | } | 4246 | } |
4247 | 4247 | ||
4248 | tryrem = min(stream->match_maxfwd - stream->match_fwd, | 4248 | tryrem = xd3_min(stream->match_maxfwd - stream->match_fwd, |
4249 | src->onblk - tryoff); | 4249 | src->onblk - tryoff); |
4250 | 4250 | ||
4251 | if (tryrem == 0) | 4251 | if (tryrem == 0) |
@@ -4587,7 +4587,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
4587 | 4587 | ||
4588 | /* Begin by advancing at twice the input rate, up to half the | 4588 | /* Begin by advancing at twice the input rate, up to half the |
4589 | * maximum window size. */ | 4589 | * maximum window size. */ |
4590 | logical_input_cksum_pos = min((stream->total_in + stream->input_position) * 2, | 4590 | logical_input_cksum_pos = xd3_min((stream->total_in + stream->input_position) * 2, |
4591 | (stream->total_in + stream->input_position) + | 4591 | (stream->total_in + stream->input_position) + |
4592 | (stream->src->max_winsize / 2)); | 4592 | (stream->src->max_winsize / 2)); |
4593 | 4593 | ||
@@ -4812,9 +4812,9 @@ XD3_TEMPLATE(xd3_string_match_) (xd3_stream *stream) | |||
4812 | * of length 8 at the next position. */ | 4812 | * of length 8 at the next position. */ |
4813 | if (xd3_iopt_last_matched (stream) > stream->input_position) | 4813 | if (xd3_iopt_last_matched (stream) > stream->input_position) |
4814 | { | 4814 | { |
4815 | stream->min_match = max(MIN_MATCH, | 4815 | stream->min_match = xd3_max (MIN_MATCH, |
4816 | 1 + xd3_iopt_last_matched(stream) - | 4816 | 1 + xd3_iopt_last_matched(stream) - |
4817 | stream->input_position); | 4817 | stream->input_position); |
4818 | } | 4818 | } |
4819 | else | 4819 | else |
4820 | { | 4820 | { |