summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3.h
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2010-02-07 03:00:42 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2010-02-07 03:00:42 +0000
commit3dbebbe46096e17c0298f1cbe315d10b35b4f9ee (patch)
treec2ae665c490d2a4e4cd4365721f4cf807fa1e44b /xdelta3/xdelta3.h
parente7a0eda2519593950a1a0dff77e42d4da9189c3e (diff)
Implement srcwin_maxsz in xd3_source_match_setup(), which prevents
the encoder from seeking backwards further than this parameter. This was supposed to be implemented long ago, but was especially problematic in the recent release, which implements source-from-FIFO.
Diffstat (limited to 'xdelta3/xdelta3.h')
-rw-r--r--xdelta3/xdelta3.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index 5b99a72..f417dcf 100644
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -1,5 +1,6 @@
1/* xdelta 3 - delta compression tools and library 1/* xdelta 3 - delta compression tools and library
2 * Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007. Joshua P. MacDonald 2 * Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007,
3 * 2008, 2009, 2010. Joshua P. MacDonald
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -694,7 +695,8 @@ struct _xd3_config
694 buffer */ 695 buffer */
695 usize_t srcwin_maxsz; /* srcwin_size grows by a factor 696 usize_t srcwin_maxsz; /* srcwin_size grows by a factor
696 of 2 when no matches are 697 of 2 when no matches are
697 found */ 698 found. encoder will not seek
699 back further than this. */
698 700
699 xd3_getblk_func *getblk; /* The three callbacks. */ 701 xd3_getblk_func *getblk; /* The three callbacks. */
700 xd3_alloc_func *alloc; 702 xd3_alloc_func *alloc;
@@ -743,7 +745,7 @@ struct _xd3_source
743 xoff_t srcbase; /* offset of this source window 745 xoff_t srcbase; /* offset of this source window
744 in the source itself */ 746 in the source itself */
745 int shiftby; /* for power-of-two blocksizes */ 747 int shiftby; /* for power-of-two blocksizes */
746 int maskby; /* for power-of-two blocksizes */ 748 int maskby; /* for power-of-two blocksizes */
747 xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */ 749 xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */
748 usize_t cpyoff_blkoff; /* offset of copy window in 750 usize_t cpyoff_blkoff; /* offset of copy window in
749 blocks, remainder */ 751 blocks, remainder */
@@ -799,7 +801,7 @@ struct _xd3_stream
799 void* opaque; /* private data object passed to 801 void* opaque; /* private data object passed to
800 alloc, free, and getblk */ 802 alloc, free, and getblk */
801 int flags; /* various options */ 803 int flags; /* various options */
802 804
803 /* secondary compressor configuration */ 805 /* secondary compressor configuration */
804 xd3_sec_cfg sec_data; /* Secondary compressor config: data */ 806 xd3_sec_cfg sec_data; /* Secondary compressor config: data */
805 xd3_sec_cfg sec_inst; /* Secondary compressor config: inst */ 807 xd3_sec_cfg sec_inst; /* Secondary compressor config: inst */
@@ -1046,7 +1048,7 @@ int xd3_decode_memory (const uint8_t *input,
1046 * xd3_stream stream; 1048 * xd3_stream stream;
1047 * xd3_config config; 1049 * xd3_config config;
1048 * xd3_source src; 1050 * xd3_source src;
1049 * 1051 *
1050 * memset (& src, 0, sizeof (src)); 1052 * memset (& src, 0, sizeof (src));
1051 * memset (& stream, 0, sizeof (stream)); 1053 * memset (& stream, 0, sizeof (stream));
1052 * memset (& config, 0, sizeof (config)); 1054 * memset (& config, 0, sizeof (config));
@@ -1119,7 +1121,7 @@ int xd3_decode_stream (xd3_stream *stream,
1119 * assert(stream->current_window == 0); 1121 * assert(stream->current_window == 0);
1120 * stuff; 1122 * stuff;
1121 * } 1123 * }
1122 * // fallthrough 1124 * // fallthrough
1123 * case XD3_WINSTART: { 1125 * case XD3_WINSTART: {
1124 * something(stream->current_window); 1126 * something(stream->current_window);
1125 * goto again; 1127 * goto again;
@@ -1171,7 +1173,7 @@ void xd3_free_stream (xd3_stream *stream);
1171int xd3_set_source (xd3_stream *stream, 1173int xd3_set_source (xd3_stream *stream,
1172 xd3_source *source); 1174 xd3_source *source);
1173 1175
1174/* If the source size is known, call this instead of xd3_set_source(). 1176/* If the source size is known, call this instead of xd3_set_source().
1175 * to avoid having stream->getblk called (and/or to avoid XD3_GETSRCBLK). 1177 * to avoid having stream->getblk called (and/or to avoid XD3_GETSRCBLK).
1176 * 1178 *
1177 * Follow these steps: 1179 * Follow these steps:
@@ -1231,7 +1233,7 @@ void xd3_init_config (xd3_config *config,
1231 config->flags = flags; 1233 config->flags = flags;
1232} 1234}
1233 1235
1234/* This supplies some input to the stream. 1236/* This supplies some input to the stream.
1235 * 1237 *
1236 * For encoding, if the input is larger than the configured window 1238 * For encoding, if the input is larger than the configured window
1237 * size (xd3_config.winsize), the entire input will be consumed and 1239 * size (xd3_config.winsize), the entire input will be consumed and
@@ -1330,7 +1332,7 @@ void xd3_blksize_add (xoff_t *blkno,
1330 *blkoff += add; 1332 *blkoff += add;
1331 blkdiff = *blkoff >> source->shiftby; 1333 blkdiff = *blkoff >> source->shiftby;
1332 1334
1333 if (blkdiff) 1335 if (blkdiff)
1334 { 1336 {
1335 *blkno += blkdiff; 1337 *blkno += blkdiff;
1336 *blkoff &= source->maskby; 1338 *blkoff &= source->maskby;