Rizin
unix-like reverse engineering framework and cli tools
rz_vector.h File Reference
#include <rz_types.h>
#include <rz_util/rz_assert.h>

Go to the source code of this file.

Classes

struct  rz_vector_t
 
struct  rz_pvector_t
 

Macros

#define rz_vector_foreach(vec, it)
 
#define rz_vector_foreach_prev(vec, it)
 
#define rz_vector_enumerate(vec, it, i)
 
#define rz_vector_lower_bound(vec, x, i, cmp)
 
#define rz_vector_upper_bound(vec, x, i, cmp)
 
#define rz_pvector_foreach(vec, it)    for (it = (void **)(vec)->v.a; (vec)->v.len && it != (void **)(vec)->v.a + (vec)->v.len; it++)
 
#define rz_pvector_foreach_prev(vec, it)    for (it = ((vec)->v.len == 0 ? NULL : (void **)(vec)->v.a + (vec)->v.len - 1); it && it != (void **)(vec)->v.a - 1; it--)
 
#define rz_array_lower_bound(array, len, x, i, cmp)
 
#define rz_array_upper_bound(array, len, x, i, cmp)
 
#define rz_array_find(array, x, itr, start, stop, cmp)
 Find an element elem in the array, lying within start and stop index such that cmp(x, elem) == 0 The index of the element elem is stored in itr If itr == stop, then no such element was found. More...
 
#define rz_pvector_lower_bound(vec, x, i, cmp)    rz_array_lower_bound((void **)(vec)->v.a, (vec)->v.len, x, i, cmp)
 
#define rz_pvector_upper_bound(vec, x, i, cmp)    rz_array_upper_bound((void **)(vec)->v.a, (vec)->v.len, x, i, cmp)
 

Typedefs

typedef int(* RzPVectorComparator) (const void *a, const void *b)
 
typedef int(* RzVectorComparator) (const void *a, const void *b)
 
typedef void(* RzVectorFree) (void *e, void *user)
 
typedef void(* RzPVectorFree) (void *e)
 
typedef struct rz_vector_t RzVector
 
typedef struct rz_pvector_t RzPVector
 

Functions

RZ_API void rz_vector_init (RzVector *vec, size_t elem_size, RzVectorFree free, void *free_user)
 
RZ_API RzVectorrz_vector_new (size_t elem_size, RzVectorFree free, void *free_user)
 
RZ_API void rz_vector_fini (RzVector *vec)
 
RZ_API void rz_vector_free (RzVector *vec)
 
RZ_API RzVectorrz_vector_clone (RzVector *vec)
 
static bool rz_vector_empty (const RzVector *vec)
 
RZ_API void rz_vector_clear (RzVector *vec)
 
static size_t rz_vector_len (const RzVector *vec)
 
static void * rz_vector_index_ptr (RzVector *vec, size_t index)
 
static void * rz_vector_head (RzVector *vec)
 
static void * rz_vector_tail (RzVector *vec)
 
RZ_API void rz_vector_assign (RzVector *vec, void *p, void *elem)
 
RZ_API void * rz_vector_assign_at (RzVector *vec, size_t index, void *elem)
 
RZ_API void rz_vector_remove_at (RzVector *vec, size_t index, void *into)
 
RZ_API void rz_vector_remove_range (RzVector *vec, size_t index, size_t count, void *into)
 
RZ_API void * rz_vector_insert (RzVector *vec, size_t index, void *x)
 
RZ_API void * rz_vector_insert_range (RzVector *vec, size_t index, void *first, size_t count)
 
RZ_API void rz_vector_pop (RzVector *vec, void *into)
 
RZ_API void rz_vector_pop_front (RzVector *vec, void *into)
 
RZ_API void * rz_vector_push (RzVector *vec, void *x)
 
RZ_API void * rz_vector_push_front (RzVector *vec, void *x)
 
RZ_API void * rz_vector_reserve (RzVector *vec, size_t capacity)
 
RZ_API void * rz_vector_shrink (RzVector *vec)
 
RZ_API void * rz_vector_flush (RzVector *vec)
 Turn the vector into a fixed-size array. This will clear the vector and return an array of its original contents whose ownership is transferred to the caller. This is useful when RzVector is used for its dynamically growing functionality as an intermediate step to generate a fixed-size array in the end. More...
 
RZ_API void rz_vector_sort (RzVector *vec, RzVectorComparator cmp, bool reverse)
 Sort function for RzVector. More...
 
RZ_API void rz_pvector_init (RzPVector *vec, RzPVectorFree free)
 
RZ_API void rz_pvector_fini (RzPVector *vec)
 
RZ_API RzPVectorrz_pvector_new (RzPVectorFree free)
 
RZ_API RzPVectorrz_pvector_new_with_len (RzPVectorFree free, size_t length)
 
RZ_API void rz_pvector_clear (RzPVector *vec)
 
RZ_API void rz_pvector_free (RzPVector *vec)
 
static size_t rz_pvector_len (const RzPVector *vec)
 
static void * rz_pvector_at (const RzPVector *vec, size_t index)
 
static void rz_pvector_set (RzPVector *vec, size_t index, void *e)
 
static bool rz_pvector_empty (RzPVector *vec)
 
static void ** rz_pvector_index_ptr (RzPVector *vec, size_t index)
 
static void ** rz_pvector_data (RzPVector *vec)
 
static void * rz_pvector_head (RzPVector *vec)
 
static void * rz_pvector_tail (RzPVector *vec)
 
RZ_API void ** rz_pvector_contains (RzPVector *vec, void *x)
 
RZ_API void * rz_pvector_remove_at (RzPVector *vec, size_t index)
 
RZ_API void rz_pvector_remove_data (RzPVector *vec, void *x)
 
static void ** rz_pvector_insert (RzPVector *vec, size_t index, void *x)
 
static void ** rz_pvector_insert_range (RzPVector *vec, size_t index, void **first, size_t count)
 
RZ_API void * rz_pvector_pop (RzPVector *vec)
 
RZ_API void * rz_pvector_pop_front (RzPVector *vec)
 
