diff options
Diffstat (limited to 'xdelta3/xdelta3.h')
-rw-r--r-- | xdelta3/xdelta3.h | 47 |
1 files changed, 9 insertions, 38 deletions
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index 9ee90d6..15b53a6 100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h | |||
@@ -341,9 +341,8 @@ typedef enum { | |||
341 | XD3_INTERNAL = -17710, /* internal error */ | 341 | XD3_INTERNAL = -17710, /* internal error */ |
342 | XD3_INVALID = -17711, /* invalid config */ | 342 | XD3_INVALID = -17711, /* invalid config */ |
343 | XD3_INVALID_INPUT = -17712, /* invalid input/decoder error */ | 343 | XD3_INVALID_INPUT = -17712, /* invalid input/decoder error */ |
344 | XD3_NOSECOND = -17713, /* when secondary compression finds no | 344 | XD3_NOSECOND = -17713, /* when secondary compression finds no |
345 | improvement. */ | 345 | improvement. */ |
346 | |||
347 | } xd3_rvalues; | 346 | } xd3_rvalues; |
348 | 347 | ||
349 | /* special values in config->flags */ | 348 | /* special values in config->flags */ |
@@ -717,7 +716,6 @@ struct _xd3_config | |||
717 | struct _xd3_source | 716 | struct _xd3_source |
718 | { | 717 | { |
719 | /* you set */ | 718 | /* you set */ |
720 | xoff_t size; /* size of this source */ | ||
721 | usize_t blksize; /* block size */ | 719 | usize_t blksize; /* block size */ |
722 | const char *name; /* its name, for debug/print | 720 | const char *name; /* its name, for debug/print |
723 | purposes */ | 721 | purposes */ |
@@ -727,8 +725,8 @@ struct _xd3_source | |||
727 | xoff_t curblkno; /* current block number: client | 725 | xoff_t curblkno; /* current block number: client |
728 | sets after getblk request */ | 726 | sets after getblk request */ |
729 | usize_t onblk; /* number of bytes on current | 727 | usize_t onblk; /* number of bytes on current |
730 | block: client sets, xd3 | 728 | block: client sets, must be >= 0 |
731 | verifies */ | 729 | and <= blksize */ |
732 | const uint8_t *curblk; /* current block array: client | 730 | const uint8_t *curblk; /* current block array: client |
733 | sets after getblk request */ | 731 | sets after getblk request */ |
734 | 732 | ||
@@ -736,9 +734,6 @@ struct _xd3_source | |||
736 | usize_t srclen; /* length of this source window */ | 734 | usize_t srclen; /* length of this source window */ |
737 | xoff_t srcbase; /* offset of this source window | 735 | xoff_t srcbase; /* offset of this source window |
738 | in the source itself */ | 736 | in the source itself */ |
739 | xoff_t blocks; /* the total number of blocks in | ||
740 | this source */ | ||
741 | usize_t onlastblk; /* cached size info, avoid __udivdi3 */ | ||
742 | int shiftby; /* for power-of-two blocksizes */ | 737 | int shiftby; /* for power-of-two blocksizes */ |
743 | int maskby; /* for power-of-two blocksizes */ | 738 | int maskby; /* for power-of-two blocksizes */ |
744 | xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */ | 739 | xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */ |
@@ -746,6 +741,11 @@ struct _xd3_source | |||
746 | blocks, remainder */ | 741 | blocks, remainder */ |
747 | xoff_t getblkno; /* request block number: xd3 sets | 742 | xoff_t getblkno; /* request block number: xd3 sets |
748 | current getblk request */ | 743 | current getblk request */ |
744 | |||
745 | xoff_t max_blkno; | ||
746 | xoff_t frontier_blkno; | ||
747 | usize_t onlastblk; | ||
748 | int eof_known; | ||
749 | }; | 749 | }; |
750 | 750 | ||
751 | /* The primary xd3_stream object, used for encoding and decoding. You | 751 | /* The primary xd3_stream object, used for encoding and decoding. You |
@@ -1292,33 +1292,4 @@ void xd3_blksize_div (const xoff_t offset, | |||
1292 | (offset - *blkno * source->blksize); | 1292 | (offset - *blkno * source->blksize); |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | /* This function tells the number of bytes expected to be set in | ||
1296 | * source->onblk after a getblk request. This is for convenience of | ||
1297 | * handling a partial last block. Note that this is a relatively | ||
1298 | * expensive function for 64-bit binaries on platforms w/o native | ||
1299 | * 64-bit integers, so source->onlastblk is set to this value. | ||
1300 | * TODO: force source->blksize to a power of two? */ | ||
1301 | static inline | ||
1302 | usize_t xd3_bytes_on_srcblk (xd3_source *source, xoff_t blkno) | ||
1303 | { | ||
1304 | xoff_t s_1_div; | ||
1305 | usize_t s_1_rem; | ||
1306 | XD3_ASSERT (blkno < source->blocks); | ||
1307 | |||
1308 | if (blkno != source->blocks - 1) | ||
1309 | { | ||
1310 | return source->blksize; | ||
1311 | } | ||
1312 | xd3_blksize_div(source->size - 1, source, &s_1_div, &s_1_rem); | ||
1313 | return s_1_rem + 1; | ||
1314 | } | ||
1315 | |||
1316 | static inline | ||
1317 | usize_t xd3_bytes_on_srcblk_fast (xd3_source *source, xoff_t blkno) | ||
1318 | { | ||
1319 | return (blkno == source->blocks - 1 ? | ||
1320 | source->onlastblk : | ||
1321 | source->blksize); | ||
1322 | } | ||
1323 | |||
1324 | #endif /* _XDELTA3_H_ */ | 1295 | #endif /* _XDELTA3_H_ */ |