Rizin
unix-like reverse engineering framework and cli tools
delta_private.h File Reference

Private common stuff for Delta encoder and decoder. More...

#include "delta_common.h"

Go to the source code of this file.

Classes

struct  lzma_delta_coder
 

Functions

lzma_ret lzma_delta_coder_init (lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters)
 

Detailed Description

Private common stuff for Delta encoder and decoder.

Definition in file delta_private.h.

Function Documentation

◆ lzma_delta_coder_init()

lzma_ret lzma_delta_coder_init ( lzma_next_coder next,
const lzma_allocator allocator,
const lzma_filter_info filters 
)

Definition at line 28 of file delta_common.c.

30 {
31  // Allocate memory for the decoder if needed.
32  lzma_delta_coder *coder = next->coder;
33  if (coder == NULL) {
34  coder = lzma_alloc(sizeof(lzma_delta_coder), allocator);
35  if (coder == NULL)
36  return LZMA_MEM_ERROR;
37 
38  next->coder = coder;
39 
40  // End function is the same for encoder and decoder.
41  next->end = &delta_coder_end;
42  coder->next = LZMA_NEXT_CODER_INIT;
43  }
44 
45  // Validate the options.
47  return LZMA_OPTIONS_ERROR;
48 
49  // Set the delta distance.
50  const lzma_options_delta *opt = filters[0].options;
51  coder->distance = opt->dist;
52 
53  // Initialize the rest of the variables.
54  coder->pos = 0;
56 
57  // Initialize the next decoder in the chain, if any.
58  return lzma_next_filter_init(&coder->next, allocator, filters + 1);
59 }
const lzma_allocator * allocator
Definition: block.h:377
const lzma_filter * filters
Definition: container.h:315
#define NULL
Definition: cris-opc.c:27
#define LZMA_DELTA_DIST_MAX
Definition: delta.h:61
static void delta_coder_end(void *coder_ptr, const lzma_allocator *allocator)
Definition: delta_common.c:18
uint64_t lzma_delta_coder_memusage(const void *options)
Definition: delta_common.c:63
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
#define UINT64_MAX
lzma_next_coder next
Next coder in the chain.
Definition: delta_private.h:20
uint8_t pos
Position in history[].
Definition: delta_private.h:26
uint8_t history[LZMA_DELTA_DIST_MAX]
Buffer to hold history of the original data.
Definition: delta_private.h:29
size_t distance
Delta distance.
Definition: delta_private.h:23
void * options
Pointer to filter-specific options structure.
Definition: filter.h:63
void * coder
Pointer to coder-specific data.
Definition: common.h:137
lzma_end_function end
Definition: common.h:155
Options for the Delta filter.
Definition: delta.h:45
uint32_t dist
Delta distance.
Definition: delta.h:59
#define LZMA_NEXT_CODER_INIT
Macro to initialize lzma_next_coder structure.
Definition: common.h:180
void * lzma_alloc(size_t size, const lzma_allocator *allocator) lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
Allocates memory.
#define memzero(s, n)
Definition: sysdefs.h:180
@ LZMA_MEM_ERROR
Cannot allocate memory.
Definition: base.h:128
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
Definition: base.h:160
lzma_ret lzma_next_filter_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter_info *filters)
Definition: common.c:116

References allocator, lzma_next_coder_s::coder, delta_coder_end(), lzma_options_delta::dist, lzma_delta_coder::distance, lzma_next_coder_s::end, filters, lzma_delta_coder::history, lzma_alloc(), lzma_delta_coder_memusage(), LZMA_DELTA_DIST_MAX, LZMA_MEM_ERROR, LZMA_NEXT_CODER_INIT, lzma_next_filter_init(), LZMA_OPTIONS_ERROR, memzero, lzma_delta_coder::next, NULL, options, lzma_filter::options, lzma_delta_coder::pos, and UINT64_MAX.

Referenced by lzma_delta_decoder_init(), and lzma_delta_encoder_init().