static void ** rz_pvector_push (RzPVector *vec, void *x)
 
static void ** rz_pvector_push_front (RzPVector *vec, void *x)
 
RZ_API void rz_pvector_sort (RzPVector *vec, RzPVectorComparator cmp)
 
static void ** rz_pvector_reserve (RzPVector *vec, size_t capacity)
 
static void ** rz_pvector_shrink (RzPVector *vec)
 
static void ** rz_pvector_flush (RzPVector *vec)
 

Macro Definition Documentation

◆ rz_array_find

#define rz_array_find (   array,
  x,
  itr,
  start,
  stop,
  cmp 
)
Value:
do { \
for (itr = start; itr < stop; itr++) { \
if (cmp((array[itr]), x) == 0) { \
break; \
} \
} \
return itr; \
} while (0)
static RzILOpEffect * cmp(cs_insn *insn, bool is_thumb)
Definition: arm_il32.c:942
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 static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void start
Definition: sflib.h:133
int x
Definition: mipsasm.c:20

Find an element elem in the array, lying within start and stop index such that cmp(x, elem) == 0 The index of the element elem is stored in itr If itr == stop, then no such element was found.

Definition at line 393 of file rz_vector.h.

◆ rz_array_lower_bound

#define rz_array_lower_bound (   array,
  len,
  x,
  i,
  cmp 
)
Value:
do { \
size_t h = len, m; \
for (i = 0; i < h;) { \
m = i + ((h - i) >> 1); \
if (cmp((x), ((array)[m])) > 0) { \
i = m + 1; \
} else { \
h = m; \
} \
} \
} while (0)
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
#define h(i)
Definition: sha256.c:48

Definition at line 351 of file rz_vector.h.

◆ rz_array_upper_bound

#define rz_array_upper_bound (   array,
  len,
  x,
  i,
  cmp 
)
Value:
do { \
size_t h = len, m; \
for (i = 0; i < h;) { \
m = i + ((h - i) >> 1); \
if (cmp((x), ((array)[m])) < 0) { \
h = m; \
} else { \
i = m + 1; \
} \
} \
} while (0)

Definition at line 374 of file rz_vector.h.

◆ rz_pvector_foreach

#define rz_pvector_foreach (   vec,
  it 
)     for (it = (void **)(vec)->v.a; (vec)->v.len && it != (void **)(vec)->v.a + (vec)->v.len; it++)

Definition at line 334 of file rz_vector.h.

◆ rz_pvector_foreach_prev

#define rz_pvector_foreach_prev (   vec,
  it 
)     for (it = ((vec)->v.len == 0 ? NULL : (void **)(vec)->v.a + (vec)->v.len - 1); it && it != (void **)(vec)->v.a - 1; it--)

Definition at line 338 of file rz_vector.h.

◆ rz_pvector_lower_bound

#define rz_pvector_lower_bound (   vec,
  x,
  i,
  cmp 
)     rz_array_lower_bound((void **)(vec)->v.a, (vec)->v.len, x, i, cmp)

Definition at line 412 of file rz_vector.h.

◆ rz_pvector_upper_bound

#define rz_pvector_upper_bound (   vec,
  x,
  i,
  cmp 
)     rz_array_upper_bound((void **)(vec)->v.a, (vec)->v.len, x, i, cmp)

Definition at line 424 of file rz_vector.h.

◆ rz_vector_enumerate

#define rz_vector_enumerate (   vec,
  it,
  i 
)
Value:
if (!rz_vector_empty(vec)) \
for (it = (void *)(vec)->a, i = 0; i < (vec)->len; it = (void *)((char *)it + (vec)->elem_size), i++)
static bool rz_vector_empty(const RzVector *vec)
Definition: rz_vector.h:74
#define a(i)
Definition: sha256.c:41

Definition at line 177 of file rz_vector.h.

◆ rz_vector_foreach

#define rz_vector_foreach (   vec,
  it 
)
Value:
if (!rz_vector_empty(vec)) \
for (it = (void *)(vec)->a; (char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); it = (void *)((char *)it + (vec)->elem_size))

Definition at line 169 of file rz_vector.h.

◆ rz_vector_foreach_prev

#define rz_vector_foreach_prev (   vec,
  it 
)
Value:
if (!rz_vector_empty(vec)) \
for (it = (void *)((char *)(vec)->a + (((vec)->len - 1) * (vec)->elem_size)); (char *)it != (char *)(vec)->a - (vec)->elem_size; it = (void *)((char *)it - (vec)->elem_size))

Definition at line 173 of file rz_vector.h.

◆ rz_vector_lower_bound

#define rz_vector_lower_bound (   vec,
  x,
  i,
  cmp 
)
Value:
do { \
size_t h = (vec)->len, m; \
for (i = 0; i < h;) { \
m = i + ((h - i) >> 1); \
if ((cmp(x, ((char *)(vec)->a + (vec)->elem_size * m))) > 0) { \
i = m + 1; \
} else { \
h = m; \
} \
} \
} while (0)

Definition at line 190 of file rz_vector.h.

◆ rz_vector_upper_bound

#define rz_vector_upper_bound (   vec,
  x,
  i,
  cmp 
)
Value:
do { \
size_t h = (vec)->len, m; \
for (i = 0; i < h;) { \
m = i + ((h - i) >> 1); \
if ((cmp(x, ((char *)(vec)->a + (vec)->elem_size * m))) < 0) { \
h = m; \
} else { \
i = m + 1; \
} \
} \
} while (0)

Definition at line 203 of file rz_vector.h.

Typedef Documentation

◆ RzPVector

typedef struct rz_pvector_t RzPVector

◆ RzPVectorComparator

typedef int(* RzPVectorComparator) (const void *a, const void *b)

Definition at line 40 of file rz_vector.h.

◆ RzPVectorFree

typedef void(* RzPVectorFree) (void *e)

Definition at line 43 of file rz_vector.h.

◆ RzVector

typedef struct rz_vector_t RzVector

◆ RzVectorComparator

typedef int(* RzVectorComparator) (const void *a, const void *b)

