OLD | NEW |
1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
2 // | 2 // |
3 /// \file index_encoder.c | 3 /// \file index_encoder.c |
4 /// \brief Encodes the Index field | 4 /// \brief Encodes the Index field |
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 24 matching lines...) Expand all Loading... |
35 /// Position in integers | 35 /// Position in integers |
36 size_t pos; | 36 size_t pos; |
37 | 37 |
38 /// CRC32 of the List of Records field | 38 /// CRC32 of the List of Records field |
39 uint32_t crc32; | 39 uint32_t crc32; |
40 }; | 40 }; |
41 | 41 |
42 | 42 |
43 static lzma_ret | 43 static lzma_ret |
44 index_encode(lzma_coder *coder, | 44 index_encode(lzma_coder *coder, |
45 » » lzma_allocator *allocator lzma_attribute((unused)), | 45 » » lzma_allocator *allocator lzma_attribute((__unused__)), |
46 » » const uint8_t *restrict in lzma_attribute((unused)), | 46 » » const uint8_t *restrict in lzma_attribute((__unused__)), |
47 » » size_t *restrict in_pos lzma_attribute((unused)), | 47 » » size_t *restrict in_pos lzma_attribute((__unused__)), |
48 » » size_t in_size lzma_attribute((unused)), | 48 » » size_t in_size lzma_attribute((__unused__)), |
49 uint8_t *restrict out, size_t *restrict out_pos, | 49 uint8_t *restrict out, size_t *restrict out_pos, |
50 » » size_t out_size, lzma_action action lzma_attribute((unused))) | 50 » » size_t out_size, |
| 51 » » lzma_action action lzma_attribute((__unused__))) |
51 { | 52 { |
52 // Position where to start calculating CRC32. The idea is that we | 53 // Position where to start calculating CRC32. The idea is that we |
53 // need to call lzma_crc32() only once per call to index_encode(). | 54 // need to call lzma_crc32() only once per call to index_encode(). |
54 const size_t out_start = *out_pos; | 55 const size_t out_start = *out_pos; |
55 | 56 |
56 // Return value to use if we return at the end of this function. | 57 // Return value to use if we return at the end of this function. |
57 // We use "goto out" to jump out of the while-switch construct | 58 // We use "goto out" to jump out of the while-switch construct |
58 // instead of returning directly, because that way we don't need | 59 // instead of returning directly, because that way we don't need |
59 // to copypaste the lzma_crc32() call to many places. | 60 // to copypaste the lzma_crc32() call to many places. |
60 lzma_ret ret = LZMA_OK; | 61 lzma_ret ret = LZMA_OK; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return LZMA_OK; | 203 return LZMA_OK; |
203 } | 204 } |
204 | 205 |
205 | 206 |
206 extern LZMA_API(lzma_ret) | 207 extern LZMA_API(lzma_ret) |
207 lzma_index_encoder(lzma_stream *strm, const lzma_index *i) | 208 lzma_index_encoder(lzma_stream *strm, const lzma_index *i) |
208 { | 209 { |
209 lzma_next_strm_init(lzma_index_encoder_init, strm, i); | 210 lzma_next_strm_init(lzma_index_encoder_init, strm, i); |
210 | 211 |
211 strm->internal->supported_actions[LZMA_RUN] = true; | 212 strm->internal->supported_actions[LZMA_RUN] = true; |
| 213 strm->internal->supported_actions[LZMA_FINISH] = true; |
212 | 214 |
213 return LZMA_OK; | 215 return LZMA_OK; |
214 } | 216 } |
215 | 217 |
216 | 218 |
217 extern LZMA_API(lzma_ret) | 219 extern LZMA_API(lzma_ret) |
218 lzma_index_buffer_encode(const lzma_index *i, | 220 lzma_index_buffer_encode(const lzma_index *i, |
219 uint8_t *out, size_t *out_pos, size_t out_size) | 221 uint8_t *out, size_t *out_pos, size_t out_size) |
220 { | 222 { |
221 // Validate the arguments. | 223 // Validate the arguments. |
(...skipping 21 matching lines...) Expand all Loading... |
243 // We should never get here, but just in case, restore the | 245 // We should never get here, but just in case, restore the |
244 // output position and set the error accordingly if something | 246 // output position and set the error accordingly if something |
245 // goes wrong and debugging isn't enabled. | 247 // goes wrong and debugging isn't enabled. |
246 assert(0); | 248 assert(0); |
247 *out_pos = out_start; | 249 *out_pos = out_start; |
248 ret = LZMA_PROG_ERROR; | 250 ret = LZMA_PROG_ERROR; |
249 } | 251 } |
250 | 252 |
251 return ret; | 253 return ret; |
252 } | 254 } |
OLD | NEW |