summaryrefslogtreecommitdiff
path: root/xdelta3
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3')
-rwxr-xr-xxdelta3/examples/Makefile4
-rw-r--r--xdelta3/examples/checksum_test.cc2
-rw-r--r--xdelta3/examples/compare_test.c6
-rw-r--r--xdelta3/examples/encode_decode_test.c32
-rwxr-xr-xxdelta3/examples/small_page_test.c10
-rw-r--r--xdelta3/examples/test.h2
-rw-r--r--xdelta3/xdelta3-main.h7
-rw-r--r--xdelta3/xdelta3-merge.h3
-rw-r--r--xdelta3/xdelta3.c13
9 files changed, 57 insertions, 22 deletions
diff --git a/xdelta3/examples/Makefile b/xdelta3/examples/Makefile
index 7bc575c..b21ebda 100755
--- a/xdelta3/examples/Makefile
+++ b/xdelta3/examples/Makefile
@@ -1,5 +1,5 @@
1#CFLAGS = -g -Wall -I.. -DXD3_DEBUG=1 -DNDEBUG=0 1CFLAGS = -g -Wall -I.. -DXD3_DEBUG=1 -DNDEBUG=0
2CFLAGS = -O3 -Wall -I.. -DXD3_DEBUG=0 -fno-builtin -DNDEBUG=1 2#CFLAGS = -O3 -Wall -I.. -DXD3_DEBUG=0 -fno-builtin -DNDEBUG=1
3# -pg 3# -pg
4 4
5SOURCES = small_page_test.c encode_decode_test.c speed_test.c 5SOURCES = small_page_test.c encode_decode_test.c speed_test.c
diff --git a/xdelta3/examples/checksum_test.cc b/xdelta3/examples/checksum_test.cc
index 56fb641..65e3d50 100644
--- a/xdelta3/examples/checksum_test.cc
+++ b/xdelta3/examples/checksum_test.cc
@@ -590,7 +590,7 @@ void print_array(const char *tname) {
590int main(int argc, char** argv) { 590int main(int argc, char** argv) {
591 int i; 591 int i;
592 uint8_t *buf = NULL; 592 uint8_t *buf = NULL;
593 usize_t buf_len = 0; 593 size_t buf_len = 0;
594 int ret; 594 int ret;
595 595
596 if (argc <= 1) { 596 if (argc <= 1) {
diff --git a/xdelta3/examples/compare_test.c b/xdelta3/examples/compare_test.c
index 1cc41a8..f3b3ea2 100644
--- a/xdelta3/examples/compare_test.c
+++ b/xdelta3/examples/compare_test.c
@@ -4,13 +4,15 @@
4#include <string.h> 4#include <string.h>
5#include <assert.h> 5#include <assert.h>
6 6
7#include "xdelta3.h"
8
7#define NUM (1<<20) 9#define NUM (1<<20)
8#define ITERS 100 10#define ITERS 100
9 11
10/* From wikipedia on RDTSC */ 12/* From wikipedia on RDTSC */
11__inline__ uint64_t rdtsc() { 13inline uint64_t rdtsc() {
12 uint32_t lo, hi; 14 uint32_t lo, hi;
13 __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); 15 asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
14 return (uint64_t)hi << 32 | lo; 16 return (uint64_t)hi << 32 | lo;
15} 17}
16 18
diff --git a/xdelta3/examples/encode_decode_test.c b/xdelta3/examples/encode_decode_test.c
index 2b585df..353d8db 100644
--- a/xdelta3/examples/encode_decode_test.c
+++ b/xdelta3/examples/encode_decode_test.c
@@ -65,7 +65,7 @@ int code (
65 Input_Buf_Read = fread(Input_Buf, 1, BufSize, InFile); 65 Input_Buf_Read = fread(Input_Buf, 1, BufSize, InFile);
66 if (Input_Buf_Read < BufSize) 66 if (Input_Buf_Read < BufSize)
67 { 67 {
68 xd3_set_flags(&stream, XD3_FLUSH); 68 xd3_set_flags(&stream, XD3_FLUSH | stream.flags);
69 } 69 }
70 xd3_avail_input(&stream, Input_Buf, Input_Buf_Read); 70 xd3_avail_input(&stream, Input_Buf, Input_Buf_Read);
71 71
@@ -156,11 +156,21 @@ int main(int argc, char* argv[])
156 FILE* OutFile; 156 FILE* OutFile;
157 int r; 157 int r;
158 158
159 if (argc != 3) {
160 fprintf (stderr, "usage: %s source input output\n", argv[0]);
161 return 1;
162 }
163
164 char *input = argv[2];
165 char *source = argv[1];
166 const char *output = "encoded.testdata";
167 const char *decoded = "decoded.testdata";
168
159 /* Encode */ 169 /* Encode */
160 170
161 InFile = fopen("input.txt", "rb"); 171 InFile = fopen(input, "rb");
162 SrcFile = fopen("source.txt", "rb"); 172 SrcFile = fopen(source, "rb");
163 OutFile = fopen("encoded.txt", "wb"); 173 OutFile = fopen(output, "wb");
164 174
165 r = code (1, InFile, SrcFile, OutFile, 0x1000); 175 r = code (1, InFile, SrcFile, OutFile, 0x1000);
166 176
@@ -168,14 +178,16 @@ int main(int argc, char* argv[])
168 fclose(SrcFile); 178 fclose(SrcFile);
169 fclose(InFile); 179 fclose(InFile);
170 180
171 if (r) 181 if (r) {
182 fprintf (stderr, "Encode error: %d\n", r);
172 return r; 183 return r;
184 }
173 185
174 /* Decode */ 186 /* Decode */
175 187
176 InFile = fopen("encoded.txt", "rb"); 188 InFile = fopen(output, "rb");
177 SrcFile = fopen("source.txt", "rb"); 189 SrcFile = fopen(source, "rb");
178 OutFile = fopen("decoded.txt", "wb"); 190 OutFile = fopen(decoded, "wb");
179 191
180 r = code (0, InFile, SrcFile, OutFile, 0x1000); 192 r = code (0, InFile, SrcFile, OutFile, 0x1000);
181 193
@@ -183,8 +195,10 @@ int main(int argc, char* argv[])
183 fclose(SrcFile); 195 fclose(SrcFile);
184 fclose(InFile); 196 fclose(InFile);
185 197
186 if (r) 198 if (r) {
199 fprintf (stderr, "Decode error: %d\n", r);
187 return r; 200 return r;
201 }
188 202
189 return 0; 203 return 0;
190} 204}
diff --git a/xdelta3/examples/small_page_test.c b/xdelta3/examples/small_page_test.c
index 8a4532b..2d9ae93 100755
--- a/xdelta3/examples/small_page_test.c
+++ b/xdelta3/examples/small_page_test.c
@@ -62,6 +62,8 @@ process_page (int is_encode,
62 context_t *ctx = calloc(SPACE_MAX, 1); 62 context_t *ctx = calloc(SPACE_MAX, 1);
63 int ret; 63 int ret;
64 64
65 memset (&config, 0, sizeof(config));
66
65 if (ctx == NULL) 67 if (ctx == NULL)
66 { 68 {
67 printf("calloc failed\n"); 69 printf("calloc failed\n");
@@ -142,7 +144,8 @@ int test(int stride, int encode_flags)
142 &output_size, OUTPUT_MAX, 144 &output_size, OUTPUT_MAX,
143 encode_flags)) != 0) 145 encode_flags)) != 0)
144 { 146 {
145 fprintf (stderr, "encode failed: stride %u flags 0x%x\n", stride, encode_flags); 147 fprintf (stderr, "encode failed: stride %u flags 0x%x\n",
148 stride, encode_flags);
146 return ret; 149 return ret;
147 } 150 }
148 151
@@ -153,7 +156,7 @@ int test(int stride, int encode_flags)
153 0)) != 0) 156 0)) != 0)
154 { 157 {
155 fprintf (stderr, "decode failed: stride %u output_size %u flags 0x%x\n", 158 fprintf (stderr, "decode failed: stride %u output_size %u flags 0x%x\n",
156 stride, output_size, encode_flags); 159 stride, output_size, encode_flags);
157 return ret; 160 return ret;
158 } 161 }
159 162
@@ -172,7 +175,8 @@ int test(int stride, int encode_flags)
172 } 175 }
173 } 176 }
174 177
175 fprintf(stderr, "stride %d flags 0x%x size %u ", stride, encode_flags, output_size); 178 fprintf(stderr, "stride %d flags 0x%x size %u ",
179 stride, encode_flags, output_size);
176 fprintf(stderr, "%s\n", (ret == 0) ? "OK" : "FAIL"); 180 fprintf(stderr, "%s\n", (ret == 0) ? "OK" : "FAIL");
177 181
178 return 0; 182 return 0;
diff --git a/xdelta3/examples/test.h b/xdelta3/examples/test.h
index 70e46ff..e8016bb 100644
--- a/xdelta3/examples/test.h
+++ b/xdelta3/examples/test.h
@@ -11,7 +11,7 @@ static int read_whole_file(const char *name,
11 main_file file; 11 main_file file;
12 int ret; 12 int ret;
13 xoff_t len; 13 xoff_t len;
14 size_t nread; 14 usize_t nread;
15 main_file_init(&file); 15 main_file_init(&file);
16 file.filename = name; 16 file.filename = name;
17 ret = main_file_open(&file, name, XO_READ); 17 ret = main_file_open(&file, name, XO_READ);
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index b8e800e..4a75ac1 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -1816,7 +1816,8 @@ main_merge_output (xd3_stream *stream, main_file *ofile)
1816 main_free (main_bdata); 1816 main_free (main_bdata);
1817 main_bdata = NULL; 1817 main_bdata = NULL;
1818 main_bsize = 0; 1818 main_bsize = 0;
1819 if ((main_bdata = (uint8_t*) main_malloc (stream->dec_tgtlen)) == NULL) 1819 if ((main_bdata = (uint8_t*)
1820 main_malloc (stream->dec_tgtlen)) == NULL)
1820 { 1821 {
1821 return ENOMEM; 1822 return ENOMEM;
1822 } 1823 }
@@ -3510,11 +3511,13 @@ done:
3510 main_file_close (sfile); 3511 main_file_close (sfile);
3511 } 3512 }
3512 3513
3514#if VCDIFF_TOOLS
3513 if (cmd == CMD_MERGE && 3515 if (cmd == CMD_MERGE &&
3514 (ret = main_merge_output (& stream, ofile))) 3516 (ret = main_merge_output (& stream, ofile)))
3515 { 3517 {
3516 return EXIT_FAILURE; 3518 return EXIT_FAILURE;
3517 } 3519 }
3520#endif /* VCDIFF_TOOLS */
3518 3521
3519 /* If output file is not open yet because of delayed-open, it means 3522 /* If output file is not open yet because of delayed-open, it means
3520 * we never encountered a window in the delta, but it could have had 3523 * we never encountered a window in the delta, but it could have had
@@ -4039,11 +4042,13 @@ main (int argc, char **argv)
4039 if (! option_stdout) { ofile.filename = argv[1]; } 4042 if (! option_stdout) { ofile.filename = argv[1]; }
4040 } 4043 }
4041 4044
4045#if VCDIFF_TOOLS
4042 if (cmd == CMD_MERGE && 4046 if (cmd == CMD_MERGE &&
4043 (ret = main_merge_arguments (&merge_order))) 4047 (ret = main_merge_arguments (&merge_order)))
4044 { 4048 {
4045 goto cleanup; 4049 goto cleanup;
4046 } 4050 }
4051#endif /* VCDIFF_TOOLS */
4047 4052
4048 switch (cmd) 4053 switch (cmd)
4049 { 4054 {
diff --git a/xdelta3/xdelta3-merge.h b/xdelta3/xdelta3-merge.h
index 8cbbb25..2c03bb3 100644
--- a/xdelta3/xdelta3-merge.h
+++ b/xdelta3/xdelta3-merge.h
@@ -191,12 +191,13 @@ xd3_whole_append_window (xd3_stream *stream)
191} 191}
192 192
193/* xd3_merge_inputs() applies *input to *source, returns its result in 193/* xd3_merge_inputs() applies *input to *source, returns its result in
194 * tmp_stream. */ 194 * stream. */
195int xd3_merge_inputs (xd3_stream *stream, 195int xd3_merge_inputs (xd3_stream *stream,
196 xd3_whole_state *source, 196 xd3_whole_state *source,
197 xd3_whole_state *input) 197 xd3_whole_state *input)
198{ 198{
199 DP(RINT "Merge inputs!\n"); 199 DP(RINT "Merge inputs!\n");
200
200 return 0; 201 return 0;
201} 202}
202 203
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index 17985ae..3a0c6e8 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -3813,7 +3813,16 @@ xd3_encode_input (xd3_stream *stream)
3813 return ret; 3813 return ret;
3814 } 3814 }
3815 3815
3816 stream->input_position += stream->match_fwd; 3816 /* The search has to make forward progress here
3817 * or else it can get stuck in a match-backward
3818 * (getsrcblk) then match-forward (getsrcblk),
3819 * find insufficient match length, then repeat
3820 * exactly the same search. */
3821 if (stream->match_fwd != 0) {
3822 stream->input_position += stream->match_fwd;
3823 } else {
3824 stream->input_position += 1;
3825 }
3817 } 3826 }
3818 3827
3819 case MATCH_SEARCHING: 3828 case MATCH_SEARCHING:
@@ -4741,7 +4750,7 @@ xd3_smatch (xd3_stream *stream,
4741 4750
4742 again: 4751 again:
4743 4752
4744 IF_DEBUG1 (DP(RINT "smatch at base=%u inp=%u cksum=%u\n", base, 4753 IF_DEBUG2 (DP(RINT "smatch at base=%u inp=%u cksum=%u\n", base,
4745 stream->input_position, scksum)); 4754 stream->input_position, scksum));
4746 4755
4747 /* For small matches, we can always go to the end-of-input because 4756 /* For small matches, we can always go to the end-of-input because