Definition at line 41 of file rz_vector.h.

◆ RzVectorFree

typedef void(* RzVectorFree) (void *e, void *user)

Definition at line 42 of file rz_vector.h.

Function Documentation

◆ rz_pvector_at()

static void* rz_pvector_at ( const RzPVector vec,
size_t  index 
)
inlinestatic

Definition at line 236 of file rz_vector.h.

236  {
237  rz_return_val_if_fail(vec && index < vec->v.len, NULL);
238  return ((void **)vec->v.a)[index];
239 }
#define NULL
Definition: cris-opc.c:27
const char * v
Definition: dsignal.c:12
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RzVector v
Definition: rz_vector.h:56
void * a
Definition: rz_vector.h:46

References rz_vector_t::a, NULL, rz_return_val_if_fail, v, and rz_pvector_t::v.

Referenced by __core_visual_gogo(), analysis_block_cb(), analysis_block_on_exit(), cmp(), cmplen(), core_get_file(), dex_create_relocations(), dex_new_encoded_method(), dex_print_encoded_field(), dex_print_encoded_method(), dex_resolve_all_virtual_methods(), dex_resolve_entrypoints_in_class(), dex_resolve_fields_in_class(), dex_resolve_fields_in_class_as_symbols(), dex_resolve_methods_in_class(), dex_resolve_proto_id(), dex_resolve_string_id_native(), dex_resolve_symbol_in_class_methods(), get_max_common_pfx(), get_relocs(), print_log(), print_new_results(), propagate_return_type(), propagate_types_among_used_variables(), rz_analysis_esil_get_instruction_trace(), rz_analysis_function_delete_vars_by_kind(), rz_analysis_get_used_function_var(), rz_analysis_var_delete(), rz_bin_dex_resolve_field_by_idx(), rz_bin_dex_resolve_method_by_idx(), rz_bin_dex_resolve_method_offset_by_idx(), rz_bin_source_line_info_builder_build_and_fini(), rz_cmd_dexe_handler(), rz_cmd_dexs_handler(), rz_core_file_close(), rz_core_get_boundaries_prot(), rz_il_validate_global_context_new_from_vm(), rz_il_vm_add_mem(), rz_il_vm_get_mem(), rz_io_map_cleanup(), rz_io_map_del(), rz_io_map_del_for_fd(), rz_io_map_depriorize(), rz_io_map_priorize(), rz_io_map_priorize_for_fd(), rz_line_autocomplete(), rz_pvector_pop(), rz_pvector_pop_front(), rz_pvector_remove_at(), rz_rows_cmp(), rz_table_filter(), rz_test_main(), type_pos_hit(), and vars_resolve_overlaps().

◆ rz_pvector_clear()

◆ rz_pvector_contains()

RZ_API void** rz_pvector_contains ( RzPVector vec,
void *  x 
)

Definition at line 344 of file vector.c.

344  {
346  size_t i;
347  for (i = 0; i < vec->v.len; i++) {
348  if (((void **)vec->v.a)[i] == x) {
349  return &((void **)vec->v.a)[i];
350  }
351  }
352  return NULL;
353 }
size_t len
Definition: rz_vector.h:47

References rz_vector_t::a, i, rz_vector_t::len, NULL, rz_return_val_if_fail, rz_pvector_t::v, and x.

Referenced by rz_analysis_var_set_access(), and rz_pvector_remove_data().

◆ rz_pvector_data()

static void** rz_pvector_data ( RzPVector vec)
inlinestatic

Definition at line 257 of file rz_vector.h.

257  {
259  return (void **)vec->v.a;
260 }

References rz_vector_t::a, NULL, rz_return_val_if_fail, and rz_pvector_t::v.

Referenced by rz_line_autocomplete(), and selection_widget_update().

◆ rz_pvector_empty()

◆ rz_pvector_fini()

◆ rz_pvector_flush()

static void** rz_pvector_flush ( RzPVector vec)
inlinestatic

Definition at line 320 of file rz_vector.h.

320  {
321  return (void **)rz_vector_flush(&vec->v);
322 }
RZ_API void * rz_vector_flush(RzVector *vec)
Turn the vector into a fixed-size array. This will clear the vector and return an array of its origin...
Definition: vector.c:230

References rz_vector_flush(), and rz_pvector_t::v.

Referenced by parse_line_header_source(), and rz_bin_reloc_storage_new().

◆ rz_pvector_free()

RZ_API void rz_pvector_free ( RzPVector vec)

◆ rz_pvector_head()

static void* rz_pvector_head ( RzPVector vec)
inlinestatic

Definition at line 263 of file rz_vector.h.

263  {
265  return ((void **)vec->v.a)[0];
266 }

References rz_vector_t::a, NULL, rz_return_val_if_fail, and rz_pvector_t::v.

◆ rz_pvector_index_ptr()

static void** rz_pvector_index_ptr ( RzPVector vec,
size_t  index 
)
inlinestatic

Definition at line 251 of file rz_vector.h.

251  {
252  rz_return_val_if_fail(vec && index < vec->v.capacity, NULL);
253  return ((void **)vec->v.a) + index;
254 }

References rz_vector_t::a, NULL, rz_return_val_if_fail, v, and rz_pvector_t::v.

Referenced by function_argument_type_derive(), rz_analysis_function_set_type(), rz_table_columns(), rz_type_func_args_name(), and rz_type_func_args_type().

◆ rz_pvector_init()

◆ rz_pvector_insert()

static void** rz_pvector_insert ( RzPVector vec,
size_t  index,
void *  x 
)
inlinestatic

Definition at line 284 of file rz_vector.h.

284  {
285  return (void **)rz_vector_insert(&vec->v, index, &x);
286 }
RZ_API void * rz_vector_insert(RzVector *vec, size_t index, void *x)
Definition: vector.c:151

References rz_vector_insert(), rz_pvector_t::v, and x.

Referenced by rz_analysis_function_args().

◆ rz_pvector_insert_range()

static void** rz_pvector_insert_range ( RzPVector vec,
size_t  index,
void **  first,
size_t  count 
)
inlinestatic

