003 File Manager
Current Path:
/usr/src/contrib/xz/src/liblzma/common
usr
/
src
/
contrib
/
xz
/
src
/
liblzma
/
common
/
📁
..
📄
alone_decoder.c
(5.53 KB)
📄
alone_decoder.h
(601 B)
📄
alone_encoder.c
(3.66 KB)
📄
auto_decoder.c
(4.79 KB)
📄
block_buffer_decoder.c
(2.31 KB)
📄
block_buffer_encoder.c
(9.89 KB)
📄
block_buffer_encoder.h
(763 B)
📄
block_decoder.c
(6.82 KB)
📄
block_decoder.h
(576 B)
📄
block_encoder.c
(5.63 KB)
📄
block_encoder.h
(1.85 KB)
📄
block_header_decoder.c
(3.62 KB)
📄
block_header_encoder.c
(3.27 KB)
📄
block_util.c
(2.58 KB)
📄
common.c
(10.4 KB)
📄
common.h
(10.22 KB)
📄
easy_buffer_encoder.c
(840 B)
📄
easy_decoder_memusage.c
(668 B)
📄
easy_encoder.c
(678 B)
📄
easy_encoder_memusage.c
(654 B)
📄
easy_preset.c
(727 B)
📄
easy_preset.h
(921 B)
📄
filter_buffer_decoder.c
(2.45 KB)
📄
filter_buffer_encoder.c
(1.5 KB)
📄
filter_common.c
(8.5 KB)
📄
filter_common.h
(1.23 KB)
📄
filter_decoder.c
(4.32 KB)
📄
filter_decoder.h
(617 B)
📄
filter_encoder.c
(7.17 KB)
📄
filter_encoder.h
(732 B)
📄
filter_flags_decoder.c
(1.16 KB)
📄
filter_flags_encoder.c
(1.37 KB)
📄
hardware_cputhreads.c
(526 B)
📄
hardware_physmem.c
(683 B)
📄
index.c
(34.61 KB)
📄
index.h
(1.93 KB)
📄
index_decoder.c
(8.4 KB)
📄
index_encoder.c
(5.72 KB)
📄
index_encoder.h
(584 B)
📄
index_hash.c
(8.77 KB)
📄
memcmplen.h
(4.71 KB)
📄
outqueue.c
(4.48 KB)
📄
outqueue.h
(4.88 KB)
📄
stream_buffer_decoder.c
(2.72 KB)
📄
stream_buffer_encoder.c
(3.96 KB)
📄
stream_decoder.c
(12.7 KB)
📄
stream_decoder.h
(599 B)
📄
stream_encoder.c
(9.63 KB)
📄
stream_encoder_mt.c
(29.64 KB)
📄
stream_flags_common.c
(1.29 KB)
📄
stream_flags_common.h
(883 B)
📄
stream_flags_decoder.c
(2.23 KB)
📄
stream_flags_encoder.c
(2.01 KB)
📄
vli_decoder.c
(2.5 KB)
📄
vli_encoder.c
(1.89 KB)
📄
vli_size.c
(630 B)
Editing: outqueue.c
/////////////////////////////////////////////////////////////////////////////// // /// \file outqueue.c /// \brief Output queue handling in multithreaded coding // // Author: Lasse Collin // // This file has been put into the public domain. // You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// #include "outqueue.h" /// This is to ease integer overflow checking: We may allocate up to /// 2 * LZMA_THREADS_MAX buffers and we need some extra memory for other /// data structures (that's the second /2). #define BUF_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX / 2 / 2) static lzma_ret get_options(uint64_t *bufs_alloc_size, uint32_t *bufs_count, uint64_t buf_size_max, uint32_t threads) { if (threads > LZMA_THREADS_MAX || buf_size_max > BUF_SIZE_MAX) return LZMA_OPTIONS_ERROR; // The number of buffers is twice the number of threads. // This wastes RAM but keeps the threads busy when buffers // finish out of order. // // NOTE: If this is changed, update BUF_SIZE_MAX too. *bufs_count = threads * 2; *bufs_alloc_size = *bufs_count * buf_size_max; return LZMA_OK; } extern uint64_t lzma_outq_memusage(uint64_t buf_size_max, uint32_t threads) { uint64_t bufs_alloc_size; uint32_t bufs_count; if (get_options(&bufs_alloc_size, &bufs_count, buf_size_max, threads) != LZMA_OK) return UINT64_MAX; return sizeof(lzma_outq) + bufs_count * sizeof(lzma_outbuf) + bufs_alloc_size; } extern lzma_ret lzma_outq_init(lzma_outq *outq, const lzma_allocator *allocator, uint64_t buf_size_max, uint32_t threads) { uint64_t bufs_alloc_size; uint32_t bufs_count; // Set bufs_count and bufs_alloc_size. return_if_error(get_options(&bufs_alloc_size, &bufs_count, buf_size_max, threads)); // Allocate memory if needed. if (outq->buf_size_max != buf_size_max || outq->bufs_allocated != bufs_count) { lzma_outq_end(outq, allocator); #if SIZE_MAX < UINT64_MAX if (bufs_alloc_size > SIZE_MAX) return LZMA_MEM_ERROR; #endif outq->bufs = lzma_alloc(bufs_count * sizeof(lzma_outbuf), allocator); outq->bufs_mem = lzma_alloc((size_t)(bufs_alloc_size), allocator); if (outq->bufs == NULL || outq->bufs_mem == NULL) { lzma_outq_end(outq, allocator); return LZMA_MEM_ERROR; } } // Initialize the rest of the main structure. Initialization of // outq->bufs[] is done when they are actually needed. outq->buf_size_max = (size_t)(buf_size_max); outq->bufs_allocated = bufs_count; outq->bufs_pos = 0; outq->bufs_used = 0; outq->read_pos = 0; return LZMA_OK; } extern void lzma_outq_end(lzma_outq *outq, const lzma_allocator *allocator) { lzma_free(outq->bufs, allocator); outq->bufs = NULL; lzma_free(outq->bufs_mem, allocator); outq->bufs_mem = NULL; return; } extern lzma_outbuf * lzma_outq_get_buf(lzma_outq *outq) { // Caller must have checked it with lzma_outq_has_buf(). assert(outq->bufs_used < outq->bufs_allocated); // Initialize the new buffer. lzma_outbuf *buf = &outq->bufs[outq->bufs_pos]; buf->buf = outq->bufs_mem + outq->bufs_pos * outq->buf_size_max; buf->size = 0; buf->finished = false; // Update the queue state. if (++outq->bufs_pos == outq->bufs_allocated) outq->bufs_pos = 0; ++outq->bufs_used; return buf; } extern bool lzma_outq_is_readable(const lzma_outq *outq) { uint32_t i = outq->bufs_pos - outq->bufs_used; if (outq->bufs_pos < outq->bufs_used) i += outq->bufs_allocated; return outq->bufs[i].finished; } extern lzma_ret lzma_outq_read(lzma_outq *restrict outq, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_vli *restrict unpadded_size, lzma_vli *restrict uncompressed_size) { // There must be at least one buffer from which to read. if (outq->bufs_used == 0) return LZMA_OK; // Get the buffer. uint32_t i = outq->bufs_pos - outq->bufs_used; if (outq->bufs_pos < outq->bufs_used) i += outq->bufs_allocated; lzma_outbuf *buf = &outq->bufs[i]; // If it isn't finished yet, we cannot read from it. if (!buf->finished) return LZMA_OK; // Copy from the buffer to output. lzma_bufcpy(buf->buf, &outq->read_pos, buf->size, out, out_pos, out_size); // Return if we didn't get all the data from the buffer. if (outq->read_pos < buf->size) return LZMA_OK; // The buffer was finished. Tell the caller its size information. *unpadded_size = buf->unpadded_size; *uncompressed_size = buf->uncompressed_size; // Free this buffer for further use. --outq->bufs_used; outq->read_pos = 0; return LZMA_STREAM_END; }
Upload File
Create Folder