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

Handling of Index. More...

#include "common.h"

Go to the source code of this file.

Macros

#define UNPADDED_SIZE_MIN   LZMA_VLI_C(5)
 Minimum Unpadded Size. More...
 
#define UNPADDED_SIZE_MAX   (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
 Maximum Unpadded Size. More...
 

Functions

uint32_t lzma_index_padding_size (const lzma_index *i)
 
void lzma_index_prealloc (lzma_index *i, lzma_vli records)
 
static lzma_vli vli_ceil4 (lzma_vli vli)
 Round the variable-length integer to the next multiple of four. More...
 
static lzma_vli index_size_unpadded (lzma_vli count, lzma_vli index_list_size)
 Calculate the size of the Index field excluding Index Padding. More...
 
static lzma_vli index_size (lzma_vli count, lzma_vli index_list_size)
 Calculate the size of the Index field including Index Padding. More...
 
static lzma_vli index_stream_size (lzma_vli blocks_size, lzma_vli count, lzma_vli index_list_size)
 Calculate the total size of the Stream. More...
 

Detailed Description

Handling of Index.

Definition in file index.h.

Macro Definition Documentation

◆ UNPADDED_SIZE_MAX

#define UNPADDED_SIZE_MAX   (LZMA_VLI_MAX & ~LZMA_VLI_C(3))

Maximum Unpadded Size.

Definition at line 23 of file index.h.

◆ UNPADDED_SIZE_MIN

#define UNPADDED_SIZE_MIN   LZMA_VLI_C(5)

Minimum Unpadded Size.

Definition at line 20 of file index.h.

Function Documentation

◆ index_size()

static lzma_vli index_size ( lzma_vli  count,
lzma_vli  index_list_size 
)
inlinestatic

Calculate the size of the Index field including Index Padding.

Definition at line 57 of file index.h.

58 {
59  return vli_ceil4(index_size_unpadded(count, index_list_size));
60 }
static lzma_vli vli_ceil4(lzma_vli vli)
Round the variable-length integer to the next multiple of four.
Definition: index.h:39
static lzma_vli index_size_unpadded(lzma_vli count, lzma_vli index_list_size)
Calculate the size of the Index field excluding Index Padding.
Definition: index.h:48
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98

References count, index_size_unpadded(), and vli_ceil4().

Referenced by index_file_size(), index_stream_size(), iter_set_info(), LZMA_API(), parse_indexes(), read_image_metadata_tilde_header(), and test_code().

◆ index_size_unpadded()

static lzma_vli index_size_unpadded ( lzma_vli  count,
lzma_vli  index_list_size 
)
inlinestatic

Calculate the size of the Index field excluding Index Padding.

Definition at line 48 of file index.h.

49 {
50  // Index Indicator + Number of Records + List of Records + CRC32
51  return 1 + lzma_vli_size(count) + index_list_size + 4;
52 }

References count.

Referenced by index_size(), and lzma_index_padding_size().

◆ index_stream_size()

static lzma_vli index_stream_size ( lzma_vli  blocks_size,
lzma_vli  count,
lzma_vli  index_list_size 
)
inlinestatic

Calculate the total size of the Stream.

Definition at line 65 of file index.h.

67 {
68  return LZMA_STREAM_HEADER_SIZE + blocks_size
69  + index_size(count, index_list_size)
71 }
static lzma_vli index_size(lzma_vli count, lzma_vli index_list_size)
Calculate the size of the Index field including Index Padding.
Definition: index.h:57
#define LZMA_STREAM_HEADER_SIZE
Size of Stream Header and Stream Footer.
Definition: stream_flags.h:27

References count, index_size(), and LZMA_STREAM_HEADER_SIZE.

Referenced by LZMA_API().

◆ lzma_index_padding_size()

uint32_t lzma_index_padding_size ( const lzma_index i)

Get the size of the Index Padding field. This is needed by Index encoder and decoder, but applications should have no use for this.

Definition at line 593 of file index.c.

594 {
595  return (LZMA_VLI_C(4) - index_size_unpadded(
596  i->record_count, i->index_list_size)) & 3;
597 }
lzma_index ** i
Definition: index.h:629
lzma_vli index_list_size
Definition: index.c:166
lzma_vli record_count
Total number of Records in all Streams in this lzma_index.
Definition: index.c:158
#define LZMA_VLI_C(n)
VLI constant suffix.
Definition: vli.h:49

References i, lzma_index_s::index_list_size, index_size_unpadded(), LZMA_VLI_C, and lzma_index_s::record_count.

Referenced by index_decode(), and index_encode().

◆ lzma_index_prealloc()

void lzma_index_prealloc ( lzma_index i,
lzma_vli  records 
)

Set for how many Records to allocate memory the next time lzma_index_append() needs to allocate space for a new Record. This is used only by the Index decoder.

Definition at line 431 of file index.c.

432 {
433  if (records > PREALLOC_MAX)
434  records = PREALLOC_MAX;
435 
436  i->prealloc = (size_t)(records);
437  return;
438 }
#define PREALLOC_MAX
How many Records can be allocated at once at maximum.
Definition: index.c:25
int size_t
Definition: sftypes.h:40
size_t prealloc
Definition: index.c:171

References i, lzma_index_s::prealloc, and PREALLOC_MAX.

Referenced by index_decode().

◆ vli_ceil4()

static lzma_vli vli_ceil4 ( lzma_vli  vli)
inlinestatic

Round the variable-length integer to the next multiple of four.

Definition at line 39 of file index.h.

40 {
41  assert(vli <= LZMA_VLI_MAX);
42  return (vli + 3) & ~LZMA_VLI_C(3);
43 }
assert(limit<=UINT32_MAX/2)
#define LZMA_VLI_MAX
Maximum supported value of a variable-length integer.
Definition: vli.h:34

References assert(), LZMA_VLI_C, and LZMA_VLI_MAX.

Referenced by hash_append(), index_file_size(), index_size(), iter_set_info(), and LZMA_API().