Definition at line 289 of file rz_vector.h.

289  {
290  return (void **)rz_vector_insert_range(&vec->v, index, first, count);
291 }
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
RZ_API void * rz_vector_insert_range(RzVector *vec, size_t index, void *first, size_t count)
Definition: vector.c:167

References count, rz_vector_insert_range(), and rz_pvector_t::v.

Referenced by rz_io_map_priorize_for_fd(), and rz_test_main().

◆ rz_pvector_len()

static size_t rz_pvector_len ( const RzPVector vec)
inlinestatic

Definition at line 231 of file rz_vector.h.

231  {
232  rz_return_val_if_fail(vec, 0);
233  return vec->v.len;
234 }

References rz_vector_t::len, rz_return_val_if_fail, and rz_pvector_t::v.

Referenced by __cons_pal_update_event(), __core_visual_gogo(), analysis_block_cb(), analysis_block_on_exit(), dex_create_relocations(), dex_new_encoded_method(), dex_resolve_all_virtual_methods(), dex_resolve_entrypoints_in_class(), dex_resolve_fields_in_class(), dex_resolve_fields_in_class_as_symbols(), dex_resolve_methods_in_class(), dex_resolve_proto_id(), dex_resolve_string_id_native(), dex_resolve_symbol_in_class_methods(), function_argument_type_derive(), get_relocs(), interact(), needs_reloc_patching(), parse_line_header_source(), print_log(), print_new_results(), print_state(), reloc_targets_vfile_size(), run_rz_test(), rz_analysis_esil_get_instruction_trace(), rz_analysis_function_args(), rz_analysis_function_delete_vars_by_kind(), rz_analysis_function_get_arg_count(), rz_analysis_function_set_type(), rz_analysis_var_delete(), rz_bin_dex_classes(), rz_bin_dex_fields(), rz_bin_dex_imports(), rz_bin_dex_libraries(), rz_bin_dex_resolve_field_by_idx(), rz_bin_dex_resolve_method_by_idx(), rz_bin_dex_resolve_method_offset_by_idx(), rz_bin_dex_symbols(), rz_bin_pe_get_clr_symbols(), rz_bin_reloc_storage_new(), rz_cmd_dexe_handler(), rz_cmd_dexs_handler(), rz_core_analysis_type_match(), rz_core_disasm_pde(), rz_core_file_close(), rz_core_get_boundaries_prot(), rz_il_validate_global_context_new_from_vm(), rz_il_vm_add_mem(), rz_il_vm_get_mem(), rz_io_map_cleanup(), rz_io_map_del(), rz_io_map_del_for_fd(), rz_io_map_depriorize(), rz_io_map_priorize(), rz_io_map_priorize_for_fd(), rz_line_autocomplete(), rz_line_completion_push(), rz_pvector_empty(), rz_rows_cmp(), rz_table_add_row(), rz_table_add_row_vec(), rz_test_main(), rz_test_run_asm_test(), rz_type_func_args_count(), rz_type_func_args_name(), rz_type_func_args_type(), save_callable(), selection_widget_update(), type_match(), and vars_resolve_overlaps().

◆ rz_pvector_new()

RZ_API RzPVector* rz_pvector_new ( RzPVectorFree  free)

◆ rz_pvector_new_with_len()

RZ_API RzPVector* rz_pvector_new_with_len ( RzPVectorFree  free,
size_t  length 
)

Definition at line 311 of file vector.c.

311  {
313  if (!v) {
314  return NULL;
315  }
316  void **p = rz_pvector_reserve(v, length);
317  if (!p) {
319  return NULL;
320  }
321  memset(p, 0, v->v.elem_size * v->v.capacity);
322  v->v.len = length;
323  return v;
324 }
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 static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
return memset(p, 0, total)
void * p
Definition: libc.cpp:67
static void ** rz_pvector_reserve(RzPVector *vec, size_t capacity)
Definition: rz_vector.h:312
RZ_API RzPVector * rz_pvector_new(RzPVectorFree free)
Definition: vector.c:302
RZ_API void rz_pvector_free(RzPVector *vec)
Definition: vector.c:336

References free(), length, memset(), NULL, p, rz_pvector_free(), rz_pvector_new(), rz_pvector_reserve(), and v.

Referenced by get_relocs().

◆ rz_pvector_pop()

RZ_API void* rz_pvector_pop ( RzPVector vec)

Definition at line 372 of file vector.c.

372  {
374  void *r = rz_pvector_at(vec, vec->v.len - 1);
375  rz_vector_pop(&vec->v, NULL);
376  return r;
377 }
#define r
Definition: crypto_rc6.c:12
static void * rz_pvector_at(const RzPVector *vec, size_t index)
Definition: rz_vector.h:236
RZ_API void rz_vector_pop(RzVector *vec, void *into)
Definition: vector.c:184

References rz_vector_t::len, NULL, r, rz_pvector_at(), rz_return_val_if_fail, rz_vector_pop(), and rz_pvector_t::v.

Referenced by analysis_block_on_exit(), rz_analysis_block_recurse(), rz_analysis_block_recurse_followthrough(), rz_core_visual_cmd(), rz_test_run_asm_test(), substitute_args_fini(), and worker_th().

◆ rz_pvector_pop_front()

RZ_API void* rz_pvector_pop_front ( RzPVector vec)

Definition at line 379 of file vector.c.

379  {
381  void *r = rz_pvector_at(vec, 0);
382  rz_vector_pop_front(&vec->v, NULL);
383  return r;
384 }
RZ_API void rz_vector_pop_front(RzVector *vec, void *into)
Definition: vector.c:192

References NULL, r, rz_pvector_at(), rz_return_val_if_fail, rz_vector_pop_front(), and rz_pvector_t::v.

Referenced by rz_core_disasm_pde(), and rz_tree_bfs().

◆ rz_pvector_push()

static void** rz_pvector_push ( RzPVector vec,
void *  x 
)
inlinestatic

Definition at line 300 of file rz_vector.h.

