OLD | NEW |
1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
2 // | 2 // |
3 /// \file block_encoder.c | 3 /// \file block_encoder.c |
4 /// \brief Encodes .xz Blocks | 4 /// \brief Encodes .xz Blocks |
5 // | 5 // |
6 // Author: Lasse Collin | 6 // Author: Lasse Collin |
7 // | 7 // |
8 // This file has been put into the public domain. | 8 // This file has been put into the public domain. |
9 // You can do whatever you want with this file. | 9 // You can do whatever you want with this file. |
10 // | 10 // |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 block_encoder_end(lzma_coder *coder, lzma_allocator *allocator) | 137 block_encoder_end(lzma_coder *coder, lzma_allocator *allocator) |
138 { | 138 { |
139 lzma_next_end(&coder->next, allocator); | 139 lzma_next_end(&coder->next, allocator); |
140 lzma_free(coder, allocator); | 140 lzma_free(coder, allocator); |
141 return; | 141 return; |
142 } | 142 } |
143 | 143 |
144 | 144 |
145 static lzma_ret | 145 static lzma_ret |
146 block_encoder_update(lzma_coder *coder, lzma_allocator *allocator, | 146 block_encoder_update(lzma_coder *coder, lzma_allocator *allocator, |
147 » » const lzma_filter *filters lzma_attribute((unused)), | 147 » » const lzma_filter *filters lzma_attribute((__unused__)), |
148 const lzma_filter *reversed_filters) | 148 const lzma_filter *reversed_filters) |
149 { | 149 { |
150 if (coder->sequence != SEQ_CODE) | 150 if (coder->sequence != SEQ_CODE) |
151 return LZMA_PROG_ERROR; | 151 return LZMA_PROG_ERROR; |
152 | 152 |
153 return lzma_next_filter_update( | 153 return lzma_next_filter_update( |
154 &coder->next, allocator, reversed_filters); | 154 &coder->next, allocator, reversed_filters); |
155 } | 155 } |
156 | 156 |
157 | 157 |
158 extern lzma_ret | 158 extern lzma_ret |
159 lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, | 159 lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, |
160 lzma_block *block) | 160 lzma_block *block) |
161 { | 161 { |
162 lzma_next_coder_init(&lzma_block_encoder_init, next, allocator); | 162 lzma_next_coder_init(&lzma_block_encoder_init, next, allocator); |
163 | 163 |
| 164 if (block == NULL) |
| 165 return LZMA_PROG_ERROR; |
| 166 |
| 167 // The contents of the structure may depend on the version so |
| 168 // check the version first. |
164 if (block->version != 0) | 169 if (block->version != 0) |
165 return LZMA_OPTIONS_ERROR; | 170 return LZMA_OPTIONS_ERROR; |
166 | 171 |
167 // If the Check ID is not supported, we cannot calculate the check and | 172 // If the Check ID is not supported, we cannot calculate the check and |
168 // thus not create a proper Block. | 173 // thus not create a proper Block. |
169 if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX) | 174 if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX) |
170 return LZMA_PROG_ERROR; | 175 return LZMA_PROG_ERROR; |
171 | 176 |
172 if (!lzma_check_is_supported(block->check)) | 177 if (!lzma_check_is_supported(block->check)) |
173 return LZMA_UNSUPPORTED_CHECK; | 178 return LZMA_UNSUPPORTED_CHECK; |
(...skipping 29 matching lines...) Expand all Loading... |
203 extern LZMA_API(lzma_ret) | 208 extern LZMA_API(lzma_ret) |
204 lzma_block_encoder(lzma_stream *strm, lzma_block *block) | 209 lzma_block_encoder(lzma_stream *strm, lzma_block *block) |
205 { | 210 { |
206 lzma_next_strm_init(lzma_block_encoder_init, strm, block); | 211 lzma_next_strm_init(lzma_block_encoder_init, strm, block); |
207 | 212 |
208 strm->internal->supported_actions[LZMA_RUN] = true; | 213 strm->internal->supported_actions[LZMA_RUN] = true; |
209 strm->internal->supported_actions[LZMA_FINISH] = true; | 214 strm->internal->supported_actions[LZMA_FINISH] = true; |
210 | 215 |
211 return LZMA_OK; | 216 return LZMA_OK; |
212 } | 217 } |
OLD | NEW |