diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-01-20 13:45:41 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-01-20 13:45:41 +0200 |
commit | d8b58d099340f8f4007b24b211ee41a7210c061c (patch) | |
tree | 606250a3fcc228b697f8709e56a12fa91191da69 /src/liblzma/common/block_encoder.h | |
parent | Use LZMA_PROG_ERROR in lzma_code() as documented in base.h. (diff) | |
download | xz-d8b58d099340f8f4007b24b211ee41a7210c061c.tar.xz |
Block encoder cleanups
Diffstat (limited to 'src/liblzma/common/block_encoder.h')
-rw-r--r-- | src/liblzma/common/block_encoder.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/liblzma/common/block_encoder.h b/src/liblzma/common/block_encoder.h index d5b3ec0d..3113dab7 100644 --- a/src/liblzma/common/block_encoder.h +++ b/src/liblzma/common/block_encoder.h @@ -23,6 +23,31 @@ #include "common.h" +/// \brief Biggest Compressed Size value that the Block encoder supports +/// +/// The maximum size of a single Block is limited by the maximum size of +/// a Stream, which in theory is 2^63 - 3 bytes (i.e. LZMA_VLI_MAX - 3). +/// While the size is really big and no one should hit it in practice, we +/// take it into account in some places anyway to catch some errors e.g. if +/// application passes insanely big value to some function. +/// +/// We could take into account the headers etc. to determine the exact +/// maximum size of the Compressed Data field, but the complexity would give +/// us nothing useful. Instead, limit the size of Compressed Data so that +/// even with biggest possible Block Header and Check fields the total +/// encoded size of the Block stays as a valid VLI. This doesn't guarantee +/// that the size of the Stream doesn't grow too big, but that problem is +/// taken care outside the Block handling code. +/// +/// ~LZMA_VLI_C(3) is to guarantee that if we need padding at the end of +/// the Compressed Data field, it will still stay in the proper limit. +/// +/// This constant is in this file because it is needed in both +/// block_encoder.c and block_buffer_encoder.c. +#define COMPRESSED_SIZE_MAX ((LZMA_VLI_MAX - LZMA_BLOCK_HEADER_SIZE_MAX \ + - LZMA_CHECK_SIZE_MAX) & ~LZMA_VLI_C(3)) + + extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, lzma_block *block); |