300  {
301  return (void **)rz_vector_push(&vec->v, &x);
302 }
RZ_API void * rz_vector_push(RzVector *vec, void *x)
Definition: vector.c:197

References rz_vector_push(), rz_pvector_t::v, and x.

Referenced by __addRow(), __cons_pal_update_event(), add_map(), analysis_block_cb(), analysis_class_print(), block_recurse_successor_cb(), c_parser_new_callable_argument(), capture_filter_keywords(), cmd_desc_set_parent(), collect_nodes_cb(), core_file_do_load_for_debug(), core_file_do_load_for_io_plugin(), database_load(), database_load_fuzz_file(), del(), dex_parse(), ds_newline(), get_callable_type(), get_patchable_relocs(), get_token_patterns(), interact(), io_create_mem_map(), io_map_new(), map_multi_dex(), parse_line_header_source(), parse_type_arglist(), print_stats(), read_image_metadata_tilde_header(), recovery_analysis_complete_object_locator(), recovery_analysis_type_descriptor(), run_rz_test(), rz_analysis_block_recurse(), rz_analysis_block_recurse_followthrough(), rz_analysis_block_shortest_path(), rz_analysis_esil_trace_op(), rz_analysis_function_all_opcode_stat_handler(), rz_analysis_function_args(), rz_analysis_function_set_var(), rz_analysis_il_config_add_label(), rz_analysis_il_trace_add_mem(), rz_analysis_il_trace_add_reg(), rz_analysis_var_set_access(), rz_annotated_code_annotations_in(), rz_annotated_code_annotations_range(), rz_bin_object_get_maps_at(), rz_bin_object_sections_mapping_list(), rz_bin_reloc_storage_new(), rz_bin_source_line_info_builder_build_and_fini(), rz_core_analysis_bytes(), rz_core_recover_vars(), rz_il_vm_add_mem(), rz_io_cache_write(), rz_io_map_priorize(), rz_io_map_priorize_for_fd(), rz_line_completion_push(), rz_line_ns_completion_result_add(), rz_serialize_analysis_load(), rz_subprocess_start_opt(), rz_table_columns(), rz_table_transpose(), rz_test_load_asm_test_file(), rz_test_load_cmd_test_file(), rz_test_load_json_test_file(), rz_test_main(), rz_test_run_asm_test(), rz_tree_bfs(), rz_type_callable_arg_add(), rz_type_callable_clone(), rz_type_func_arg_add(), shortest_path_successor_cb(), source_file_collect_cb(), substitute_args_init(), vars_collect_cb(), and worker_th().

◆ rz_pvector_push_front()

static void** rz_pvector_push_front ( RzPVector vec,
void *  x 
)
inlinestatic

Definition at line 305 of file rz_vector.h.

305  {
306  return (void **)rz_vector_push_front(&vec->v, &x);
307 }
RZ_API void * rz_vector_push_front(RzVector *vec, void *x)
Definition: vector.c:209

References rz_vector_push_front(), rz_pvector_t::v, and x.

Referenced by rz_core_visual_cmd(), and rz_io_map_depriorize().

◆ rz_pvector_remove_at()

RZ_API void* rz_pvector_remove_at ( RzPVector vec,
size_t  index 
)

Definition at line 355 of file vector.c.

355  {
357  void *r = rz_pvector_at(vec, index);
358  rz_vector_remove_at(&vec->v, index, NULL);
359  return r;
360 }
RZ_API void rz_vector_remove_at(RzVector *vec, size_t index, void *into)
Definition: vector.c:127

References NULL, r, rz_pvector_at(), rz_return_val_if_fail, rz_vector_remove_at(), and rz_pvector_t::v.

Referenced by rz_analysis_function_delete_vars_by_kind(), rz_analysis_var_delete(), rz_io_map_cleanup(), rz_io_map_del(), rz_io_map_del_for_fd(), rz_io_map_depriorize(), rz_io_map_priorize(), rz_io_map_priorize_for_fd(), and rz_test_main().

◆ rz_pvector_remove_data()

RZ_API void rz_pvector_remove_data ( RzPVector vec,
void *  x 
)

Definition at line 362 of file vector.c.

362  {
363  void **el = rz_pvector_contains(vec, x);
364  if (!el) {
365  return;
366  }
367 
368  size_t index = el - (void **)vec->v.a;
369  rz_vector_remove_at(&vec->v, index, NULL);
370 }
RZ_API void ** rz_pvector_contains(RzPVector *vec, void *x)
Definition: vector.c:344

References rz_vector_t::a, NULL, rz_pvector_contains(), rz_vector_remove_at(), rz_pvector_t::v, and x.

Referenced by cmd_desc_unset_parent(), rz_analysis_function_delete_var(), rz_analysis_var_clear_accesses(), rz_analysis_var_remove_access_at(), rz_core_file_bin_file_deleted(), rz_core_file_io_desc_closed(), rz_core_file_io_map_deleted(), rz_io_cache_invalidate(), and rz_subprocess_free().

◆ rz_pvector_reserve()

static void** rz_pvector_reserve ( RzPVector vec,
size_t  capacity 
)
inlinestatic

Definition at line 312 of file rz_vector.h.

312  {
313  return (void **)rz_vector_reserve(&vec->v, capacity);
314 }
RZ_API void * rz_vector_reserve(RzVector *vec, size_t capacity)
Definition: vector.c:214

References rz_vector_reserve(), and rz_pvector_t::v.

Referenced by dex_parse(), get_callable_type(), rz_analysis_function_args(), rz_bin_reloc_storage_new(), rz_bin_source_line_info_builder_build_and_fini(), rz_core_analysis_bytes(), rz_il_vm_add_mem(), rz_line_completion_set(), rz_pvector_new_with_len(), and rz_tree_bfs().

◆ rz_pvector_set()

static void rz_pvector_set ( RzPVector vec,
size_t  index,
void *  e 
)
inlinestatic

Definition at line 241 of file rz_vector.h.

241  {
242  rz_return_if_fail(vec && index < vec->v.len);
243  ((void **)vec->v.a)[index] = e;
244 }
#define e(frag)

