diff options
Diffstat (limited to 'xdelta3')
-rw-r--r-- | xdelta3/testing/regtest.cc | 3 | ||||
-rw-r--r-- | xdelta3/xdelta3-blkcache.h | 2 | ||||
-rw-r--r-- | xdelta3/xdelta3-internal.h | 2 | ||||
-rw-r--r-- | xdelta3/xdelta3-main.h | 48 | ||||
-rw-r--r-- | xdelta3/xdelta3.c | 58 | ||||
-rw-r--r-- | xdelta3/xdelta3.h | 14 |
6 files changed, 78 insertions, 49 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc index d31f6b5..d5864d6 100644 --- a/xdelta3/testing/regtest.cc +++ b/xdelta3/testing/regtest.cc | |||
@@ -46,7 +46,6 @@ void InMemoryEncodeDecode(const FileSpec &source_file, | |||
46 | xd3_init_config(&decode_config, XD3_ADLER32); | 46 | xd3_init_config(&decode_config, XD3_ADLER32); |
47 | 47 | ||
48 | encode_config.winsize = Constants::WINDOW_SIZE; | 48 | encode_config.winsize = Constants::WINDOW_SIZE; |
49 | encode_config.srcwin_maxsz = options.encode_srcwin_maxsz; | ||
50 | 49 | ||
51 | // TODO! the smatcher setup isn't working, | 50 | // TODO! the smatcher setup isn't working, |
52 | // if (options.large_cksum_step) { | 51 | // if (options.large_cksum_step) { |
@@ -64,6 +63,8 @@ void InMemoryEncodeDecode(const FileSpec &source_file, | |||
64 | encode_source.blksize = Constants::BLOCK_SIZE; | 63 | encode_source.blksize = Constants::BLOCK_SIZE; |
65 | decode_source.blksize = Constants::BLOCK_SIZE; | 64 | decode_source.blksize = Constants::BLOCK_SIZE; |
66 | 65 | ||
66 | encode_source.max_winsize = options.encode_srcwin_maxsz; | ||
67 | |||
67 | xd3_set_source (&encode_stream, &encode_source); | 68 | xd3_set_source (&encode_stream, &encode_source); |
68 | xd3_set_source (&decode_stream, &decode_source); | 69 | xd3_set_source (&decode_stream, &decode_source); |
69 | 70 | ||
diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h index 56b8973..63abde3 100644 --- a/xdelta3/xdelta3-blkcache.h +++ b/xdelta3/xdelta3-blkcache.h | |||
@@ -166,6 +166,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, | |||
166 | source->ioh = sfile; | 166 | source->ioh = sfile; |
167 | source->curblkno = (xoff_t) -1; | 167 | source->curblkno = (xoff_t) -1; |
168 | source->curblk = NULL; | 168 | source->curblk = NULL; |
169 | source->max_winsize = option_srcwinsz; | ||
169 | 170 | ||
170 | if ((ret = main_getblk_func (stream, source, 0)) != 0) | 171 | if ((ret = main_getblk_func (stream, source, 0)) != 0) |
171 | { | 172 | { |
@@ -193,6 +194,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, | |||
193 | blksize = option_srcwinsz / MAX_LRU_SIZE; | 194 | blksize = option_srcwinsz / MAX_LRU_SIZE; |
194 | source->blksize = blksize; | 195 | source->blksize = blksize; |
195 | source->onblk = blksize; /* xd3 sets onblk */ | 196 | source->onblk = blksize; /* xd3 sets onblk */ |
197 | source->max_winsize = blksize; | ||
196 | lru[0].size = blksize; | 198 | lru[0].size = blksize; |
197 | lru_size = MAX_LRU_SIZE; | 199 | lru_size = MAX_LRU_SIZE; |
198 | 200 | ||
diff --git a/xdelta3/xdelta3-internal.h b/xdelta3/xdelta3-internal.h index 955a277..f741005 100644 --- a/xdelta3/xdelta3-internal.h +++ b/xdelta3/xdelta3-internal.h | |||
@@ -24,7 +24,7 @@ typedef struct _main_file main_file; | |||
24 | typedef struct _main_extcomp main_extcomp; | 24 | typedef struct _main_extcomp main_extcomp; |
25 | 25 | ||
26 | void main_buffree (void *ptr); | 26 | void main_buffree (void *ptr); |
27 | void* main_bufalloc (usize_t size); | 27 | void* main_bufalloc (size_t size); |
28 | void main_file_init (main_file *xfile); | 28 | void main_file_init (main_file *xfile); |
29 | int main_file_close (main_file *xfile); | 29 | int main_file_close (main_file *xfile); |
30 | void main_file_cleanup (main_file *xfile); | 30 | void main_file_cleanup (main_file *xfile); |
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 71c8541..6fcd423 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -250,7 +250,7 @@ static const char *option_source_filename = NULL; | |||
250 | static int option_level = XD3_DEFAULT_LEVEL; | 250 | static int option_level = XD3_DEFAULT_LEVEL; |
251 | static usize_t option_iopt_size = XD3_DEFAULT_IOPT_SIZE; | 251 | static usize_t option_iopt_size = XD3_DEFAULT_IOPT_SIZE; |
252 | static usize_t option_winsize = XD3_DEFAULT_WINSIZE; | 252 | static usize_t option_winsize = XD3_DEFAULT_WINSIZE; |
253 | static usize_t option_srcwinsz = XD3_DEFAULT_SRCWINSZ; | 253 | static size_t option_srcwinsz = XD3_DEFAULT_SRCWINSZ; |
254 | static usize_t option_sprevsz = XD3_DEFAULT_SPREVSZ; | 254 | static usize_t option_sprevsz = XD3_DEFAULT_SPREVSZ; |
255 | 255 | ||
256 | /* These variables are supressed to avoid their use w/o support. main() warns | 256 | /* These variables are supressed to avoid their use w/o support. main() warns |
@@ -309,7 +309,7 @@ static int main_getblk_func (xd3_stream *stream, | |||
309 | xd3_source *source, | 309 | xd3_source *source, |
310 | xoff_t blkno); | 310 | xoff_t blkno); |
311 | static void main_free (void *ptr); | 311 | static void main_free (void *ptr); |
312 | static void* main_malloc (usize_t size); | 312 | static void* main_malloc (size_t size); |
313 | 313 | ||
314 | static int main_file_stat (main_file *xfile, xoff_t *size); | 314 | static int main_file_stat (main_file *xfile, xoff_t *size); |
315 | static int main_file_seek (main_file *xfile, xoff_t pos); | 315 | static int main_file_seek (main_file *xfile, xoff_t pos); |
@@ -443,15 +443,14 @@ reset_defaults(void) | |||
443 | } | 443 | } |
444 | 444 | ||
445 | static void* | 445 | static void* |
446 | main_malloc1 (usize_t size) | 446 | main_malloc1 (size_t size) |
447 | { | 447 | { |
448 | void* r = malloc (size); | 448 | void* r = malloc (size); |
449 | if (r == NULL) { XPR(NT "malloc: %s\n", xd3_mainerror (ENOMEM)); } | 449 | if (r == NULL) { XPR(NT "malloc: %s\n", xd3_mainerror (ENOMEM)); } |
450 | else if (option_verbose > 4) { XPR(NT "malloc: %u: %p\n", size, r); } | ||
451 | return r; | 450 | return r; |
452 | } | 451 | } |
453 | 452 | ||
454 | void* main_bufalloc (usize_t size) { | 453 | void* main_bufalloc (size_t size) { |
455 | #if XD3_WIN32 | 454 | #if XD3_WIN32 |
456 | return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); | 455 | return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); |
457 | #else | 456 | #else |
@@ -460,7 +459,7 @@ void* main_bufalloc (usize_t size) { | |||
460 | } | 459 | } |
461 | 460 | ||
462 | static void* | 461 | static void* |
463 | main_malloc (usize_t size) | 462 | main_malloc (size_t size) |
464 | { | 463 | { |
465 | void *r = main_malloc1 (size); | 464 | void *r = main_malloc1 (size); |
466 | if (r) { IF_DEBUG (main_mallocs += 1); } | 465 | if (r) { IF_DEBUG (main_mallocs += 1); } |
@@ -469,7 +468,7 @@ main_malloc (usize_t size) | |||
469 | 468 | ||
470 | static void* | 469 | static void* |
471 | main_alloc (void *opaque, | 470 | main_alloc (void *opaque, |
472 | usize_t items, | 471 | size_t items, |
473 | usize_t size) | 472 | usize_t size) |
474 | { | 473 | { |
475 | return main_malloc1 (items * size); | 474 | return main_malloc1 (items * size); |
@@ -478,7 +477,6 @@ main_alloc (void *opaque, | |||
478 | static void | 477 | static void |
479 | main_free1 (void *opaque, void *ptr) | 478 | main_free1 (void *opaque, void *ptr) |
480 | { | 479 | { |
481 | if (option_verbose > 4) { XPR(NT "free: %p\n", ptr); } | ||
482 | free (ptr); | 480 | free (ptr); |
483 | } | 481 | } |
484 | 482 | ||
@@ -703,8 +701,8 @@ main_strtoxoff (const char* s, xoff_t *xo, char which) | |||
703 | } | 701 | } |
704 | 702 | ||
705 | static int | 703 | static int |
706 | main_atou (const char* arg, usize_t *xo, usize_t low, | 704 | main_atoux (const char* arg, xoff_t *xo, xoff_t low, |
707 | usize_t high, char which) | 705 | xoff_t high, char which) |
708 | { | 706 | { |
709 | xoff_t x; | 707 | xoff_t x; |
710 | int ret; | 708 | int ret; |
@@ -713,7 +711,7 @@ main_atou (const char* arg, usize_t *xo, usize_t low, | |||
713 | 711 | ||
714 | if (x < low) | 712 | if (x < low) |
715 | { | 713 | { |
716 | XPR(NT "-%c: minimum value: %u\n", which, low); | 714 | XPR(NT "-%c: minimum value: %"Q"u\n", which, low); |
717 | return EXIT_FAILURE; | 715 | return EXIT_FAILURE; |
718 | } | 716 | } |
719 | if (high == 0) | 717 | if (high == 0) |
@@ -722,10 +720,24 @@ main_atou (const char* arg, usize_t *xo, usize_t low, | |||
722 | } | 720 | } |
723 | if (x > high) | 721 | if (x > high) |
724 | { | 722 | { |
725 | XPR(NT "-%c: maximum value: %u\n", which, high); | 723 | XPR(NT "-%c: maximum value: %"Q"u\n", which, high); |
726 | return EXIT_FAILURE; | 724 | return EXIT_FAILURE; |
727 | } | 725 | } |
728 | (*xo) = (usize_t)x; | 726 | (*xo) = x; |
727 | return 0; | ||
728 | } | ||
729 | |||
730 | static int | ||
731 | main_atou (const char* arg, usize_t *uo, usize_t low, | ||
732 | usize_t high, char which) | ||
733 | { | ||
734 | int ret; | ||
735 | xoff_t xo; | ||
736 | if ((ret = main_atoux (arg, &xo, low, high, which))) | ||
737 | { | ||
738 | return ret; | ||
739 | } | ||
740 | *uo = (usize_t)xo; | ||
729 | return 0; | 741 | return 0; |
730 | } | 742 | } |
731 | 743 | ||
@@ -3102,7 +3114,6 @@ main_input (xd3_cmd cmd, | |||
3102 | } | 3114 | } |
3103 | 3115 | ||
3104 | config.winsize = winsize; | 3116 | config.winsize = winsize; |
3105 | config.srcwin_maxsz = option_srcwinsz; | ||
3106 | config.getblk = main_getblk_func; | 3117 | config.getblk = main_getblk_func; |
3107 | config.flags = stream_flags; | 3118 | config.flags = stream_flags; |
3108 | 3119 | ||
@@ -3760,13 +3771,16 @@ int main (int argc, char **argv) | |||
3760 | break; | 3771 | break; |
3761 | case 'A': if (my_optarg == NULL) { option_use_appheader = 0; } | 3772 | case 'A': if (my_optarg == NULL) { option_use_appheader = 0; } |
3762 | else { option_appheader = (uint8_t*) my_optarg; } break; | 3773 | else { option_appheader = (uint8_t*) my_optarg; } break; |
3763 | case 'B': | 3774 | case 'B': { |
3764 | if ((ret = main_atou (my_optarg, & option_srcwinsz, XD3_MINSRCWINSZ, | 3775 | xoff_t bsize; |
3765 | 0, 'B'))) | 3776 | if ((ret = main_atoux (my_optarg, & bsize, |
3777 | XD3_MINSRCWINSZ, 0, 'B'))) | ||
3766 | { | 3778 | { |
3767 | goto exit; | 3779 | goto exit; |
3768 | } | 3780 | } |
3781 | option_srcwinsz = bsize; | ||
3769 | break; | 3782 | break; |
3783 | } | ||
3770 | case 'I': | 3784 | case 'I': |
3771 | if ((ret = main_atou (my_optarg, & option_iopt_size, 0, | 3785 | if ((ret = main_atou (my_optarg, & option_iopt_size, 0, |
3772 | 0, 'I'))) | 3786 | 0, 'I'))) |
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 431bab9..eb44b89 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -1527,9 +1527,9 @@ xd3_swap_usize_t (usize_t* p1, usize_t* p2) | |||
1527 | 1527 | ||
1528 | /* It's not constant time, but it computes the log. */ | 1528 | /* It's not constant time, but it computes the log. */ |
1529 | static int | 1529 | static int |
1530 | xd3_check_pow2 (usize_t value, usize_t *logof) | 1530 | xd3_check_pow2 (xoff_t value, usize_t *logof) |
1531 | { | 1531 | { |
1532 | usize_t x = 1; | 1532 | xoff_t x = 1; |
1533 | usize_t nolog; | 1533 | usize_t nolog; |
1534 | if (logof == NULL) { | 1534 | if (logof == NULL) { |
1535 | logof = &nolog; | 1535 | logof = &nolog; |
@@ -1558,6 +1558,16 @@ xd3_pow2_roundup (usize_t x) | |||
1558 | return i; | 1558 | return i; |
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | static xoff_t | ||
1562 | xd3_xoff_roundup (xoff_t x) | ||
1563 | { | ||
1564 | xoff_t i = 1; | ||
1565 | while (x > i) { | ||
1566 | i <<= 1U; | ||
1567 | } | ||
1568 | return i; | ||
1569 | } | ||
1570 | |||
1561 | static usize_t | 1571 | static usize_t |
1562 | xd3_round_blksize (usize_t sz, usize_t blksz) | 1572 | xd3_round_blksize (usize_t sz, usize_t blksz) |
1563 | { | 1573 | { |
@@ -2088,9 +2098,9 @@ xd3_decode_address (xd3_stream *stream, usize_t here, | |||
2088 | ***********************************************************************/ | 2098 | ***********************************************************************/ |
2089 | 2099 | ||
2090 | static void* | 2100 | static void* |
2091 | __xd3_alloc_func (void* opaque, usize_t items, usize_t size) | 2101 | __xd3_alloc_func (void* opaque, size_t items, usize_t size) |
2092 | { | 2102 | { |
2093 | return malloc ((size_t) items * (size_t) size); | 2103 | return malloc (items * (size_t) size); |
2094 | } | 2104 | } |
2095 | 2105 | ||
2096 | static void | 2106 | static void |
@@ -2369,8 +2379,6 @@ xd3_config_stream(xd3_stream *stream, | |||
2369 | 2379 | ||
2370 | stream->winsize = config->winsize ? config->winsize : XD3_DEFAULT_WINSIZE; | 2380 | stream->winsize = config->winsize ? config->winsize : XD3_DEFAULT_WINSIZE; |
2371 | stream->sprevsz = config->sprevsz ? config->sprevsz : XD3_DEFAULT_SPREVSZ; | 2381 | stream->sprevsz = config->sprevsz ? config->sprevsz : XD3_DEFAULT_SPREVSZ; |
2372 | stream->srcwin_maxsz = config->srcwin_maxsz ? | ||
2373 | config->srcwin_maxsz : XD3_DEFAULT_SRCWINSZ; | ||
2374 | 2382 | ||
2375 | if (config->iopt_size == 0) | 2383 | if (config->iopt_size == 0) |
2376 | { | 2384 | { |
@@ -2651,15 +2659,23 @@ xd3_set_source (xd3_stream *stream, | |||
2651 | 2659 | ||
2652 | /* Enforce power-of-two blocksize so that source-block number | 2660 | /* Enforce power-of-two blocksize so that source-block number |
2653 | * calculations are cheap. */ | 2661 | * calculations are cheap. */ |
2654 | if (!xd3_check_pow2 (src->blksize, &shiftby) == 0) | 2662 | if (xd3_check_pow2 (src->blksize, &shiftby) != 0) |
2655 | { | 2663 | { |
2656 | src->blksize = xd3_pow2_roundup(src->blksize); | 2664 | src->blksize = xd3_pow2_roundup(src->blksize); |
2657 | xd3_check_pow2 (src->blksize, &shiftby); | 2665 | xd3_check_pow2 (src->blksize, &shiftby); |
2658 | IF_DEBUG1 (DP(RINT "raising srcblksz to %u\n", src->blksize)); | 2666 | IF_DEBUG1 (DP(RINT "raising src_blksz to %u\n", src->blksize)); |
2659 | } | 2667 | } |
2660 | 2668 | ||
2661 | src->shiftby = shiftby; | 2669 | src->shiftby = shiftby; |
2662 | src->maskby = (1 << shiftby) - 1; | 2670 | src->maskby = (1 << shiftby) - 1; |
2671 | |||
2672 | if (xd3_check_pow2 (src->max_winsize, NULL) != 0) | ||
2673 | { | ||
2674 | src->max_winsize = xd3_xoff_roundup(src->max_winsize); | ||
2675 | IF_DEBUG1 (DP(RINT "raising src_maxsize to %"Q"u\n", src->blksize)); | ||
2676 | } | ||
2677 | src->max_winsize = max(src->max_winsize, XD3_ALLOCSIZE); | ||
2678 | |||
2663 | return 0; | 2679 | return 0; |
2664 | } | 2680 | } |
2665 | 2681 | ||
@@ -3678,7 +3694,7 @@ xd3_encode_init (xd3_stream *stream, int full_init) | |||
3678 | * identical or short inputs require no table allocation. */ | 3694 | * identical or short inputs require no table allocation. */ |
3679 | if (large_comp) | 3695 | if (large_comp) |
3680 | { | 3696 | { |
3681 | usize_t hash_values = (stream->srcwin_maxsz / | 3697 | usize_t hash_values = (stream->src->max_winsize / |
3682 | stream->smatcher.large_step); | 3698 | stream->smatcher.large_step); |
3683 | 3699 | ||
3684 | xd3_size_hashtable (stream, | 3700 | xd3_size_hashtable (stream, |
@@ -4117,7 +4133,6 @@ xd3_process_memory (int is_encode, | |||
4117 | 4133 | ||
4118 | if (is_encode) | 4134 | if (is_encode) |
4119 | { | 4135 | { |
4120 | config.srcwin_maxsz = source_size; | ||
4121 | config.winsize = min(input_size, (usize_t) XD3_DEFAULT_WINSIZE); | 4136 | config.winsize = min(input_size, (usize_t) XD3_DEFAULT_WINSIZE); |
4122 | config.iopt_size = min(input_size / 32, XD3_DEFAULT_IOPT_SIZE); | 4137 | config.iopt_size = min(input_size / 32, XD3_DEFAULT_IOPT_SIZE); |
4123 | config.iopt_size = max(config.iopt_size, 128U); | 4138 | config.iopt_size = max(config.iopt_size, 128U); |
@@ -4137,6 +4152,7 @@ xd3_process_memory (int is_encode, | |||
4137 | src.onblk = source_size; | 4152 | src.onblk = source_size; |
4138 | src.curblk = source; | 4153 | src.curblk = source; |
4139 | src.curblkno = 0; | 4154 | src.curblkno = 0; |
4155 | src.max_winsize = source_size; | ||
4140 | 4156 | ||
4141 | if ((ret = xd3_set_source_and_size (&stream, &src, source_size)) != 0) | 4157 | if ((ret = xd3_set_source_and_size (&stream, &src, source_size)) != 0) |
4142 | { | 4158 | { |
@@ -4419,23 +4435,23 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos) | |||
4419 | goto bad; | 4435 | goto bad; |
4420 | } | 4436 | } |
4421 | 4437 | ||
4422 | /* Implement srcwin_maxsz, which prevents the encoder from seeking | 4438 | /* Implement src->max_winsize, which prevents the encoder from seeking |
4423 | * back further than the LRU cache maintaining FIFO discipline, (to | 4439 | * back further than the LRU cache maintaining FIFO discipline, (to |
4424 | * avoid seeking). Note the +1 here ensures that "frontier_pos" is | 4440 | * avoid seeking). Note the +1 here ensures that "frontier_pos" is |
4425 | * the address of the next byte in the stream, and ensures that the | 4441 | * the address of the next byte in the stream, and ensures that the |
4426 | * maximum offset is less than the source window size (in | 4442 | * maximum offset is less than the source window size (in |
4427 | * blocks). */ | 4443 | * blocks). */ |
4428 | frontier_pos = | 4444 | frontier_pos = |
4429 | (stream->src->frontier_blkno +1) * stream->src->blksize; | 4445 | (stream->src->frontier_blkno + 1) * stream->src->blksize; |
4430 | IF_DEBUG1(DP(RINT "[match_setup] frontier_pos %"Q"u, srcpos %"Q"u, " | 4446 | IF_DEBUG1(DP(RINT "[match_setup] frontier_pos %"Q"u, srcpos %"Q"u, " |
4431 | "srcwin_maxsz %u\n", | 4447 | "src->max_winsize %u\n", |
4432 | frontier_pos, srcpos, stream->srcwin_maxsz)); | 4448 | frontier_pos, srcpos, stream->src->max_winsize)); |
4433 | if (srcpos < frontier_pos && | 4449 | if (srcpos < frontier_pos && |
4434 | frontier_pos - srcpos > stream->srcwin_maxsz) { | 4450 | frontier_pos - srcpos > stream->src->max_winsize) { |
4435 | IF_DEBUG1(DP(RINT "[match_setup] rejected due to srcwin_maxsz " | 4451 | IF_DEBUG1(DP(RINT "[match_setup] rejected due to src->max_winsize " |
4436 | "distance eof=%"Q"u srcpos=%"Q"u maxsz=%u\n", | 4452 | "distance eof=%"Q"u srcpos=%"Q"u maxsz=%u\n", |
4437 | xd3_source_eof (stream->src), | 4453 | xd3_source_eof (stream->src), |
4438 | srcpos, stream->srcwin_maxsz)); | 4454 | srcpos, stream->src->max_winsize)); |
4439 | goto bad; | 4455 | goto bad; |
4440 | } | 4456 | } |
4441 | 4457 | ||
@@ -5034,7 +5050,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5034 | * maximum window size. */ | 5050 | * maximum window size. */ |
5035 | logical_input_cksum_pos = min((stream->total_in + stream->input_position) * 2, | 5051 | logical_input_cksum_pos = min((stream->total_in + stream->input_position) * 2, |
5036 | (stream->total_in + stream->input_position) + | 5052 | (stream->total_in + stream->input_position) + |
5037 | (stream->srcwin_maxsz / 2)); | 5053 | (stream->src->max_winsize / 2)); |
5038 | 5054 | ||
5039 | /* If srcwin_cksum_pos is already greater, wait until the difference | 5055 | /* If srcwin_cksum_pos is already greater, wait until the difference |
5040 | * is met. */ | 5056 | * is met. */ |
@@ -5060,13 +5076,13 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5060 | /* Advance at least one source block. With the command-line | 5076 | /* Advance at least one source block. With the command-line |
5061 | * defaults this means: | 5077 | * defaults this means: |
5062 | * | 5078 | * |
5063 | * if (src->size <= srcwin_maxsz), index the entire source at once | 5079 | * if (src->size <= src->max_winsize), index the entire source at once |
5064 | * using the position of the first non-match. This is good for | 5080 | * using the position of the first non-match. This is good for |
5065 | * small inputs, especially when the content may have moved anywhere | 5081 | * small inputs, especially when the content may have moved anywhere |
5066 | * in the file (e.g., tar files). | 5082 | * in the file (e.g., tar files). |
5067 | * | 5083 | * |
5068 | * if (src->size > srcwin_maxsz), index at least one block (which | 5084 | * if (src->size > src->max_winsize), index at least one block (which |
5069 | * the command-line sets to 1/32 of srcwin_maxsz) ahead of the | 5085 | * the command-line sets to 1/32 of src->max_winsize) ahead of the |
5070 | * logical position. This is good for different reasons: when a | 5086 | * logical position. This is good for different reasons: when a |
5071 | * long match spanning several source blocks is encountered, this | 5087 | * long match spanning several source blocks is encountered, this |
5072 | * avoids computing checksums for those blocks. If the data can | 5088 | * avoids computing checksums for those blocks. If the data can |
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index 6cffbf8..554359d 100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h | |||
@@ -280,8 +280,8 @@ typedef struct _xd3_wininfo xd3_wininfo; | |||
280 | * provided as NULL, the stream returns XD3_GETSRCBLK. */ | 280 | * provided as NULL, the stream returns XD3_GETSRCBLK. */ |
281 | 281 | ||
282 | typedef void* (xd3_alloc_func) (void *opaque, | 282 | typedef void* (xd3_alloc_func) (void *opaque, |
283 | usize_t items, | 283 | size_t items, |
284 | usize_t size); | 284 | usize_t size); |
285 | typedef void (xd3_free_func) (void *opaque, | 285 | typedef void (xd3_free_func) (void *opaque, |
286 | void *address); | 286 | void *address); |
287 | 287 | ||
@@ -692,10 +692,6 @@ struct _xd3_config | |||
692 | usize_t iopt_size; /* entries in the | 692 | usize_t iopt_size; /* entries in the |
693 | instruction-optimizing | 693 | instruction-optimizing |
694 | buffer */ | 694 | buffer */ |
695 | usize_t srcwin_maxsz; /* srcwin_size grows by a factor | ||
696 | of 2 when no matches are | ||
697 | found. encoder will not seek | ||
698 | back further than this. */ | ||
699 | 695 | ||
700 | xd3_getblk_func *getblk; /* The three callbacks. */ | 696 | xd3_getblk_func *getblk; /* The three callbacks. */ |
701 | xd3_alloc_func *alloc; | 697 | xd3_alloc_func *alloc; |
@@ -729,6 +725,7 @@ struct _xd3_source | |||
729 | const char *name; /* its name, for debug/print | 725 | const char *name; /* its name, for debug/print |
730 | purposes */ | 726 | purposes */ |
731 | void *ioh; /* opaque handle */ | 727 | void *ioh; /* opaque handle */ |
728 | xoff_t max_winsize; /* maximum visible buffer */ | ||
732 | 729 | ||
733 | /* getblk sets */ | 730 | /* getblk sets */ |
734 | xoff_t curblkno; /* current block number: client | 731 | xoff_t curblkno; /* current block number: client |
@@ -798,7 +795,6 @@ struct _xd3_stream | |||
798 | size mask */ | 795 | size mask */ |
799 | usize_t iopt_size; | 796 | usize_t iopt_size; |
800 | usize_t iopt_unlimited; | 797 | usize_t iopt_unlimited; |
801 | usize_t srcwin_maxsz; | ||
802 | 798 | ||
803 | /* general configuration */ | 799 | /* general configuration */ |
804 | xd3_getblk_func *getblk; /* set nxtblk, nxtblkno to scanblkno */ | 800 | xd3_getblk_func *getblk; /* set nxtblk, nxtblkno to scanblkno */ |
@@ -840,7 +836,7 @@ struct _xd3_stream | |||
840 | * if there is at least one | 836 | * if there is at least one |
841 | * match in the buffer. */ | 837 | * match in the buffer. */ |
842 | 838 | ||
843 | /* SRCWIN: these variables plus srcwin_maxsz above (set by config) */ | 839 | /* SRCWIN */ |
844 | int srcwin_decided; /* boolean: true if srclen and | 840 | int srcwin_decided; /* boolean: true if srclen and |
845 | srcbase have been | 841 | srcbase have been |
846 | decided. */ | 842 | decided. */ |
@@ -1070,11 +1066,11 @@ int xd3_decode_memory (const uint8_t *input, | |||
1070 | * src.curblkno = 0; | 1066 | * src.curblkno = 0; |
1071 | * src.onblk = source_size; | 1067 | * src.onblk = source_size; |
1072 | * src.curblk = source; | 1068 | * src.curblk = source; |
1069 | * src.max_winsize = source_size; | ||
1073 | * xd3_set_source(&stream, &src); | 1070 | * xd3_set_source(&stream, &src); |
1074 | * } | 1071 | * } |
1075 | * | 1072 | * |
1076 | * config.flags = flags; | 1073 | * config.flags = flags; |
1077 | * config.srcwin_maxsz = source_size; | ||
1078 | * config.winsize = input_size; | 1074 | * config.winsize = input_size; |
1079 | * | 1075 | * |
1080 | * ... set smatcher, appheader, encoding-table, compression-level, etc. | 1076 | * ... set smatcher, appheader, encoding-table, compression-level, etc. |