diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2006-12-16 23:13:12 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2006-12-16 23:13:12 +0000 |
commit | 4f033f90aa355913c7fc2bd39524200a0a0847b9 (patch) | |
tree | a911628fa0c08e02731a1e738c9fc57fa0a8aedd | |
parent | a7d946283af8a6325fb9887fc644e27d7b7c2f59 (diff) |
Make badcopy use xoff_t
-rwxr-xr-x | xdelta3/badcopy.c | 41 | ||||
-rwxr-xr-x | xdelta3/xdelta3-main.h | 4 |
2 files changed, 26 insertions, 19 deletions
diff --git a/xdelta3/badcopy.c b/xdelta3/badcopy.c index 2b6e7f1..03abc63 100755 --- a/xdelta3/badcopy.c +++ b/xdelta3/badcopy.c | |||
@@ -4,17 +4,6 @@ | |||
4 | 4 | ||
5 | #define BUFSZ (1 << 22) | 5 | #define BUFSZ (1 << 22) |
6 | 6 | ||
7 | typedef unsigned int usize_t; | ||
8 | |||
9 | double error_prob = 0.0001; | ||
10 | usize_t mean_change = 100; | ||
11 | usize_t total_change = 0; | ||
12 | usize_t total_size = 0; | ||
13 | usize_t max_change = 0; | ||
14 | usize_t num_change = 0; | ||
15 | |||
16 | int last_end = 0; | ||
17 | |||
18 | #ifdef WIN32 | 7 | #ifdef WIN32 |
19 | // whatever | 8 | // whatever |
20 | static | 9 | static |
@@ -40,8 +29,19 @@ long lrand48() { | |||
40 | #define XD3_MAIN 1 | 29 | #define XD3_MAIN 1 |
41 | #define main notmain | 30 | #define main notmain |
42 | #define EXTERNAL_COMPRESSION 0 | 31 | #define EXTERNAL_COMPRESSION 0 |
32 | #define XD3_USE_LARGEFILE64 1 | ||
43 | #include "xdelta3.c" | 33 | #include "xdelta3.c" |
44 | #undef main | 34 | #undef main |
35 | |||
36 | |||
37 | double error_prob = 0.0001; | ||
38 | usize_t mean_change = 100; | ||
39 | xoff_t total_change = 0; | ||
40 | xoff_t total_size = 0; | ||
41 | usize_t max_change = 0; | ||
42 | usize_t num_change = 0; | ||
43 | |||
44 | |||
45 | static usize_t | 45 | static usize_t |
46 | edist (usize_t mean, usize_t max) | 46 | edist (usize_t mean, usize_t max) |
47 | { | 47 | { |
@@ -55,8 +55,7 @@ edist (usize_t mean, usize_t max) | |||
55 | void modify (char *buf, usize_t size) | 55 | void modify (char *buf, usize_t size) |
56 | { | 56 | { |
57 | usize_t bufpos = 0, j; | 57 | usize_t bufpos = 0, j; |
58 | 58 | usize_t last_end = 0; | |
59 | last_end = 0; | ||
60 | 59 | ||
61 | for (;; /* bufpos and j are incremented in the inner loop */) | 60 | for (;; /* bufpos and j are incremented in the inner loop */) |
62 | { | 61 | { |
@@ -73,8 +72,14 @@ void modify (char *buf, usize_t size) | |||
73 | 72 | ||
74 | bufpos += next_mod; | 73 | bufpos += next_mod; |
75 | 74 | ||
76 | fprintf (stderr, "COPY: %u-%u (%u)\n", total_size + last_end, total_size + bufpos, bufpos - last_end); | 75 | fprintf (stderr, "COPY: %I64u-%I64u (%u)\n", |
77 | fprintf (stderr, "ADD: %u-%u (%u) is change %u\n", total_size + bufpos , total_size + bufpos + next_size, next_size, num_change); | 76 | total_size + (xoff_t)last_end, |
77 | total_size + (xoff_t)bufpos, | ||
78 | bufpos - last_end); | ||
79 | fprintf (stderr, "ADD: %I64u-%I64u (%u) is change %u\n", | ||
80 | total_size + (xoff_t)bufpos, | ||
81 | total_size + (xoff_t)(bufpos + next_size), | ||
82 | next_size, num_change); | ||
78 | 83 | ||
79 | total_change += next_size; | 84 | total_change += next_size; |
80 | num_change += 1; | 85 | num_change += 1; |
@@ -87,7 +92,9 @@ void modify (char *buf, usize_t size) | |||
87 | last_end = bufpos; | 92 | last_end = bufpos; |
88 | } | 93 | } |
89 | 94 | ||
90 | fprintf (stderr, "COPY: %u-%u (%u)\n", total_size + last_end, total_size + size, size - last_end); | 95 | fprintf (stderr, "COPY: %I64u-%I64u (%u)\n", |
96 | total_size + last_end, | ||
97 | total_size + size, size - last_end); | ||
91 | 98 | ||
92 | total_size += size; | 99 | total_size += size; |
93 | } | 100 | } |
@@ -99,7 +106,7 @@ int main(int argc, char **argv) | |||
99 | int c, ret; | 106 | int c, ret; |
100 | main_file_init(&inp); | 107 | main_file_init(&inp); |
101 | main_file_init(&out); | 108 | main_file_init(&out); |
102 | 109 | option_force = 1; | |
103 | if (argc > 5) | 110 | if (argc > 5) |
104 | { | 111 | { |
105 | fprintf (stderr, "usage: badcopy [byte_error_prob [mean_error_size]]\n"); | 112 | fprintf (stderr, "usage: badcopy [byte_error_prob [mean_error_size]]\n"); |
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index d0256f8..f9125d3 100755 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -2512,8 +2512,8 @@ main_input (xd3_cmd cmd, | |||
2512 | char rdb[32], wdb[32]; | 2512 | char rdb[32], wdb[32]; |
2513 | char trdb[32], twdb[32]; | 2513 | char trdb[32], twdb[32]; |
2514 | long millis = get_millisecs_since (); | 2514 | long millis = get_millisecs_since (); |
2515 | usize_t this_read = stream.total_in - last_total_in; | 2515 | usize_t this_read = (usize_t)(stream.total_in - last_total_in); |
2516 | usize_t this_write = stream.total_out - last_total_out; | 2516 | usize_t this_write = (usize_t)(stream.total_out - last_total_out); |
2517 | last_total_in = stream.total_in; | 2517 | last_total_in = stream.total_in; |
2518 | last_total_out = stream.total_out; | 2518 | last_total_out = stream.total_out; |
2519 | 2519 | ||