References rz_vector_t::a, e, rz_return_if_fail, v, and rz_pvector_t::v.

Referenced by rz_analysis_function_args(), and rz_il_vm_add_mem().

◆ rz_pvector_shrink()

static void** rz_pvector_shrink ( RzPVector vec)
inlinestatic

Definition at line 316 of file rz_vector.h.

316  {
317  return (void **)rz_vector_shrink(&vec->v);
318 }
RZ_API void * rz_vector_shrink(RzVector *vec)
Definition: vector.c:222

References rz_vector_shrink(), and rz_pvector_t::v.

◆ rz_pvector_sort()

RZ_API void rz_pvector_sort ( RzPVector vec,
RzPVectorComparator  cmp 
)

Definition at line 408 of file vector.c.

408  {
409  rz_return_if_fail(vec && cmp);
410  quick_sort(vec->v.a, vec->v.len, cmp);
411 }
static void quick_sort(void **a, size_t n, RzPVectorComparator cmp)
Definition: vector.c:387

References rz_vector_t::a, cmp(), rz_vector_t::len, quick_sort(), rz_return_if_fail, and rz_pvector_t::v.

Referenced by __cons_pal_update_event(), cmd_desc_set_parent(), print_source_info(), rz_bin_reloc_storage_new(), rz_bin_source_line_info_builder_build_and_fini(), and sort_groups().

◆ rz_pvector_tail()

static void* rz_pvector_tail ( RzPVector vec)
inlinestatic

Definition at line 269 of file rz_vector.h.

269  {
271  return ((void **)vec->v.a)[vec->v.len - 1];
272 }

References rz_vector_t::a, rz_vector_t::len, NULL, rz_return_val_if_fail, and rz_pvector_t::v.

Referenced by map_multi_dex(), and rz_table_tosimplestring().

◆ rz_vector_assign()

RZ_API void rz_vector_assign ( RzVector vec,
void *  p,
void *  elem 
)

Definition at line 114 of file vector.c.

114  {
115  rz_return_if_fail(vec && p && elem);
116  memcpy(p, elem, vec->elem_size);
117 }
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
size_t elem_size
Definition: rz_vector.h:49

References rz_vector_t::elem_size, memcpy(), p, and rz_return_if_fail.

Referenced by rz_vector_assign_at(), rz_vector_insert(), rz_vector_pop(), rz_vector_push(), and rz_vector_remove_at().

◆ rz_vector_assign_at()

RZ_API void* rz_vector_assign_at ( RzVector vec,
size_t  index,
void *  elem 
)

Definition at line 119 of file vector.c.

119  {
120  void *p = rz_vector_index_ptr(vec, index);
121  if (elem) {
122  rz_vector_assign(vec, p, elem);
123  }
124  return p;
125 }
static void * rz_vector_index_ptr(RzVector *vec, size_t index)
Definition: rz_vector.h:88
RZ_API void rz_vector_assign(RzVector *vec, void *p, void *elem)
Definition: vector.c:114

References p, rz_vector_assign(), and rz_vector_index_ptr().

◆ rz_vector_clear()

◆ rz_vector_clone()

RZ_API RzVector* rz_vector_clone ( RzVector vec)

Definition at line 101 of file vector.c.

101  {
103  RzVector *ret = RZ_NEW(RzVector);
104  if (!ret) {
105  return NULL;
106  }
107  if (!vector_clone(ret, vec)) {
108  free(ret);
109  return NULL;
110  }
111  return ret;
112 }
static bool vector_clone(RzVector *dst, RzVector *src)
Definition: vector.c:82

References free(), NULL, RZ_NEW, rz_return_val_if_fail, and vector_clone().

Referenced by clear_bb_vars(), fcn_takeover_block_recursive_followthrough_cb(), rz_analysis_function_delete_unused_vars(), rz_analysis_function_set_type(), rz_analysis_var_resolve_overlaps(), rz_asm_token_string_clone(), and rz_core_disasm_pde().

◆ rz_vector_empty()

◆ rz_vector_fini()

◆ rz_vector_flush()

RZ_API void* rz_vector_flush ( RzVector vec)

Turn the vector into a fixed-size array. This will clear the vector and return an array of its original contents whose ownership is transferred to the caller. This is useful when RzVector is used for its dynamically growing functionality as an intermediate step to generate a fixed-size array in the end.

Definition at line 230 of file vector.c.

230  {
232  rz_vector_shrink(vec);
233  void *r = vec->a;
234  vec->a = NULL;
235  vec->capacity = vec->len = 0;
236  return r;
237 }
RZ_API void * rz_vector_shrink(RzVector *vec)
Definition: vector.c:222

References rz_vector_t::a, rz_vector_t::capacity, rz_vector_t::len, NULL, r, rz_return_val_if_fail, and rz_vector_shrink().

Referenced by parse_line_header_source(), parse_line_raw(), rz_bin_source_line_info_builder_build_and_fini(), rz_il_reg_binding_derive(), and rz_pvector_flush().

◆ rz_vector_free()

◆ rz_vector_head()

static void* rz_vector_head ( RzVector vec)
inlinestatic

Definition at line 94 of file rz_vector.h.

94  {
96  return (void *)vec->a;
97 }

References rz_vector_t::a, NULL, and rz_return_val_if_fail.

◆ rz_vector_index_ptr()

static void* rz_vector_index_ptr ( RzVector vec,
size_t  index 
)
inlinestatic

Definition at line 88 of file rz_vector.h.

88  {
89  rz_return_val_if_fail(vec && index < vec->capacity, NULL);
90  return (char *)vec->a + vec->elem_size * index;
91 }

References rz_vector_t::a, rz_vector_t::elem_size, NULL, and rz_return_val_if_fail.

