Rizin
unix-like reverse engineering framework and cli tools
|
Definitions common to the whole liblzma library. More...
Go to the source code of this file.
Classes | |
struct | lzma_filter_info_s |
struct | lzma_next_coder_s |
Hold data and function pointers of the next filter in the chain. More... | |
struct | lzma_internal_s |
Macros | |
#define | LZMA_API_EXPORT |
#define | LZMA_API(type) LZMA_API_EXPORT type LZMA_API_CALL |
#define | likely(expr) (expr) |
#define | unlikely(expr) (expr) |
#define | LZMA_BUFFER_SIZE 4096 |
Size of temporary buffers needed in some filters. More... | |
#define | LZMA_THREADS_MAX 16384 |
#define | LZMA_MEMUSAGE_BASE (UINT64_C(1) << 15) |
#define | LZMA_FILTER_RESERVED_START (LZMA_VLI_C(1) << 62) |
#define | LZMA_SUPPORTED_FLAGS |
#define | LZMA_ACTION_MAX ((unsigned int)(LZMA_FULL_BARRIER)) |
Largest valid lzma_action value as unsigned integer. More... | |
#define | LZMA_TIMED_OUT 32 |
#define | LZMA_NEXT_CODER_INIT |
Macro to initialize lzma_next_coder structure. More... | |
#define | return_if_error(expr) |
Return if expression doesn't evaluate to LZMA_OK. More... | |
#define | lzma_next_coder_init(func, next, allocator) |
#define | lzma_next_strm_init(func, strm, ...) |
Typedefs | |
typedef struct lzma_next_coder_s | lzma_next_coder |
typedef struct lzma_filter_info_s | lzma_filter_info |
typedef lzma_ret(* | lzma_init_function) (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters) |
Type of a function used to initialize a filter encoder or decoder. More... | |
typedef lzma_ret(* | lzma_code_function) (void *coder, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_action action) |
typedef void(* | lzma_end_function) (void *coder, const lzma_allocator *allocator) |
Type of a function to free the memory allocated for the coder. More... | |
Functions | |
void * | lzma_alloc (size_t size, const lzma_allocator *allocator) lzma_attribute((__malloc__)) lzma_attr_alloc_size(1) |
Allocates memory. More... | |
void * | lzma_attribute ((__malloc__)) lzma_attr_alloc_size(1) lzma_alloc_zero(size_t size |
void | lzma_free (void *ptr, const lzma_allocator *allocator) |
Frees memory. More... | |
lzma_ret | lzma_strm_init (lzma_stream *strm) |
lzma_ret | lzma_next_filter_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters) |
lzma_ret | lzma_next_filter_update (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter *reversed_filters) |
void | lzma_next_end (lzma_next_coder *next, const lzma_allocator *allocator) |
size_t | lzma_bufcpy (const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size) |
Variables | |
void const lzma_allocator * | allocator |
Definitions common to the whole liblzma library.
Definition in file common.h.
#define LZMA_ACTION_MAX ((unsigned int)(LZMA_FULL_BARRIER)) |
#define LZMA_API | ( | type | ) | LZMA_API_EXPORT type LZMA_API_CALL |
#define LZMA_BUFFER_SIZE 4096 |
#define LZMA_FILTER_RESERVED_START (LZMA_VLI_C(1) << 62) |
#define LZMA_MEMUSAGE_BASE (UINT64_C(1) << 15) |
#define LZMA_NEXT_CODER_INIT |
Macro to initialize lzma_next_coder structure.
#define lzma_next_coder_init | ( | func, | |
next, | |||
allocator | |||
) |
If next isn't already initialized, free the previous coder. Then mark that next is possibly initialized for the coder using this macro. "Possibly" means that if e.g. allocation of next->coder fails, the structure isn't actually initialized for this coder, but leaving next->init to func is still OK.
#define lzma_next_strm_init | ( | func, | |
strm, | |||
... | |||
) |
Initializes lzma_strm and calls func() to initialize strm->internal->next. (The function being called will use lzma_next_coder_init()). If initialization fails, memory that wasn't freed by func() is freed along strm->internal.
#define LZMA_SUPPORTED_FLAGS |
Supported flags that can be passed to lzma_stream_decoder() or lzma_auto_decoder().
#define LZMA_THREADS_MAX 16384 |
Maximum number of worker threads within one multithreaded component. The limit exists solely to make it simpler to prevent integer overflows when allocating structures etc. This should be big enough for now... the code won't scale anywhere close to this number anyway.
#define LZMA_TIMED_OUT 32 |
#define return_if_error | ( | expr | ) |
Return if expression doesn't evaluate to LZMA_OK.
There are several situations where we want to return immediately with the value of expr if it isn't LZMA_OK. This macro shortens the code a little.
typedef void(* lzma_end_function) (void *coder, const lzma_allocator *allocator) |
typedef struct lzma_filter_info_s lzma_filter_info |
typedef lzma_ret(* lzma_init_function) (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters) |
typedef struct lzma_next_coder_s lzma_next_coder |
void* lzma_alloc | ( | size_t | size, |
const lzma_allocator * | allocator | ||
) |
Allocates memory.
Referenced by alone_encoder_init(), auto_decoder_init(), index_decoder_init(), index_dup_stream(), index_init_plain(), index_stream_init(), initialize_new_thread(), lz_encoder_init(), lzma2_decoder_init(), lzma2_encoder_init(), lzma_alone_decoder_init(), LZMA_API(), lzma_block_decoder_init(), lzma_block_encoder_init(), lzma_delta_coder_init(), lzma_delta_props_decode(), lzma_index_encoder_init(), lzma_lz_decoder_init(), lzma_lz_encoder_init(), lzma_lzma_decoder_create(), lzma_lzma_encoder_create(), lzma_lzma_props_decode(), lzma_outq_init(), lzma_simple_coder_init(), lzma_simple_props_decode(), lzma_stream_decoder_init(), lzma_strm_init(), stream_encoder_init(), and stream_encoder_mt_init().
void* lzma_attribute | ( | (__malloc__) | ) |
Allocates memory and zeroes it (like calloc()). This can be faster than lzma_alloc() + memzero() while being backward compatible with custom allocators.
size_t lzma_bufcpy | ( | const uint8_t *restrict | in, |
size_t *restrict | in_pos, | ||
size_t | in_size, | ||
uint8_t *restrict | out, | ||
size_t *restrict | out_pos, | ||
size_t | out_size | ||
) |
Copy as much data as possible from in[] to out[] and update *in_pos and *out_pos accordingly. Returns the number of bytes copied.
Definition at line 94 of file common.c.
References in, in_pos, in_size, memcpy(), my_min, out, and out_pos.
Referenced by alone_encode(), block_decode(), block_encode(), copy_or_code(), dict_write(), fill_window(), lzma2_encode(), lzma_outq_read(), simple_code(), stream_decode(), stream_encode(), stream_encode_in(), and stream_encode_mt().
void lzma_free | ( | void * | ptr, |
const lzma_allocator * | allocator | ||
) |
Frees memory.
Definition at line 78 of file common.c.
References allocator, free(), NULL, and lzma_allocator::opaque.
Referenced by alone_decoder_end(), alone_encoder_end(), auto_decoder_end(), block_decoder_end(), block_encoder_end(), delta_coder_end(), free_properties(), index_decoder_end(), index_encoder_end(), index_stream_end(), initialize_new_thread(), lz_decoder_end(), lz_encoder_end(), lz_encoder_init(), lz_encoder_prepare(), lzma2_decoder_end(), lzma2_encoder_end(), LZMA_API(), lzma_lz_decoder_init(), lzma_lzma_props_decode(), lzma_next_end(), lzma_outq_end(), lzma_simple_props_decode(), simple_coder_end(), stream_decode(), stream_decoder_end(), stream_encoder_end(), stream_encoder_mt_end(), stream_encoder_mt_init(), stream_encoder_update(), threads_end(), and worker_start().
void lzma_next_end | ( | lzma_next_coder * | next, |
const lzma_allocator * | allocator | ||
) |
Frees the memory allocated for next->coder either using next->end or, if next->end is NULL, using lzma_free.
Definition at line 145 of file common.c.
References allocator, lzma_next_coder_s::coder, lzma_next_coder_s::end, lzma_next_coder_s::init, lzma_free(), LZMA_NEXT_CODER_INIT, and NULL.
Referenced by alone_decoder_end(), alone_encoder_end(), auto_decoder_end(), block_decoder_end(), block_encode_normal(), block_encoder_end(), delta_coder_end(), lz_decoder_end(), lz_encoder_end(), LZMA_API(), lzma_raw_coder_init(), simple_coder_end(), stream_decoder_end(), stream_encoder_end(), stream_encoder_mt_end(), and worker_start().
lzma_ret lzma_next_filter_init | ( | lzma_next_coder * | next, |
const lzma_allocator * | allocator, | ||
const lzma_filter_info * | filters | ||
) |
Initializes the next filter in the chain, if any. This takes care of freeing the memory of previously initialized filter if it is different than the filter being initialized now. This way the actual filter initialization functions don't need to use lzma_next_coder_init macro.
Definition at line 116 of file common.c.
References allocator, filters, lzma_filter::id, lzma_next_coder_s::id, init, lzma_next_coder_init, LZMA_OK, and NULL.
Referenced by alone_decode(), alone_encoder_init(), lzma_delta_coder_init(), lzma_lz_decoder_init(), lzma_lz_encoder_init(), lzma_raw_coder_init(), and lzma_simple_coder_init().
lzma_ret lzma_next_filter_update | ( | lzma_next_coder * | next, |
const lzma_allocator * | allocator, | ||
const lzma_filter * | reversed_filters | ||
) |
Update the next filter in the chain, if any. This checks that the application is not trying to change the Filter IDs.
Definition at line 127 of file common.c.
References allocator, assert(), lzma_next_coder_s::coder, lzma_next_coder_s::id, LZMA_OK, LZMA_PROG_ERROR, LZMA_VLI_UNKNOWN, NULL, and lzma_next_coder_s::update.
Referenced by block_encoder_update(), delta_encoder_update(), lz_encoder_update(), and simple_coder_update().
lzma_ret lzma_strm_init | ( | lzma_stream * | strm | ) |
Allocates strm->internal if it is NULL, and initializes *strm and strm->internal. This function is only called via lzma_next_strm_init macro.
Definition at line 170 of file common.c.
References lzma_stream::allocator, lzma_internal_s::allow_buf_error, lzma_stream::internal, lzma_alloc(), LZMA_MEM_ERROR, LZMA_NEXT_CODER_INIT, LZMA_OK, LZMA_PROG_ERROR, memzero, lzma_internal_s::next, NULL, lzma_internal_s::sequence, strm, lzma_internal_s::supported_actions, lzma_stream::total_in, and lzma_stream::total_out.
void const lzma_allocator* allocator |