Rizin
unix-like reverse engineering framework and cli tools
outqueue.h
Go to the documentation of this file.
1 //
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
10 //
12 
13 #include "common.h"
14 
15 
17 typedef struct {
20 
22  size_t size;
23 
27 
32  bool finished;
33 
34 } lzma_outbuf;
35 
36 
37 typedef struct {
40 
43 
45  size_t buf_size_max;
46 
49 
53 
56 
58  size_t read_pos;
59 
60 } lzma_outq;
61 
62 
69 
70 
91  lzma_outq *outq, const lzma_allocator *allocator,
92  uint64_t buf_size_max, uint32_t threads);
93 
94 
96 extern void lzma_outq_end(lzma_outq *outq, const lzma_allocator *allocator);
97 
98 
105 
106 
112 extern bool lzma_outq_is_readable(const lzma_outq *outq);
113 
114 
135  uint8_t *restrict out, size_t *restrict out_pos,
136  size_t out_size, lzma_vli *restrict unpadded_size,
138 
139 
144 static inline bool
146 {
147  return outq->bufs_used < outq->bufs_allocated;
148 }
149 
150 
152 static inline bool
154 {
155  return outq->bufs_used == 0;
156 }
const lzma_allocator lzma_vli unpadded_size
Definition: index.h:345
const lzma_allocator const uint8_t size_t uint8_t size_t * out_pos
Definition: block.h:528
const lzma_allocator * allocator
Definition: block.h:377
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
#define restrict
lzma_outbuf * lzma_outq_get_buf(lzma_outq *outq)
Get a new buffer.
Definition: outqueue.c:114
static bool lzma_outq_has_buf(const lzma_outq *outq)
Test if there is at least one buffer free.
Definition: outqueue.h:145
void lzma_outq_end(lzma_outq *outq, const lzma_allocator *allocator)
Free the memory associated with the output queue.
Definition: outqueue.c:101
bool lzma_outq_is_readable(const lzma_outq *outq)
Test if there is data ready to be read.
Definition: outqueue.c:136
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)
Read finished data.
Definition: outqueue.c:147
uint64_t lzma_outq_memusage(uint64_t buf_size_max, uint32_t threads)
Calculate the memory usage of an output queue.
Definition: outqueue.c:42
lzma_ret lzma_outq_init(lzma_outq *outq, const lzma_allocator *allocator, uint64_t buf_size_max, uint32_t threads)
Initialize an output queue.
Definition: outqueue.c:57
static bool lzma_outq_is_empty(const lzma_outq *outq)
Test if the queue is completely empty.
Definition: outqueue.h:153
unsigned int uint32_t
Definition: sftypes.h:29
unsigned long uint64_t
Definition: sftypes.h:28
unsigned char uint8_t
Definition: sftypes.h:31
Custom functions for memory handling.
Definition: base.h:372
Output buffer for a single thread.
Definition: outqueue.h:17
bool finished
Definition: outqueue.h:32
size_t size
Amount of data written to buf.
Definition: outqueue.h:22
lzma_vli uncompressed_size
Definition: outqueue.h:26
uint8_t * buf
Pointer to the output buffer of lzma_outq.buf_size_max bytes.
Definition: outqueue.h:19
lzma_vli unpadded_size
Additional size information.
Definition: outqueue.h:25
lzma_outbuf * bufs
Array of buffers that are used cyclically.
Definition: outqueue.h:39
size_t buf_size_max
Amount of buffer space available in each buffer.
Definition: outqueue.h:45
uint32_t bufs_allocated
Number of buffers allocated.
Definition: outqueue.h:48
uint32_t bufs_pos
Definition: outqueue.h:52
size_t read_pos
Position in the buffer in lzma_outq_read()
Definition: outqueue.h:58
uint32_t bufs_used
Number of buffers in use.
Definition: outqueue.h:55
uint8_t * bufs_mem
Memory allocated for all the buffers.
Definition: outqueue.h:42
Definitions common to the whole liblzma library.
uint64_t uncompressed_size
Definition: list.c:106
static uv_thread_t * threads
Definition: threadpool.c:38
uint64_t lzma_vli
Variable-length integer type.
Definition: vli.h:63
lzma_ret
Return values used by several functions in liblzma.
Definition: base.h:57