Referenced by __addRow(), __computeTotal(), __table_adjust(), _get_checkpoint_before(), _restore_memory_cb(), _set_register(), add_seek_history(), analBars(), backtrace_windows_x64(), buf_sparse_read(), buf_sparse_resize(), cmd_print_bars(), cmd_print_blocks(), get_number_of_segments(), init_shstrtab_aux(), nextword(), on_map_skyline(), restore_memory_cb(), restore_register(), rz_analysis_block_recurse_depth_first(), rz_analysis_function_get_var_reg_at(), rz_analysis_function_get_var_stackptr_at(), rz_analysis_var_get_access_at(), rz_analysis_var_get_constraints_readable(), rz_analysis_var_global_get_constraints_readable(), rz_analysis_var_remove_access_at(), rz_analysis_var_set_access(), rz_bin_elf_get_section(), rz_buf_sparse_get_chunks(), rz_buf_sparse_populated_in(), rz_core_annotated_code_print(), rz_core_get_boundaries_prot(), rz_core_seek_peek(), rz_rows_cmp(), rz_skyline_add(), rz_skyline_get_item_intersect(), rz_table_align(), rz_table_columns(), rz_table_filter(), rz_table_filter_columns(), rz_table_group(), rz_table_sort(), rz_table_sortlen(), rz_table_tocsv(), rz_table_tofancystring(), rz_table_tojson(), rz_table_tosimplestring(), rz_table_transpose(), rz_vector_assign_at(), rz_vector_insert(), rz_vector_insert_range(), rz_vector_pop(), rz_vector_push(), rz_vector_remove_at(), rz_vector_remove_range(), sparse_limits(), sparse_write(), unset_addr_hint_record(), and vector_free_elems().

◆ rz_vector_init()

◆ rz_vector_insert()

RZ_API void* rz_vector_insert ( RzVector vec,
size_t  index,
void *  x 
)

Definition at line 151 of file vector.c.

151  {
152  rz_return_val_if_fail(vec && index <= vec->len, NULL);
153  if (vec->len >= vec->capacity) {
155  }
156  void *p = rz_vector_index_ptr(vec, index);
157  if (index < vec->len) {
158  memmove((char *)p + vec->elem_size, p, vec->elem_size * (vec->len - index));
159  }
160  vec->len++;
161  if (x) {
162  rz_vector_assign(vec, p, x);
163  }
164  return p;
165 }
#define NEXT_VECTOR_CAPACITY
Definition: vector.c:17
#define RESIZE_OR_RETURN_NULL(next_capacity)
Definition: vector.c:22

References rz_vector_t::capacity, rz_vector_t::elem_size, len, rz_vector_t::len, NEXT_VECTOR_CAPACITY, NULL, p, RESIZE_OR_RETURN_NULL, rz_return_val_if_fail, rz_vector_assign(), rz_vector_index_ptr(), and x.

Referenced by rz_analysis_var_set_access(), rz_pvector_insert(), rz_skyline_add(), rz_vector_push_front(), and sparse_write().

◆ rz_vector_insert_range()

RZ_API void* rz_vector_insert_range ( RzVector vec,
size_t  index,
void *  first,
size_t  count 
)

Definition at line 167 of file vector.c.

167  {
168  rz_return_val_if_fail(vec && index <= vec->len, NULL);
169  if (vec->len + count > vec->capacity) {
171  }
172  size_t sz = count * vec->elem_size;
173  void *p = rz_vector_index_ptr(vec, index);
174  if (index < vec->len) {
175  memmove((char *)p + sz, p, vec->elem_size * (vec->len - index));
176  }
177  vec->len += count;
178  if (first) {
179  memcpy(p, first, sz);
180  }
181  return p;
182 }
#define RZ_MAX(x, y)

References rz_vector_t::capacity, count, rz_vector_t::elem_size, len, rz_vector_t::len, memcpy(), NEXT_VECTOR_CAPACITY, NULL, p, RESIZE_OR_RETURN_NULL, RZ_MAX, rz_return_val_if_fail, and rz_vector_index_ptr().

Referenced by rz_core_analysis_get_stats(), and rz_pvector_insert_range().

◆ rz_vector_len()

◆ rz_vector_new()

◆ rz_vector_pop()

RZ_API void rz_vector_pop ( RzVector vec,
void *  into 
)

Definition at line 184 of file vector.c.

184  {
185  rz_return_if_fail(vec);
186  if (into) {
187  rz_vector_assign(vec, into, rz_vector_index_ptr(vec, vec->len - 1));
188  }
189  vec->len--;
190 }

References rz_vector_t::len, rz_return_if_fail, rz_vector_assign(), and rz_vector_index_ptr().

Referenced by rz_analysis_block_recurse_depth_first(), rz_analysis_run_tasks(), rz_core_seek_redo(), rz_core_seek_undo(), and rz_pvector_pop().

◆ rz_vector_pop_front()

RZ_API void rz_vector_pop_front ( RzVector vec,
void *  into 
)

Definition at line 192 of file vector.c.

192  {
193  rz_return_if_fail(vec);
194  rz_vector_remove_at(vec, 0, into);
195 }

References rz_return_if_fail, and rz_vector_remove_at().

Referenced by rz_id_pool_grab_id(), and rz_pvector_pop_front().

◆ rz_vector_push()

RZ_API void* rz_vector_push ( RzVector vec,
void *  x 
)

Definition at line 197 of file vector.c.

197  {
199  if (vec->len >= vec->capacity) {
201  }
202  void *p = rz_vector_index_ptr(vec, vec->len++);
203  if (x) {
204  rz_vector_assign(vec, p, x);
205  }
206  return p;
207 }

References rz_vector_t::capacity, rz_vector_t::len, NEXT_VECTOR_CAPACITY, NULL, p, RESIZE_OR_RETURN_NULL, rz_return_val_if_fail, rz_vector_assign(), rz_vector_index_ptr(), and x.

