diff options
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r-- | xdelta3/xdelta3-main.h | 48 |
1 files changed, 31 insertions, 17 deletions
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'))) |