Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/archival/libarchive/decompress_unlzma.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/archival/libarchive/decompress_unlzma.c
r3232 r3621 46 46 47 47 48 /* Called twice: once at startup (LZMA_FAST only) and once in rc_normalize() */49 static size_inlinevoid rc_read(rc_t *rc)48 /* Called once in rc_do_normalize() */ 49 static void rc_read(rc_t *rc) 50 50 { 51 51 int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE); … … 54 54 if (buffer_size <= 0) 55 55 bb_error_msg_and_die("unexpected EOF"); 56 rc->buffer_end = RC_BUFFER + buffer_size; 56 57 rc->ptr = RC_BUFFER; 57 rc->buffer_end = RC_BUFFER + buffer_size;58 58 } 59 59 … … 66 66 rc->code = (rc->code << 8) | *rc->ptr++; 67 67 } 68 static ALWAYS_INLINE void rc_normalize(rc_t *rc) 69 { 70 if (rc->range < (1 << RC_TOP_BITS)) { 71 rc_do_normalize(rc); 72 } 73 } 68 74 69 75 /* Called once */ … … 79 85 80 86 for (i = 0; i < 5; i++) { 81 #if ENABLE_FEATURE_LZMA_FAST82 if (rc->ptr >= rc->buffer_end)83 rc_read(rc);84 rc->code = (rc->code << 8) | *rc->ptr++;85 #else86 87 rc_do_normalize(rc); 87 #endif 88 } 89 rc->range = 0xFFFFFFFF; 88 } 89 rc->range = 0xffffffff; 90 90 return rc; 91 91 } … … 95 95 { 96 96 free(rc); 97 }98 99 static ALWAYS_INLINE void rc_normalize(rc_t *rc)100 {101 if (rc->range < (1 << RC_TOP_BITS)) {102 rc_do_normalize(rc);103 }104 97 } 105 98 … … 121 114 122 115 /* Called 4 times in unlzma loop */ 123 static speed_inlineint rc_get_bit(rc_t *rc, uint16_t *p, int *symbol)116 static ALWAYS_INLINE int rc_get_bit(rc_t *rc, uint16_t *p, int *symbol) 124 117 { 125 118 int ret = rc_is_bit_1(rc, p); … … 214 207 215 208 IF_DESKTOP(long long) int FAST_FUNC 216 unpack_lzma_stream(transformer_ aux_data_t *aux UNUSED_PARAM, int src_fd, int dst_fd)209 unpack_lzma_stream(transformer_state_t *xstate) 217 210 { 218 211 IF_DESKTOP(long long total_written = 0;) … … 222 215 uint32_t literal_pos_mask; 223 216 uint16_t *p; 224 int num_bits;225 int num_probs;226 217 rc_t *rc; 227 218 int i; … … 233 224 uint32_t rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1; 234 225 235 if (full_read( src_fd, &header, sizeof(header)) != sizeof(header)226 if (full_read(xstate->src_fd, &header, sizeof(header)) != sizeof(header) 236 227 || header.pos >= (9 * 5 * 5) 237 228 ) { … … 247 238 literal_pos_mask = (1 << lp) - 1; 248 239 240 /* Example values from linux-3.3.4.tar.lzma: 241 * dict_size: 64M, dst_size: 2^64-1 242 */ 249 243 header.dict_size = SWAP_LE32(header.dict_size); 250 244 header.dst_size = SWAP_LE64(header.dst_size); … … 255 249 buffer = xmalloc(MIN(header.dst_size, header.dict_size)); 256 250 257 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)); 258 p = xmalloc(num_probs * sizeof(*p)); 259 num_probs += LZMA_LITERAL - LZMA_BASE_SIZE; 260 for (i = 0; i < num_probs; i++) 261 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1; 262 263 rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */ 251 { 252 int num_probs; 253 254 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)); 255 p = xmalloc(num_probs * sizeof(*p)); 256 num_probs += LZMA_LITERAL - LZMA_BASE_SIZE; 257 for (i = 0; i < num_probs; i++) 258 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1; 259 } 260 261 rc = rc_init(xstate->src_fd); /*, RC_BUFFER_SIZE); */ 264 262 265 263 while (global_pos + buffer_pos < header.dst_size) { … … 309 307 buffer_pos = 0; 310 308 global_pos += header.dict_size; 311 if ( full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)309 if (transformer_write(xstate, buffer, header.dict_size) != (ssize_t)header.dict_size) 312 310 goto bad; 313 311 IF_DESKTOP(total_written += header.dict_size;) … … 318 316 #endif 319 317 } else { 318 int num_bits; 320 319 int offset; 321 320 uint16_t *prob2; … … 442 441 buffer_pos = 0; 443 442 global_pos += header.dict_size; 444 if ( full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)443 if (transformer_write(xstate, buffer, header.dict_size) != (ssize_t)header.dict_size) 445 444 goto bad; 446 445 IF_DESKTOP(total_written += header.dict_size;) … … 448 447 len--; 449 448 } while (len != 0 && buffer_pos < header.dst_size); 449 /* FIXME: ...........^^^^^ 450 * shouldn't it be "global_pos + buffer_pos < header.dst_size"? 451 */ 450 452 } 451 453 } … … 454 456 IF_NOT_DESKTOP(int total_written = 0; /* success */) 455 457 IF_DESKTOP(total_written += buffer_pos;) 456 if ( full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {458 if (transformer_write(xstate, buffer, buffer_pos) != (ssize_t)buffer_pos) { 457 459 bad: 458 460 total_written = -1; /* failure */
Note:
See TracChangeset
for help on using the changeset viewer.