Referenced by add_dt_dynamic_entry(), add_mem_change(), add_reg_change(), add_seek_history(), add_token(), analyze_function_locally(), array_add(), bflt_load_relocs(), compute_symbols_from_segment(), convert_sections_from_shdr(), create_section_from_phdr(), deserialize_checkpoints_cb(), deserialize_memory_cb(), deserialize_registers_cb(), ensure_addr_hint_record(), get_enum_type(), get_gnu_debugdata_elf_symbols(), get_relocs_entry(), get_segments_from_phdr(), get_struct_type(), get_union_type(), global_var_load_cb(), init_module_runtime_functions(), nextword(), parse_enum(), parse_enum_node(), parse_enum_type(), parse_line_header_source(), parse_note_file(), parse_note_prstatus(), parse_opcodes(), parse_struct_node(), parse_structure(), parse_structure_type(), parse_union(), parse_union_node(), recovery_analysis_complete_object_locator(), rz_analysis_block_recurse_depth_first(), rz_analysis_class_base_get_all(), rz_analysis_class_method_get_all(), rz_analysis_class_vtable_get_all(), rz_analysis_get_delta_jmptbl_info(), rz_analysis_il_init_state_set_var(), rz_analysis_task_item_new(), rz_analysis_var_add_constraint(), rz_analysis_var_global_add_constraint(), rz_analysis_vtable_parse_at(), rz_annotated_code_add_annotation(), rz_annotated_code_line_offsets(), rz_bin_elf_notes_new(), rz_bin_elf_sections_new(), rz_bin_object_p2v_all(), rz_bin_object_sections_mapping_list(), rz_bin_source_line_info_builder_push_sample(), rz_core_seek_redo(), rz_core_seek_undo(), rz_debug_add_checkpoint(), rz_debug_dmp_init(), rz_debug_dmp_pids(), rz_debug_session_add_mem_change(), rz_debug_session_add_reg_change(), rz_event_hook(), rz_event_unhook(), rz_id_pool_kick_id(), rz_il_reg_binding_derive(), rz_pvector_push(), rz_serialize_analysis_var_load(), rz_table_add_column(), rz_table_add_row(), rz_table_add_row_vec(), and rz_table_columns().

◆ rz_vector_push_front()

RZ_API void* rz_vector_push_front ( RzVector vec,
void *  x 
)

Definition at line 209 of file vector.c.

209  {
211  return rz_vector_insert(vec, 0, x);
212 }
RZ_API void * rz_vector_insert(RzVector *vec, size_t index, void *x)
Definition: vector.c:151

References NULL, rz_return_val_if_fail, rz_vector_insert(), and x.

Referenced by rz_pvector_push_front().

◆ rz_vector_remove_at()

RZ_API void rz_vector_remove_at ( RzVector vec,
size_t  index,
void *  into 
)

Definition at line 127 of file vector.c.

127  {
128  rz_return_if_fail(vec);
129  void *p = rz_vector_index_ptr(vec, index);
130  if (into) {
131  rz_vector_assign(vec, into, p);
132  }
133  vec->len--;
134  if (index < vec->len) {
135  memmove(p, (char *)p + vec->elem_size, vec->elem_size * (vec->len - index));
136  }
137 }

References rz_vector_t::elem_size, len, rz_vector_t::len, p, rz_return_if_fail, rz_vector_assign(), and rz_vector_index_ptr().

Referenced by add_seek_history(), del_hook(), rz_analysis_var_remove_access_at(), rz_pvector_remove_at(), rz_pvector_remove_data(), rz_skyline_add(), rz_table_filter(), rz_table_group(), rz_vector_pop_front(), and unset_addr_hint_record().

◆ rz_vector_remove_range()

RZ_API void rz_vector_remove_range ( RzVector vec,
size_t  index,
size_t  count,
void *  into 
)

remove all elements in the given range and write the contents to into (must be appropriately large). It is the caller's responsibility to free potential resources associated with the elements.

Definition at line 139 of file vector.c.

139  {
140  rz_return_if_fail(vec && index + count <= vec->len);
141  void *p = rz_vector_index_ptr(vec, index);
142  if (into) {
143  memcpy(into, p, count * vec->elem_size);
144  }
145  vec->len -= count;
146  if (index < vec->len) {
147  memmove(p, (char *)p + vec->elem_size * count, vec->elem_size * (vec->len - index));
148  }
149 }

References count, rz_vector_t::elem_size, len, rz_vector_t::len, memcpy(), p, rz_return_if_fail, and rz_vector_index_ptr().

Referenced by buf_sparse_resize(), and sparse_write().

◆ rz_vector_reserve()

◆ rz_vector_shrink()

RZ_API void* rz_vector_shrink ( RzVector vec)

Definition at line 222 of file vector.c.

222  {
224  if (vec->len < vec->capacity) {
226  }
227  return vec->a;
228 }

References rz_vector_t::a, rz_vector_t::capacity, rz_vector_t::len, NULL, RESIZE_OR_RETURN_NULL, and rz_return_val_if_fail.

Referenced by rz_pvector_shrink(), and rz_vector_flush().

◆ rz_vector_sort()

RZ_API void rz_vector_sort ( RzVector vec,
RzVectorComparator  cmp,
bool  reverse 
)

Sort function for RzVector.

Parameters
vecpointer to RzVector
cmpfunction used for comparing elements while sorting
reversesort order, ascending order when reverse = False

Definition at line 285 of file vector.c.

285  {
286  rz_return_if_fail(vec && cmp);
287  vector_quick_sort(vec->a, vec->elem_size, vec->len, cmp, reverse);
288 }
static void vector_quick_sort(void *a, size_t elem_size, size_t len, RzPVectorComparator cmp, bool reverse)
Definition: vector.c:241

References rz_vector_t::a, cmp(), rz_vector_t::elem_size, rz_vector_t::len, make_dist_html::reverse, rz_return_if_fail, and vector_quick_sort().

Referenced by rz_asm_tokenize_asm_regex(), rz_table_sort(), and rz_table_sortlen().

◆ rz_vector_tail()

static void* rz_vector_tail ( RzVector vec)
inlinestatic

Definition at line 100 of file rz_vector.h.

100  {
102  return (char *)vec->a + vec->elem_size * (vec->len - 1);
103 }

References rz_vector_t::a, rz_vector_t::elem_size, rz_vector_t::len, NULL, and rz_return_val_if_fail.

Referenced by parse_enum_node(), rz_table_add_row_columnsf(), and rz_table_tosimplestring().