From df3d83031d716abbca504cbf0c003dccda750979 Mon Sep 17 00:00:00 2001 From: dotdotisdead Date: Sun, 24 Sep 2006 03:18:55 +0000 Subject: Fixes setting of srcwin_cksum_pos in xd3_srcwin_move_point(), because main's getblk now returns XD3_TOOFARBACK for encode. This had been broken several checkins prior, and was causing XD3_INTERNAL at the 4G boundary. --- xdelta3/Makefile | 6 +++++- xdelta3/xdelta3.c | 15 +++++++++------ xdelta3/xdelta3.h | 17 ++++++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) (limited to 'xdelta3') diff --git a/xdelta3/Makefile b/xdelta3/Makefile index 1e936e4..6cac09e 100755 --- a/xdelta3/Makefile +++ b/xdelta3/Makefile @@ -2,7 +2,7 @@ PYTHON = python PYTGT = build/temp.linux-i686-2.3/xdelta3.so -TARGETS = xdelta3 xdelta3-64 xdelta3-everything \ +TARGETS = xdelta3 xdelta3-2 xdelta3-64 xdelta3-everything \ xdelta3-Opg xdelta3-64-O xdelta3-Op xdelta3-O \ xdelta3-decoder xdelta3-decoder-nomain.o \ $(PYTGT) \ @@ -41,6 +41,10 @@ xdelta3: $(SOURCES) $(CC) -g -Wall -Wshadow xdelta3.c -o xdelta3 -DXD3_MAIN=1 -DGENERIC_ENCODE_TABLES=1 \ -DXD3_USE_LARGEFILE64=1 -DREGRESSION_TEST=1 -DXD3_DEBUG=1 -DSECONDARY_DJW=1 -lm +xdelta3-2: $(SOURCES) + $(CC) -g -Wall -Wshadow xdelta3.c -o xdelta3-2 -DXD3_MAIN=1 -DGENERIC_ENCODE_TABLES=1 \ + -DXD3_USE_LARGEFILE64=1 -DREGRESSION_TEST=1 -DXD3_DEBUG=2 -DSECONDARY_DJW=1 -lm + xdelta3-decoder: $(SOURCES) $(CC) -O2 -Wall -Wshadow xdelta3.c \ -DXD3_ENCODER=0 -DXD3_MAIN=1 -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 \ diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 3f34c35..8229603 100755 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c @@ -5007,7 +5007,8 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) /* Begin by advancing at twice the input rate, up to half the maximum window size. */ logical_input_cksum_pos = min((stream->total_in + stream->input_position) * 2, - (stream->total_in + stream->input_position) + (stream->srcwin_maxsz / 2)); + (stream->total_in + stream->input_position) + + (stream->srcwin_maxsz / 2)); /* If srcwin_cksum_pos is already greater, wait until the difference is met. */ if (stream->srcwin_cksum_pos > logical_input_cksum_pos) @@ -5019,12 +5020,14 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) /* If the stream has matched beyond the srcwin_cksum_pos (good), we shouldn't * begin reading so far back. */ - int diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; + if (stream->match_maxaddr > stream->srcwin_cksum_pos) + { + stream->srcwin_cksum_pos = stream->match_maxaddr; + } - if (diff > stream->srcwin_size) + if (logical_input_cksum_pos < stream->srcwin_cksum_pos) { - // TODO: I think this should use the last match position in the source! - //stream->srcwin_cksum_pos = logical_input_cksum_pos - stream->srcwin_size; + logical_input_cksum_pos = stream->srcwin_cksum_pos; } /* Advance an extra srcwin_size bytes */ @@ -5060,7 +5063,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) } onblk -= stream->large_look; - diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; + int diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; onblk = min(blkoff + diff, onblk); while (blkoff <= onblk) diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index eb11141..b538d77 100755 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h @@ -234,7 +234,9 @@ typedef int (xd3_getblk_func) (xd3_stream *stream, * alternate code tables. See the comments & code enabled by GENERIC_ENCODE_TABLES. */ typedef const xd3_dinst* (xd3_code_table_func) (void); -typedef int (xd3_comp_table_func) (xd3_stream *stream, const uint8_t **data, usize_t *size); +typedef int (xd3_comp_table_func) (xd3_stream *stream, + const uint8_t **data, + usize_t *size); /* Some junk. */ @@ -294,9 +296,9 @@ typedef enum { XD3_GOTHEADER = -17706, /* (decode-only) after the initial VCDIFF & first window header */ XD3_WINSTART = -17707, /* notification: returned before a window is processed, giving a * chance to XD3_SKIP_WINDOW or not XD3_SKIP_EMIT that window. */ - XD3_WINFINISH = -17708, /* notification: returned after encode/decode & output for a window */ + XD3_WINFINISH = -17708, /* notification: returned after encode/decode & output for a window */ XD3_TOOFARBACK = -17709, /* (encoder only) may be returned by getblk() if the block is too old */ - XD3_INTERNAL = -17710, /* internal error */ + XD3_INTERNAL = -17710, /* internal error */ } xd3_rvalues; @@ -314,7 +316,7 @@ typedef enum XD3_SEC_NODATA = (1 << 7), /* disable secondary compression of the data section. */ XD3_SEC_NOINST = (1 << 8), /* disable secondary compression of the inst section. */ - XD3_SEC_NOADDR = (1 << 9), /* disable secondary compression of the addr section (which is most random). */ + XD3_SEC_NOADDR = (1 << 9), /* disable secondary compression of the addr section. */ XD3_SEC_OTHER = (XD3_SEC_NODATA | XD3_SEC_NOINST | XD3_SEC_NOADDR), @@ -604,9 +606,10 @@ struct _xd3_config uint promote; /* whether to promote matches in the hash chain */ }; -/* The primary source file object. You create one of these objects and initialize the first - * four fields. This library maintains the next 5 fields. The configured getblk implementation is - * responsible for setting the final 3 fields when called (and/or when XD3_GETSRCBLK is returned). +/* The primary source file object. You create one of these objects and initialize the + * first four fields. This library maintains the next 5 fields. The configured getblk + * implementation is responsible for setting the final 3 fields when called (and/or when + * XD3_GETSRCBLK is returned). */ struct _xd3_source { -- cgit v1.2.3