summaryrefslogtreecommitdiff
path: root/xdelta3/badcopy.c
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2006-12-16 23:13:12 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2006-12-16 23:13:12 +0000
commit4f033f90aa355913c7fc2bd39524200a0a0847b9 (patch)
treea911628fa0c08e02731a1e738c9fc57fa0a8aedd /xdelta3/badcopy.c
parenta7d946283af8a6325fb9887fc644e27d7b7c2f59 (diff)
Make badcopy use xoff_t
Diffstat (limited to 'xdelta3/badcopy.c')
-rwxr-xr-xxdelta3/badcopy.c41
1 files changed, 24 insertions, 17 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
7typedef unsigned int usize_t;
8
9double error_prob = 0.0001;
10usize_t mean_change = 100;
11usize_t total_change = 0;
12usize_t total_size = 0;
13usize_t max_change = 0;
14usize_t num_change = 0;
15
16int last_end = 0;
17
18#ifdef WIN32 7#ifdef WIN32
19// whatever 8// whatever
20static 9static
@@ -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
37double error_prob = 0.0001;
38usize_t mean_change = 100;
39xoff_t total_change = 0;
40xoff_t total_size = 0;
41usize_t max_change = 0;
42usize_t num_change = 0;
43
44
45static usize_t 45static usize_t
46edist (usize_t mean, usize_t max) 46edist (usize_t mean, usize_t max)
47{ 47{
@@ -55,8 +55,7 @@ edist (usize_t mean, usize_t max)
55void modify (char *buf, usize_t size) 55void 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");