aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/block_decoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-09-10 00:27:02 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-09-10 00:27:02 +0300
commit2ba01bfa755e47ff6af84a978e3c8d63d7d2775e (patch)
tree28da43adf9aff178d45995134d4f14aebb4d02f4 /src/liblzma/common/block_decoder.c
parentChanged Filter ID of LZMA to 0x20. (diff)
downloadxz-2ba01bfa755e47ff6af84a978e3c8d63d7d2775e.tar.xz
Cleaned up Block encoder and moved the no longer shared
code from block_private.h to block_decoder.c. Now the Block encoder doesn't need compressed_size and uncompressed_size from lzma_block structure to be initialized.
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/block_decoder.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/liblzma/common/block_decoder.c b/src/liblzma/common/block_decoder.c
index eab25a88..9eb33651 100644
--- a/src/liblzma/common/block_decoder.c
+++ b/src/liblzma/common/block_decoder.c
@@ -18,7 +18,6 @@
///////////////////////////////////////////////////////////////////////////////
#include "block_decoder.h"
-#include "block_private.h"
#include "filter_decoder.h"
#include "check.h"
@@ -56,6 +55,28 @@ struct lzma_coder_s {
};
+static inline bool
+update_size(lzma_vli *size, lzma_vli add, lzma_vli limit)
+{
+ if (limit > LZMA_VLI_VALUE_MAX)
+ limit = LZMA_VLI_VALUE_MAX;
+
+ if (limit < *size || limit - *size < add)
+ return true;
+
+ *size += add;
+
+ return false;
+}
+
+
+static inline bool
+is_size_valid(lzma_vli size, lzma_vli reference)
+{
+ return reference == LZMA_VLI_VALUE_UNKNOWN || reference == size;
+}
+
+
static lzma_ret
block_decode(lzma_coder *coder, lzma_allocator *allocator,
const uint8_t *restrict in, size_t *restrict in_pos,