summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xdelta3/Makefile.am2
-rw-r--r--xdelta3/configure.ac2
-rw-r--r--xdelta3/xdelta3-blkcache.h107
-rw-r--r--xdelta3/xdelta3-decode.h12
-rw-r--r--xdelta3/xdelta3-fgk.h6
-rw-r--r--xdelta3/xdelta3-hash.h15
-rw-r--r--xdelta3/xdelta3-internal.h2
-rw-r--r--xdelta3/xdelta3-list.h4
-rw-r--r--xdelta3/xdelta3-main.h11
-rw-r--r--xdelta3/xdelta3-second.h4
-rw-r--r--xdelta3/xdelta3-test.h4
-rw-r--r--xdelta3/xdelta3.c79
-rw-r--r--xdelta3/xdelta3.h34
-rw-r--r--xdelta3/xdelta3.prj2
14 files changed, 156 insertions, 128 deletions
diff --git a/xdelta3/Makefile.am b/xdelta3/Makefile.am
index ab8c09a..dd2f2d5 100644
--- a/xdelta3/Makefile.am
+++ b/xdelta3/Makefile.am
@@ -57,7 +57,7 @@ if DEBUG_SYMBOLS
57endif 57endif
58 58
59# For additional debugging, add -DXD3_DEBUG=1, 2, 3, ... 59# For additional debugging, add -DXD3_DEBUG=1, 2, 3, ...
60xdelta3_CFLAGS = $(C_WFLAGS) $(common_CFLAGS) -DXD3_DEBUG=2 60xdelta3_CFLAGS = $(C_WFLAGS) $(common_CFLAGS) -DXD3_DEBUG=0
61xdelta3_LDADD = -lm 61xdelta3_LDADD = -lm
62 62
63xdelta3decode_CFLAGS = \ 63xdelta3decode_CFLAGS = \
diff --git a/xdelta3/configure.ac b/xdelta3/configure.ac
index 4d03e12..1feb7dd 100644
--- a/xdelta3/configure.ac
+++ b/xdelta3/configure.ac
@@ -1,4 +1,4 @@
1AC_INIT([Xdelta3], [3.0.5], [josh.macdonald@gmail.com], 1AC_INIT([Xdelta3], [3.0.6], [josh.macdonald@gmail.com],
2 [xdelta3], [http://xdelta.org/]) 2 [xdelta3], [http://xdelta.org/])
3AC_PREREQ([2.68]) 3AC_PREREQ([2.68])
4AC_CONFIG_MACRO_DIR([m4]) 4AC_CONFIG_MACRO_DIR([m4])
diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h
index a68a59a..82d720e 100644
--- a/xdelta3/xdelta3-blkcache.h
+++ b/xdelta3/xdelta3-blkcache.h
@@ -1,6 +1,6 @@
1/* xdelta 3 - delta compression tools and library 1/* xdelta 3 - delta compression tools and library
2 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3 * 2008, 2009, 2010, 2011, 2012, 2013 3 * 2008, 2009, 2010
4 * Joshua P. MacDonald 4 * Joshua P. MacDonald
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
@@ -18,6 +18,9 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 20
21/* TODO: This code is heavily revised from 3.0z but still needs major
22 * refactoring. */
23
21#include "xdelta3-internal.h" 24#include "xdelta3-internal.h"
22 25
23typedef struct _main_blklru main_blklru; 26typedef struct _main_blklru main_blklru;
@@ -33,13 +36,13 @@ struct _main_blklru
33{ 36{
34 uint8_t *blk; 37 uint8_t *blk;
35 xoff_t blkno; 38 xoff_t blkno;
36 xoff_t size; 39 usize_t size;
37 main_blklru_list link; 40 main_blklru_list link;
38}; 41};
39 42
40#define MAX_LRU_SIZE 32U 43#define MAX_LRU_SIZE 32U
41#define XD3_MINSRCWINSZ (XD3_ALLOCSIZE * MAX_LRU_SIZE) 44#define XD3_MINSRCWINSZ (XD3_ALLOCSIZE * MAX_LRU_SIZE)
42#define XD3_MAXSRCWINSZ (1ULL << 32) 45#define XD3_MAXSRCWINSZ (1ULL << 31)
43 46
44XD3_MAKELIST(main_blklru_list,main_blklru,link); 47XD3_MAKELIST(main_blklru_list,main_blklru,link);
45 48
@@ -87,23 +90,32 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
87 int ret = 0; 90 int ret = 0;
88 usize_t i; 91 usize_t i;
89 xoff_t source_size = 0; 92 xoff_t source_size = 0;
93 usize_t blksize;
90 94
91 XD3_ASSERT (lru == NULL); 95 XD3_ASSERT (lru == NULL);
92 XD3_ASSERT (stream->src == NULL); 96 XD3_ASSERT (stream->src == NULL);
93 XD3_ASSERT (option_srcwinsz >= XD3_MINSRCWINSZ); 97 XD3_ASSERT (option_srcwinsz >= XD3_MINSRCWINSZ);
94 98
99 /* TODO: this code needs refactoring into FIFO, LRU, FAKE. Yuck!
100 * This is simplified from 3.0z which had issues with sizing the
101 * source buffer memory allocation and the source blocksize. */
102
95 /* LRU-specific */ 103 /* LRU-specific */
96 main_blklru_list_init (& lru_list); 104 main_blklru_list_init (& lru_list);
97 105
98 if (allow_fake_source) 106 if (allow_fake_source)
99 { 107 {
108 /* TODO: refactor
109 * TOOLS/recode-specific: Check "allow_fake_source" mode looks
110 * broken now. */
100 sfile->mode = XO_READ; 111 sfile->mode = XO_READ;
101 sfile->realname = sfile->filename; 112 sfile->realname = sfile->filename;
102 sfile->nread = 0; 113 sfile->nread = 0;
103 } 114 }
104 else 115 else
105 { 116 {
106 /* Either a regular file or a FIFO. Both are possibly compressed. */ 117 /* Either a regular file (possibly compressed) or a FIFO
118 * (possibly compressed). */
107 if ((ret = main_file_open (sfile, sfile->filename, XO_READ))) 119 if ((ret = main_file_open (sfile, sfile->filename, XO_READ)))
108 { 120 {
109 return ret; 121 return ret;
@@ -141,24 +153,22 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
141 return ret; 153 return ret;
142 } 154 }
143 155
144 /* Setup LRU blocks. */ 156 /* Main calls main_getblk_func() once before xd3_set_source(). This
145 for (i = 0; i < MAX_LRU_SIZE; i++) 157 * is the point at which external decompression may begin. Set the
146 { 158 * system for a single block. */
147 lru[i].blk = lru[0].blk + (option_srcwinsz / MAX_LRU_SIZE) * i; 159 lru_size = 1;
148 lru[i].blkno = (xoff_t) -1; 160 lru[0].blkno = (xoff_t) -1;
149 lru[i].size = 0; 161 blksize = option_srcwinsz;
150 main_blklru_list_push_back (& lru_list, & lru[i]); 162 main_blklru_list_push_back (& lru_list, & lru[0]);
151 } 163 XD3_ASSERT (blksize != 0);
152 164
153 /* Initialize xd3_source. */ 165 /* Initialize xd3_source. */
166 source->blksize = blksize;
154 source->name = sfile->filename; 167 source->name = sfile->filename;
155 source->ioh = sfile; 168 source->ioh = sfile;
156 source->curblkno = (xoff_t) -1; 169 source->curblkno = (xoff_t) -1;
157 source->curblk = NULL; 170 source->curblk = NULL;
158 source->max_winsize = option_srcwinsz; 171 source->max_winsize = option_srcwinsz;
159 source->blksize = option_srcwinsz;
160
161 lru_size = 1;
162 172
163 if ((ret = main_getblk_func (stream, source, 0)) != 0) 173 if ((ret = main_getblk_func (stream, source, 0)) != 0)
164 { 174 {
@@ -168,26 +178,44 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
168 return ret; 178 return ret;
169 } 179 }
170 180
171 /* If the file is smaller than the buffer, size is known. */ 181 source->onblk = lru[0].size; /* xd3 sets onblk */
172 if (source->onblk < source->blksize) 182
183 /* If the file is smaller than a block, size is known. */
184 if (!sfile->size_known && source->onblk < blksize)
173 { 185 {
174 source_size = source->onblk; 186 source_size = source->onblk;
175 sfile->size_known = 1; 187 sfile->size_known = 1;
176 } 188 }
177 else 189
190 /* If the size is not known or is greater than the buffer size, we
191 * split the buffer across MAX_LRU_SIZE blocks (already allocated in
192 * "lru"). */
193 if (!sfile->size_known || source_size > option_srcwinsz)
178 { 194 {
179 /* Split the buffer */ 195 /* Modify block 0, change blocksize. */
180 source->blksize = option_srcwinsz / MAX_LRU_SIZE; 196 blksize = option_srcwinsz / MAX_LRU_SIZE;
181 source->onblk = source->blksize; 197 source->blksize = blksize;
198 source->onblk = blksize; /* xd3 sets onblk */
199 /* Note: source->max_winsize is unchanged. */
200 lru[0].size = blksize;
182 lru_size = MAX_LRU_SIZE; 201 lru_size = MAX_LRU_SIZE;
183 202
184 for (i = 0; i < (int) MAX_LRU_SIZE; ++i) 203 /* Setup rest of blocks. */
204 for (i = 1; i < lru_size; i += 1)
185 { 205 {
206 lru[i].blk = lru[0].blk + (blksize * i);
186 lru[i].blkno = i; 207 lru[i].blkno = i;
187 lru[i].size = source->blksize; 208 lru[i].size = blksize;
209 main_blklru_list_push_back (& lru_list, & lru[i]);
188 } 210 }
189 } 211 }
190 212
213 if (! sfile->size_known)
214 {
215 /* If the size is not know, we must use FIFO discipline. */
216 do_src_fifo = 1;
217 }
218
191 /* Call the appropriate set_source method, handle errors, print 219 /* Call the appropriate set_source method, handle errors, print
192 * verbose message, etc. */ 220 * verbose message, etc. */
193 if (sfile->size_known) 221 if (sfile->size_known)
@@ -196,8 +224,6 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
196 } 224 }
197 else 225 else
198 { 226 {
199 /* If the size is not known, we must use FIFO discipline. */
200 do_src_fifo = 1;
201 ret = xd3_set_source (stream, source); 227 ret = xd3_set_source (stream, source);
202 } 228 }
203 229
@@ -208,6 +234,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
208 } 234 }
209 235
210 XD3_ASSERT (stream->src == source); 236 XD3_ASSERT (stream->src == source);
237 XD3_ASSERT (source->blksize == blksize);
211 238
212 if (option_verbose) 239 if (option_verbose)
213 { 240 {
@@ -238,7 +265,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
238 XPR(NT "source %s %s blksize %s window %s%s%s\n", 265 XPR(NT "source %s %s blksize %s window %s%s%s\n",
239 sfile->filename, 266 sfile->filename,
240 srcszbuf.buf, 267 srcszbuf.buf,
241 main_format_bcnt (source->blksize, &blkszbuf), 268 main_format_bcnt (blksize, &blkszbuf),
242 main_format_bcnt (option_srcwinsz, &winszbuf), 269 main_format_bcnt (option_srcwinsz, &winszbuf),
243 nbufs.buf, 270 nbufs.buf,
244 do_src_fifo ? " (FIFO)" : ""); 271 do_src_fifo ? " (FIFO)" : "");
@@ -303,18 +330,10 @@ main_getblk_lru (xd3_source *source, xoff_t blkno,
303 lru_filled += 1; 330 lru_filled += 1;
304 (*is_new) = 1; 331 (*is_new) = 1;
305 (*blrup) = blru; 332 (*blrup) = blru;
306 blru->blkno = (xoff_t) -1; 333 blru->blkno = -1;
307 return 0; 334 return 0;
308} 335}
309 336
310/* Opens / seeks the source file and:
311 * (a) determines the source stream blocksize
312 * (b) determines the source file size (if possible)
313 * (c) calls main_read_primary_input (i.e., start external decompression)
314 *
315 * The main difficulty concerns an optimization: if the entire source
316 * fits inside the buffer, we decide to use a single block.
317 */
318static int 337static int
319main_read_seek_source (xd3_stream *stream, 338main_read_seek_source (xd3_stream *stream,
320 xd3_source *source, 339 xd3_source *source,
@@ -384,7 +403,7 @@ main_read_seek_source (xd3_stream *stream,
384 while (sfile->source_position < pos) 403 while (sfile->source_position < pos)
385 { 404 {
386 xoff_t skip_blkno; 405 xoff_t skip_blkno;
387 xoff_t skip_offset; 406 usize_t skip_offset;
388 407
389 xd3_blksize_div (sfile->source_position, source, 408 xd3_blksize_div (sfile->source_position, source,
390 &skip_blkno, &skip_offset); 409 &skip_blkno, &skip_offset);
@@ -421,7 +440,7 @@ main_read_seek_source (xd3_stream *stream,
421 sfile->source_position += nread; 440 sfile->source_position += nread;
422 blru->size = nread; 441 blru->size = nread;
423 442
424 IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q"u size %"Q"u\n", 443 IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q"u size %u\n",
425 skip_blkno, blru->size)); 444 skip_blkno, blru->size));
426 445
427 XD3_ASSERT (sfile->source_position <= pos); 446 XD3_ASSERT (sfile->source_position <= pos);
@@ -449,6 +468,7 @@ main_getblk_func (xd3_stream *stream,
449 main_file *sfile = (main_file*) source->ioh; 468 main_file *sfile = (main_file*) source->ioh;
450 main_blklru *blru; 469 main_blklru *blru;
451 int is_new; 470 int is_new;
471 int did_seek = 0;
452 size_t nread = 0; 472 size_t nread = 0;
453 473
454 if (allow_fake_source) 474 if (allow_fake_source)
@@ -486,14 +506,19 @@ main_getblk_func (xd3_stream *stream,
486 return ret; 506 return ret;
487 } 507 }
488 508
489 if ((ret = main_getblk_lru (source, blkno, & blru, & is_new))) 509 /* Indicates that another call to main_getblk_lru() may be
490 { 510 * needed */
491 return ret; 511 did_seek = 1;
492 }
493 } 512 }
494 513
495 XD3_ASSERT (sfile->source_position == pos); 514 XD3_ASSERT (sfile->source_position == pos);
496 515
516 if (did_seek &&
517 (ret = main_getblk_lru (source, blkno, & blru, & is_new)))
518 {
519 return ret;
520 }
521
497 if ((ret = main_read_primary_input (sfile, 522 if ((ret = main_read_primary_input (sfile,
498 (uint8_t*) blru->blk, 523 (uint8_t*) blru->blk,
499 source->blksize, 524 source->blksize,
diff --git a/xdelta3/xdelta3-decode.h b/xdelta3/xdelta3-decode.h
index 2ffe4a7..c0cb578 100644
--- a/xdelta3/xdelta3-decode.h
+++ b/xdelta3/xdelta3-decode.h
@@ -428,8 +428,8 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst)
428 * copy. */ 428 * copy. */
429 xd3_source *source = stream->src; 429 xd3_source *source = stream->src;
430 xoff_t block = source->cpyoff_blocks; 430 xoff_t block = source->cpyoff_blocks;
431 xoff_t blkoff = source->cpyoff_blkoff; 431 usize_t blkoff = source->cpyoff_blkoff;
432 const xoff_t blksize = source->blksize; 432 const usize_t blksize = source->blksize;
433 int ret; 433 int ret;
434 434
435 xd3_blksize_add (&block, &blkoff, source, inst->addr); 435 xd3_blksize_add (&block, &blkoff, source, inst->addr);
@@ -454,7 +454,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst)
454 (blkoff + take > source->onblk)) 454 (blkoff + take > source->onblk))
455 { 455 {
456 IF_DEBUG1 (XPR(NT "[srcfile] short at blkno %"Q"u onblk " 456 IF_DEBUG1 (XPR(NT "[srcfile] short at blkno %"Q"u onblk "
457 "%"Q"u blksize %"Q"u blkoff %"Q"u take %u\n", 457 "%u blksize %u blkoff %u take %u\n",
458 block, 458 block,
459 source->onblk, 459 source->onblk,
460 blksize, 460 blksize,
@@ -475,7 +475,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst)
475 } 475 }
476 else 476 else
477 { 477 {
478 take = (usize_t) (blksize - blkoff); 478 take = blksize - blkoff;
479 inst->size -= take; 479 inst->size -= take;
480 inst->addr += take; 480 inst->addr += take;
481 481
@@ -1095,8 +1095,8 @@ xd3_decode_input (xd3_stream *stream)
1095 IF_DEBUG1(DP(RINT 1095 IF_DEBUG1(DP(RINT
1096 "decode cpyoff %"Q"u " 1096 "decode cpyoff %"Q"u "
1097 "cpyblkno %"Q"u " 1097 "cpyblkno %"Q"u "
1098 "cpyblkoff %"Q"u " 1098 "cpyblkoff %u "
1099 "blksize %"Q"u\n", 1099 "blksize %u\n",
1100 stream->dec_cpyoff, 1100 stream->dec_cpyoff,
1101 src->cpyoff_blocks, 1101 src->cpyoff_blocks,
1102 src->cpyoff_blkoff, 1102 src->cpyoff_blkoff,
diff --git a/xdelta3/xdelta3-fgk.h b/xdelta3/xdelta3-fgk.h
index b85e2c2..7011500 100644
--- a/xdelta3/xdelta3-fgk.h
+++ b/xdelta3/xdelta3-fgk.h
@@ -191,7 +191,7 @@ static fgk_stream* fgk_alloc (xd3_stream *stream /*, int alphabet_size0 */)
191static int fgk_init (xd3_stream *stream, fgk_stream *h, int is_encode) 191static int fgk_init (xd3_stream *stream, fgk_stream *h, int is_encode)
192{ 192{
193 usize_t ui; 193 usize_t ui;
194 int si; 194 ssize_t si;
195 195
196 h->root_node = h->alphabet; 196 h->root_node = h->alphabet;
197 h->decode_ptr = h->root_node; 197 h->decode_ptr = h->root_node;
@@ -217,7 +217,7 @@ static int fgk_init (xd3_stream *stream, fgk_stream *h, int is_encode)
217 /* Zero frequency nodes are inserted in the first alphabet_size 217 /* Zero frequency nodes are inserted in the first alphabet_size
218 * positions, with Value, weight, and a pointer to the next zero 218 * positions, with Value, weight, and a pointer to the next zero
219 * frequency node. */ 219 * frequency node. */
220 for (si = (int)(h->alphabet_size - 1U); si >= 0; si -= 1) 220 for (si = h->alphabet_size - 1; si >= 0; si -= 1)
221 { 221 {
222 fgk_init_node (h->alphabet + si, (usize_t) si, h->alphabet_size); 222 fgk_init_node (h->alphabet + si, (usize_t) si, h->alphabet_size);
223 } 223 }
@@ -655,7 +655,7 @@ static void fgk_factor_remaining (fgk_stream *h)
655 i >>= 1; 655 i >>= 1;
656 } 656 }
657 657
658 i = 1U << h->zero_freq_exp; 658 i = 1 << h->zero_freq_exp;
659 659
660 h->zero_freq_rem = h->zero_freq_count - i; 660 h->zero_freq_rem = h->zero_freq_count - i;
661} 661}
diff --git a/xdelta3/xdelta3-hash.h b/xdelta3/xdelta3-hash.h
index dd74734..e359436 100644
--- a/xdelta3/xdelta3-hash.h
+++ b/xdelta3/xdelta3-hash.h
@@ -134,14 +134,14 @@ xd3_lcksum (const uint8_t *seg, const usize_t ln)
134 134
135#if XD3_ENCODER 135#if XD3_ENCODER
136static usize_t 136static usize_t
137xd3_size_log2 (size_t slots) 137xd3_size_log2 (usize_t slots)
138{ 138{
139 usize_t bits = 31; 139 int bits = 28; /* This should not be an unreasonable limit. */
140 usize_t i; 140 int i;
141 141
142 for (i = 3; i <= bits; i += 1) 142 for (i = 3; i <= bits; i += 1)
143 { 143 {
144 if (slots < (1ULL << i)) 144 if (slots < (1U << i))
145 { 145 {
146 /* TODO: this is compaction=1 in checksum_test.cc and maybe should 146 /* TODO: this is compaction=1 in checksum_test.cc and maybe should
147 * not be fixed at -1. */ 147 * not be fixed at -1. */
@@ -155,12 +155,13 @@ xd3_size_log2 (size_t slots)
155 155
156static void 156static void
157xd3_size_hashtable (xd3_stream *stream, 157xd3_size_hashtable (xd3_stream *stream,
158 size_t slots, 158 usize_t slots,
159 xd3_hash_cfg *cfg) 159 xd3_hash_cfg *cfg)
160{ 160{
161 usize_t bits = xd3_size_log2 (slots); 161 int bits = xd3_size_log2 (slots);
162 162
163 cfg->size = (1U << bits); 163 /* TODO: there's a 32-bit assumption here */
164 cfg->size = (1 << bits);
164 cfg->mask = (cfg->size - 1); 165 cfg->mask = (cfg->size - 1);
165 cfg->shift = 32 - bits; 166 cfg->shift = 32 - bits;
166} 167}
diff --git a/xdelta3/xdelta3-internal.h b/xdelta3/xdelta3-internal.h
index 122cc02..13f4a34 100644
--- a/xdelta3/xdelta3-internal.h
+++ b/xdelta3/xdelta3-internal.h
@@ -40,7 +40,7 @@ int main_file_read (main_file *ifile,
40 const char *msg); 40 const char *msg);
41int main_file_write (main_file *ofile, uint8_t *buf, 41int main_file_write (main_file *ofile, uint8_t *buf,
42 usize_t size, const char *msg); 42 usize_t size, const char *msg);
43xoff_t xd3_bytes_on_srcblk (xd3_source *src, xoff_t blkno); 43usize_t xd3_bytes_on_srcblk (xd3_source *src, xoff_t blkno);
44xoff_t xd3_source_eof(const xd3_source *src); 44xoff_t xd3_source_eof(const xd3_source *src);
45uint32_t xd3_large_cksum_update (uint32_t cksum, 45uint32_t xd3_large_cksum_update (uint32_t cksum,
46 const uint8_t *base, 46 const uint8_t *base,
diff --git a/xdelta3/xdelta3-list.h b/xdelta3/xdelta3-list.h
index 9b3bc2b..6e3125f 100644
--- a/xdelta3/xdelta3-list.h
+++ b/xdelta3/xdelta3-list.h
@@ -111,11 +111,11 @@ LTYPE ## _next (ETYPE *f) \
111 return LTYPE ## _entry (f->LNAME.next); \ 111 return LTYPE ## _entry (f->LNAME.next); \
112} \ 112} \
113 \ 113 \
114static inline size_t \ 114static inline usize_t \
115LTYPE ## _length (LTYPE *l) \ 115LTYPE ## _length (LTYPE *l) \
116{ \ 116{ \
117 LTYPE *p; \ 117 LTYPE *p; \
118 size_t c = 0; \ 118 int c = 0; \
119 \ 119 \
120 for (p = l->next; p != l; p = p->next) \ 120 for (p = l->next; p != l; p = p->next) \
121 { \ 121 { \
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index b0bf370..af2336d 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -296,6 +296,9 @@ static main_extcomp extcomp_types[] =
296 { "gzip", "-c", "gzip", "-dc", "G", "\037\213", 2, 0 }, 296 { "gzip", "-c", "gzip", "-dc", "G", "\037\213", 2, 0 },
297 { "compress", "-c", "uncompress", "-c", "Z", "\037\235", 2, 0 }, 297 { "compress", "-c", "uncompress", "-c", "Z", "\037\235", 2, 0 },
298 298
299 /* TODO: add commandline support for magic-less formats */
300 /*{ "lzma", "-c", "lzma", "-dc", "M", "]\000", 2, 0 },*/
301
299 /* Xz is lzma with a magic number http://tukaani.org/xz/ */ 302 /* Xz is lzma with a magic number http://tukaani.org/xz/ */
300 { "xz", "-c", "xz", "-dc", "Y", "\xfd\x37\x7a\x58\x5a\x00", 2, 0 }, 303 { "xz", "-c", "xz", "-dc", "Y", "\xfd\x37\x7a\x58\x5a\x00", 2, 0 },
301}; 304};
@@ -357,7 +360,7 @@ static int
357main_version (void) 360main_version (void)
358{ 361{
359 /* $Format: " XPR(NTR \"Xdelta version $Xdelta3Version$, Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, Joshua MacDonald\\n\");" $ */ 362 /* $Format: " XPR(NTR \"Xdelta version $Xdelta3Version$, Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, Joshua MacDonald\\n\");" $ */
360 XPR(NTR "Xdelta version 3.0.5, Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, Joshua MacDonald\n"); 363 XPR(NTR "Xdelta version 3.0.6, Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, Joshua MacDonald\n");
361 XPR(NTR "Xdelta comes with ABSOLUTELY NO WARRANTY.\n"); 364 XPR(NTR "Xdelta comes with ABSOLUTELY NO WARRANTY.\n");
362 XPR(NTR "This is free software, and you are welcome to redistribute it\n"); 365 XPR(NTR "This is free software, and you are welcome to redistribute it\n");
363 XPR(NTR "under certain conditions; see \"COPYING\" for details.\n"); 366 XPR(NTR "under certain conditions; see \"COPYING\" for details.\n");
@@ -2415,7 +2418,7 @@ main_secondary_decompress_check (main_file *file,
2415{ 2418{
2416 int ret; 2419 int ret;
2417 usize_t i; 2420 usize_t i;
2418 size_t try_read = min (input_size, XD3_ALLOCSIZE); 2421 usize_t try_read = min (input_size, XD3_ALLOCSIZE);
2419 size_t check_nread = 0; 2422 size_t check_nread = 0;
2420 uint8_t check_buf[XD3_ALLOCSIZE]; /* TODO: stack limit */ 2423 uint8_t check_buf[XD3_ALLOCSIZE]; /* TODO: stack limit */
2421 const main_extcomp *decompressor = NULL; 2424 const main_extcomp *decompressor = NULL;
@@ -3227,8 +3230,8 @@ main_input (xd3_cmd cmd,
3227 main_get_appheader (& stream, ifile, ofile, sfile); 3230 main_get_appheader (& stream, ifile, ofile, sfile);
3228 3231
3229 /* Now open the source file. */ 3232 /* Now open the source file. */
3230 if ((sfile->filename != NULL) && 3233 if ((sfile->filename != NULL) &&
3231 (ret = main_set_source (& stream, cmd, sfile, & source))) 3234 (ret = main_set_source (& stream, cmd, sfile, & source)))
3232 { 3235 {
3233 return EXIT_FAILURE; 3236 return EXIT_FAILURE;
3234 } 3237 }
diff --git a/xdelta3/xdelta3-second.h b/xdelta3/xdelta3-second.h
index 5fc93ed..b9830ab 100644
--- a/xdelta3/xdelta3-second.h
+++ b/xdelta3/xdelta3-second.h
@@ -33,7 +33,7 @@ static inline int xd3_decode_bits (xd3_stream *stream,
33 usize_t *valuep) 33 usize_t *valuep)
34{ 34{
35 usize_t value = 0; 35 usize_t value = 0;
36 usize_t vmask = 1U << nbits; 36 usize_t vmask = 1 << nbits;
37 37
38 if (bits->cur_mask == 0x100) { goto next_byte; } 38 if (bits->cur_mask == 0x100) { goto next_byte; }
39 39
@@ -215,7 +215,7 @@ static inline int xd3_encode_bits (xd3_stream *stream,
215 usize_t value) 215 usize_t value)
216{ 216{
217 int ret; 217 int ret;
218 usize_t mask = 1U << nbits; 218 usize_t mask = 1 << nbits;
219 219
220 XD3_ASSERT (nbits > 0); 220 XD3_ASSERT (nbits > 0);
221 XD3_ASSERT (nbits < sizeof (usize_t) * 8); 221 XD3_ASSERT (nbits < sizeof (usize_t) * 8);
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h
index a602a41..fe62a4b 100644
--- a/xdelta3/xdelta3-test.h
+++ b/xdelta3/xdelta3-test.h
@@ -669,13 +669,13 @@ test_forward_match (xd3_stream *stream, int unused)
669 669
670 for (i = 0; i < 256; i++) 670 for (i = 0; i < 256; i++)
671 { 671 {
672 CHECK(xd3_forward_match(buf1, buf2, i) == i); 672 CHECK(xd3_forward_match(buf1, buf2, i) == (int)i);
673 } 673 }
674 674
675 for (i = 0; i < 255; i++) 675 for (i = 0; i < 255; i++)
676 { 676 {
677 buf2[i] = 1; 677 buf2[i] = 1;
678 CHECK(xd3_forward_match(buf1, buf2, 256) == i); 678 CHECK(xd3_forward_match(buf1, buf2, 256) == (int)i);
679 buf2[i] = 0; 679 buf2[i] = 0;
680 } 680 }
681 681
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index 23a6622..608622a 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -533,7 +533,7 @@ static int xd3_srcwin_move_point (xd3_stream *stream,
533static int xd3_emit_run (xd3_stream *stream, usize_t pos, 533static int xd3_emit_run (xd3_stream *stream, usize_t pos,
534 usize_t size, uint8_t *run_c); 534 usize_t size, uint8_t *run_c);
535static usize_t xd3_checksum_hash (const xd3_hash_cfg *cfg, 535static usize_t xd3_checksum_hash (const xd3_hash_cfg *cfg,
536 const usize_t cksum); 536 const usize_t cksum);
537static xoff_t xd3_source_cksum_offset(xd3_stream *stream, usize_t low); 537static xoff_t xd3_source_cksum_offset(xd3_stream *stream, usize_t low);
538static void xd3_scksum_insert (xd3_stream *stream, 538static void xd3_scksum_insert (xd3_stream *stream,
539 usize_t inx, 539 usize_t inx,
@@ -999,7 +999,7 @@ static void
999xd3_build_code_table (const xd3_code_table_desc *desc, xd3_dinst *tbl) 999xd3_build_code_table (const xd3_code_table_desc *desc, xd3_dinst *tbl)
1000{ 1000{
1001 usize_t size1, size2, mode; 1001 usize_t size1, size2, mode;
1002 usize_t cpy_modes = 2U + desc->near_modes + desc->same_modes; 1002 usize_t cpy_modes = 2 + desc->near_modes + desc->same_modes;
1003 xd3_dinst *d = tbl; 1003 xd3_dinst *d = tbl;
1004 1004
1005 (d++)->type1 = XD3_RUN; 1005 (d++)->type1 = XD3_RUN;
@@ -1015,8 +1015,7 @@ xd3_build_code_table (const xd3_code_table_desc *desc, xd3_dinst *tbl)
1015 { 1015 {
1016 (d++)->type1 = XD3_CPY + mode; 1016 (d++)->type1 = XD3_CPY + mode;
1017 1017
1018 for (size1 = MIN_MATCH; size1 < MIN_MATCH + desc->cpy_sizes; 1018 for (size1 = MIN_MATCH; size1 < MIN_MATCH + desc->cpy_sizes; size1 += 1, d += 1)
1019 size1 += 1, d += 1)
1020 { 1019 {
1021 d->type1 = XD3_CPY + mode; 1020 d->type1 = XD3_CPY + mode;
1022 d->size1 = size1; 1021 d->size1 = size1;
@@ -1530,10 +1529,10 @@ xd3_swap_usize_t (usize_t* p1, usize_t* p2)
1530 1529
1531/* It's not constant time, but it computes the log. */ 1530/* It's not constant time, but it computes the log. */
1532static int 1531static int
1533xd3_check_pow2 (xoff_t value, int *logof) 1532xd3_check_pow2 (xoff_t value, usize_t *logof)
1534{ 1533{
1535 xoff_t x = 1; 1534 xoff_t x = 1;
1536 int nolog; 1535 usize_t nolog;
1537 if (logof == NULL) { 1536 if (logof == NULL) {
1538 logof = &nolog; 1537 logof = &nolog;
1539 } 1538 }
@@ -1594,16 +1593,17 @@ xd3_round_blksize (usize_t sz, usize_t blksz)
1594#define A32_DO8(buf,i) A32_DO4(buf,i); A32_DO4(buf,i+4); 1593#define A32_DO8(buf,i) A32_DO4(buf,i); A32_DO4(buf,i+4);
1595#define A32_DO16(buf) A32_DO8(buf,0); A32_DO8(buf,8); 1594#define A32_DO16(buf) A32_DO8(buf,0); A32_DO8(buf,8);
1596 1595
1597static uint32_t adler32 (uint32_t adler, const uint8_t *buf, size_t len) 1596static unsigned long adler32 (unsigned long adler, const uint8_t *buf,
1597 usize_t len)
1598{ 1598{
1599 uint32_t s1 = adler & 0xffff; 1599 unsigned long s1 = adler & 0xffff;
1600 uint32_t s2 = (adler >> 16) & 0xffff; 1600 unsigned long s2 = (adler >> 16) & 0xffff;
1601 int k; 1601 int k;
1602 1602
1603 while (len > 0) 1603 while (len > 0)
1604 { 1604 {
1605 k = (len < A32_NMAX) ? (int) len : A32_NMAX; 1605 k = (len < A32_NMAX) ? len : A32_NMAX;
1606 len -= (size_t) k; 1606 len -= k;
1607 1607
1608 while (k >= 16) 1608 while (k >= 16)
1609 { 1609 {
@@ -2560,9 +2560,9 @@ xoff_t xd3_source_eof(const xd3_source *src)
2560} 2560}
2561 2561
2562inline 2562inline
2563xoff_t xd3_bytes_on_srcblk (xd3_source *src, xoff_t blkno) 2563usize_t xd3_bytes_on_srcblk (xd3_source *src, xoff_t blkno)
2564{ 2564{
2565 xoff_t r = (blkno == src->max_blkno ? 2565 usize_t r = (blkno == src->max_blkno ?
2566 src->onlastblk : 2566 src->onlastblk :
2567 src->blksize); 2567 src->blksize);
2568 return r; 2568 return r;
@@ -2653,7 +2653,7 @@ int
2653xd3_set_source (xd3_stream *stream, 2653xd3_set_source (xd3_stream *stream,
2654 xd3_source *src) 2654 xd3_source *src)
2655{ 2655{
2656 int shiftby; 2656 usize_t shiftby;
2657 2657
2658 stream->src = src; 2658 stream->src = src;
2659 src->srclen = 0; 2659 src->srclen = 0;
@@ -2665,16 +2665,16 @@ xd3_set_source (xd3_stream *stream,
2665 { 2665 {
2666 src->blksize = xd3_pow2_roundup(src->blksize); 2666 src->blksize = xd3_pow2_roundup(src->blksize);
2667 xd3_check_pow2 (src->blksize, &shiftby); 2667 xd3_check_pow2 (src->blksize, &shiftby);
2668 IF_DEBUG1 (DP(RINT "raising src_blksz to %"Q"u\n", src->blksize)); 2668 IF_DEBUG1 (DP(RINT "raising src_blksz to %u\n", src->blksize));
2669 } 2669 }
2670 2670
2671 src->shiftby = shiftby; 2671 src->shiftby = shiftby;
2672 src->maskby = (1U << shiftby) - 1; 2672 src->maskby = (1 << shiftby) - 1;
2673 2673
2674 if (xd3_check_pow2 (src->max_winsize, NULL) != 0) 2674 if (xd3_check_pow2 (src->max_winsize, NULL) != 0)
2675 { 2675 {
2676 src->max_winsize = xd3_xoff_roundup(src->max_winsize); 2676 src->max_winsize = xd3_xoff_roundup(src->max_winsize);
2677 IF_DEBUG1 (DP(RINT "raising src_maxsize to %"Q"u\n", src->blksize)); 2677 IF_DEBUG1 (DP(RINT "raising src_maxsize to %u\n", src->blksize));
2678 } 2678 }
2679 src->max_winsize = max(src->max_winsize, XD3_ALLOCSIZE); 2679 src->max_winsize = max(src->max_winsize, XD3_ALLOCSIZE);
2680 2680
@@ -3696,8 +3696,8 @@ xd3_encode_init (xd3_stream *stream, int full_init)
3696 * identical or short inputs require no table allocation. */ 3696 * identical or short inputs require no table allocation. */
3697 if (large_comp) 3697 if (large_comp)
3698 { 3698 {
3699 usize_t hash_values = (usize_t) (stream->src->max_winsize / 3699 usize_t hash_values = (stream->src->max_winsize /
3700 (xoff_t) stream->smatcher.large_step); 3700 stream->smatcher.large_step);
3701 3701
3702 xd3_size_hashtable (stream, 3702 xd3_size_hashtable (stream,
3703 hash_values, 3703 hash_values,
@@ -4138,7 +4138,7 @@ xd3_process_memory (int is_encode,
4138 config.winsize = min(input_size, (usize_t) XD3_DEFAULT_WINSIZE); 4138 config.winsize = min(input_size, (usize_t) XD3_DEFAULT_WINSIZE);
4139 config.iopt_size = min(input_size / 32, XD3_DEFAULT_IOPT_SIZE); 4139 config.iopt_size = min(input_size / 32, XD3_DEFAULT_IOPT_SIZE);
4140 config.iopt_size = max(config.iopt_size, 128U); 4140 config.iopt_size = max(config.iopt_size, 128U);
4141 config.sprevsz = (usize_t) xd3_pow2_roundup (config.winsize); 4141 config.sprevsz = xd3_pow2_roundup (config.winsize);
4142 } 4142 }
4143 4143
4144 if ((ret = xd3_config_stream (&stream, &config)) != 0) 4144 if ((ret = xd3_config_stream (&stream, &config)) != 0)
@@ -4560,21 +4560,19 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos)
4560 return 1; 4560 return 1;
4561} 4561}
4562 4562
4563static inline xoff_t 4563static inline int
4564xd3_forward_match(const uint8_t *s1c, const uint8_t *s2c, size_t n) 4564xd3_forward_match(const uint8_t *s1c, const uint8_t *s2c, int n)
4565{ 4565{
4566 size_t i = 0; 4566 int i = 0;
4567#if UNALIGNED_OK 4567#if UNALIGNED_OK
4568 const size_t ssize = sizeof(size_t); 4568 int nint = n / sizeof(int);
4569 const size_t nint = n / ssize;
4570 4569
4571 /* If there are at least 8 elements */
4572 if (nint >> 3) 4570 if (nint >> 3)
4573 { 4571 {
4574 usize_t j = 0; 4572 int j = 0;
4575 const size_t *s1 = (const size_t*)s1c; 4573 const int *s1 = (const int*)s1c;
4576 const size_t *s2 = (const size_t*)s2c; 4574 const int *s2 = (const int*)s2c;
4577 const size_t nint_8 = nint - 8; 4575 int nint_8 = nint - 8;
4578 4576
4579 while (i <= nint_8 && 4577 while (i <= nint_8 &&
4580 s1[i++] == s2[j++] && 4578 s1[i++] == s2[j++] &&
@@ -4586,7 +4584,7 @@ xd3_forward_match(const uint8_t *s1c, const uint8_t *s2c, size_t n)
4586 s1[i++] == s2[j++] && 4584 s1[i++] == s2[j++] &&
4587 s1[i++] == s2[j++]) { } 4585 s1[i++] == s2[j++]) { }
4588 4586
4589 i = (i - 1) * ssize; 4587 i = (i - 1) * sizeof(int);
4590 } 4588 }
4591#endif 4589#endif
4592 4590
@@ -4617,9 +4615,9 @@ xd3_source_extend_match (xd3_stream *stream)
4617 of the input match being tested. */ 4615 of the input match being tested. */
4618 xoff_t tryblk; /* tryblk, tryoff are the block, offset position 4616 xoff_t tryblk; /* tryblk, tryoff are the block, offset position
4619 of matchoff */ 4617 of matchoff */
4620 xoff_t tryoff; 4618 usize_t tryoff;
4621 xoff_t tryrem; /* tryrem is the number of matchable bytes */ 4619 usize_t tryrem; /* tryrem is the number of matchable bytes */
4622 xoff_t matched; 4620 usize_t matched;
4623 4621
4624 IF_DEBUG2(DP(RINT "[extend match] srcpos %"Q"u\n", 4622 IF_DEBUG2(DP(RINT "[extend match] srcpos %"Q"u\n",
4625 stream->match_srcpos)); 4623 stream->match_srcpos));
@@ -4722,8 +4720,8 @@ xd3_source_extend_match (xd3_stream *stream)
4722 stream->next_in + streamoff, 4720 stream->next_in + streamoff,
4723 tryrem); 4721 tryrem);
4724 tryoff += matched; 4722 tryoff += matched;
4725 streamoff += (xoff_t) matched; 4723 streamoff += matched;
4726 stream->match_fwd += (xoff_t) matched; 4724 stream->match_fwd += matched;
4727 4725
4728 if (tryrem != matched) 4726 if (tryrem != matched)
4729 { 4727 {
@@ -5096,7 +5094,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point)
5096 { 5094 {
5097 xoff_t blkno; 5095 xoff_t blkno;
5098 xoff_t blkbaseoffset; 5096 xoff_t blkbaseoffset;
5099 xoff_t blkrem; 5097 usize_t blkrem;
5100 ssize_t oldpos; /* Using ssize_t because of a */ 5098 ssize_t oldpos; /* Using ssize_t because of a */
5101 ssize_t blkpos; /* do { blkpos-- } 5099 ssize_t blkpos; /* do { blkpos-- }
5102 while (blkpos >= oldpos); */ 5100 while (blkpos >= oldpos); */
@@ -5154,11 +5152,12 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point)
5154 usize_t hval = xd3_checksum_hash (& stream->large_hash, cksum); 5152 usize_t hval = xd3_checksum_hash (& stream->large_hash, cksum);
5155 5153
5156 stream->large_table[hval] = 5154 stream->large_table[hval] =
5157 (uint32_t) (blkbaseoffset + (xoff_t)(blkpos + HASH_CKOFFSET)); 5155 (usize_t) (blkbaseoffset +
5156 (xoff_t)(blkpos + HASH_CKOFFSET));
5158 5157
5159 IF_DEBUG (stream->large_ckcnt += 1); 5158 IF_DEBUG (stream->large_ckcnt += 1);
5160 5159
5161 blkpos -= (ssize_t) stream->smatcher.large_step; 5160 blkpos -= stream->smatcher.large_step;
5162 } 5161 }
5163 while (blkpos >= oldpos); 5162 while (blkpos >= oldpos);
5164 5163
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index c05df08..686e05c 100644
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -110,6 +110,7 @@
110 */ 110 */
111#ifndef _WIN32 111#ifndef _WIN32
112#include <stdint.h> 112#include <stdint.h>
113typedef uint32_t usize_t;
113#else 114#else
114#define WIN32_LEAN_AND_MEAN 115#define WIN32_LEAN_AND_MEAN
115#if XD3_USE_LARGEFILE64 116#if XD3_USE_LARGEFILE64
@@ -124,9 +125,10 @@
124#define _WIN32_WINNT 0x0400 125#define _WIN32_WINNT 0x0400
125#endif 126#endif
126#include <windows.h> 127#include <windows.h>
128typedef uint32_t usize_t;
127#ifdef _MSC_VER 129#ifdef _MSC_VER
128#define inline 130#define inline
129typedef signed long ssize_t; 131typedef signed int ssize_t;
130#if _MSC_VER < 1600 132#if _MSC_VER < 1600
131typedef unsigned char uint8_t; 133typedef unsigned char uint8_t;
132typedef unsigned short uint16_t; 134typedef unsigned short uint16_t;
@@ -142,8 +144,6 @@ typedef ULONGLONG uint64_t;
142#endif 144#endif
143#endif 145#endif
144 146
145typedef uint32_t usize_t;
146
147#if XD3_USE_LARGEFILE64 147#if XD3_USE_LARGEFILE64
148#define __USE_FILE_OFFSET64 1 /* GLIBC: for 64bit fileops, ... ? */ 148#define __USE_FILE_OFFSET64 1 /* GLIBC: for 64bit fileops, ... ? */
149#ifndef _LARGEFILE_SOURCE 149#ifndef _LARGEFILE_SOURCE
@@ -632,9 +632,9 @@ struct _xd3_smatcher
632/* hash table size & power-of-two hash function. */ 632/* hash table size & power-of-two hash function. */
633struct _xd3_hash_cfg 633struct _xd3_hash_cfg
634{ 634{
635 usize_t size; 635 usize_t size;
636 usize_t shift; 636 usize_t shift;
637 usize_t mask; 637 usize_t mask;
638}; 638};
639 639
640/* the sprev list */ 640/* the sprev list */
@@ -718,7 +718,7 @@ struct _xd3_config
718struct _xd3_source 718struct _xd3_source
719{ 719{
720 /* you set */ 720 /* you set */
721 xoff_t blksize; /* block size */ 721 usize_t blksize; /* block size */
722 const char *name; /* its name, for debug/print 722 const char *name; /* its name, for debug/print
723 purposes */ 723 purposes */
724 void *ioh; /* opaque handle */ 724 void *ioh; /* opaque handle */
@@ -727,7 +727,7 @@ struct _xd3_source
727 /* getblk sets */ 727 /* getblk sets */
728 xoff_t curblkno; /* current block number: client 728 xoff_t curblkno; /* current block number: client
729 sets after getblk request */ 729 sets after getblk request */
730 xoff_t onblk; /* number of bytes on current 730 usize_t onblk; /* number of bytes on current
731 block: client sets, must be >= 0 731 block: client sets, must be >= 0
732 and <= blksize */ 732 and <= blksize */
733 const uint8_t *curblk; /* current block array: client 733 const uint8_t *curblk; /* current block array: client
@@ -738,9 +738,9 @@ struct _xd3_source
738 xoff_t srcbase; /* offset of this source window 738 xoff_t srcbase; /* offset of this source window
739 in the source itself */ 739 in the source itself */
740 int shiftby; /* for power-of-two blocksizes */ 740 int shiftby; /* for power-of-two blocksizes */
741 usize_t maskby; /* for power-of-two blocksizes */ 741 int maskby; /* for power-of-two blocksizes */
742 xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */ 742 xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */
743 xoff_t cpyoff_blkoff; /* offset of copy window in 743 usize_t cpyoff_blkoff; /* offset of copy window in
744 blocks, remainder */ 744 blocks, remainder */
745 xoff_t getblkno; /* request block number: xd3 sets 745 xoff_t getblkno; /* request block number: xd3 sets
746 current getblk request */ 746 current getblk request */
@@ -753,7 +753,7 @@ struct _xd3_source
753 * source position to be read. 753 * source position to be read.
754 * Otherwise, equal to 754 * Otherwise, equal to
755 * max_blkno. */ 755 * max_blkno. */
756 xoff_t onlastblk; /* Number of bytes on max_blkno */ 756 usize_t onlastblk; /* Number of bytes on max_blkno */
757 int eof_known; /* Set to true when the first 757 int eof_known; /* Set to true when the first
758 * partial block is read. */ 758 * partial block is read. */
759}; 759};
@@ -808,10 +808,10 @@ struct _xd3_stream
808 808
809 xd3_smatcher smatcher; 809 xd3_smatcher smatcher;
810 810
811 uint32_t *large_table; /* table of large checksums */ 811 usize_t *large_table; /* table of large checksums */
812 xd3_hash_cfg large_hash; /* large hash config */ 812 xd3_hash_cfg large_hash; /* large hash config */
813 813
814 uint32_t *small_table; /* table of small checksums */ 814 usize_t *small_table; /* table of small checksums */
815 xd3_slist *small_prev; /* table of previous offsets, 815 xd3_slist *small_prev; /* table of previous offsets,
816 circular linked list */ 816 circular linked list */
817 int small_reset; /* true if small table should 817 int small_reset; /* true if small table should
@@ -1315,19 +1315,19 @@ static inline
1315void xd3_blksize_div (const xoff_t offset, 1315void xd3_blksize_div (const xoff_t offset,
1316 const xd3_source *source, 1316 const xd3_source *source,
1317 xoff_t *blkno, 1317 xoff_t *blkno,
1318 xoff_t *blkoff) { 1318 usize_t *blkoff) {
1319 *blkno = (xoff_t) (offset >> source->shiftby); 1319 *blkno = (xoff_t) (offset >> source->shiftby);
1320 *blkoff = (xoff_t) (offset & source->maskby); 1320 *blkoff = (usize_t) (offset & source->maskby);
1321 XD3_ASSERT (*blkoff < source->blksize); 1321 XD3_ASSERT (*blkoff < source->blksize);
1322} 1322}
1323 1323
1324static inline 1324static inline
1325void xd3_blksize_add (xoff_t *blkno, 1325void xd3_blksize_add (xoff_t *blkno,
1326 xoff_t *blkoff, 1326 usize_t *blkoff,
1327 const xd3_source *source, 1327 const xd3_source *source,
1328 const usize_t add) 1328 const usize_t add)
1329{ 1329{
1330 xoff_t blkdiff; 1330 usize_t blkdiff;
1331 1331
1332 /* Does not check for overflow, checked in xdelta3-decode.h. */ 1332 /* Does not check for overflow, checked in xdelta3-decode.h. */
1333 *blkoff += add; 1333 *blkoff += add;
diff --git a/xdelta3/xdelta3.prj b/xdelta3/xdelta3.prj
index 96abed7..74aaa8a 100644
--- a/xdelta3/xdelta3.prj
+++ b/xdelta3/xdelta3.prj
@@ -9,7 +9,7 @@
9(Checkin-Login jmacd) 9(Checkin-Login jmacd)
10(Populate-Ignore ("\\.svn")) 10(Populate-Ignore ("\\.svn"))
11(Project-Keywords 11(Project-Keywords
12 (Xdelta3Version "3.0.5") 12 (Xdelta3Version "3.0.6")
13 ) 13 )
14(Files 14(Files
15 (COPYING (xdelta3/b/29_COPYING 1.1 744)) 15 (COPYING (xdelta3/b/29_COPYING 1.1 744))