Rizin
unix-like reverse engineering framework and cli tools
switch.c File Reference
#include <rz_analysis.h>

Go to the source code of this file.

Functions

static RzAnalysisSwitchOp__switch_op_new (void)
 
RZ_API RzAnalysisSwitchOprz_analysis_switch_op_new (ut64 addr, ut64 min_val, ut64 max_val, ut64 def_val)
 
RZ_API RzAnalysisCaseOprz_analysis_case_op_new (ut64 addr, ut64 val, ut64 jump)
 
RZ_API void rz_analysis_switch_op_free (RzAnalysisSwitchOp *swop)
 
RZ_API RzAnalysisCaseOprz_analysis_switch_op_add_case (RzAnalysisSwitchOp *swop, ut64 addr, ut64 value, ut64 jump)
 

Function Documentation

◆ __switch_op_new()

static RzAnalysisSwitchOp* __switch_op_new ( void  )
static

Definition at line 7 of file switch.c.

7  {
9  if (swop) {
10  swop->cases = rz_list_new();
11  if (!swop->cases) {
12  free(swop);
13  return NULL;
14  }
15  swop->cases->free = (void *)free;
16  swop->min_val = swop->def_val = swop->max_val = 0;
17  }
18  return swop;
19 }
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
#define RZ_NEW0(x)
Definition: rz_types.h:284
RzListFree free
Definition: rz_list.h:21

References rz_analysis_switch_obj_t::cases, rz_analysis_switch_obj_t::def_val, rz_list_t::free, free(), rz_analysis_switch_obj_t::max_val, rz_analysis_switch_obj_t::min_val, NULL, rz_list_new(), and RZ_NEW0.

Referenced by rz_analysis_switch_op_new().

◆ rz_analysis_case_op_new()

RZ_API RzAnalysisCaseOp* rz_analysis_case_op_new ( ut64  addr,
ut64  val,
ut64  jump 
)

Definition at line 32 of file switch.c.

32  {
34  if (c) {
35  c->addr = addr;
36  c->value = val;
37  c->jump = jump;
38  }
39  return c;
40 }
ut16 val
Definition: armass64_const.h:6
int jump(int a, int b)
Definition: bcj_test.c:35
#define c(i)
Definition: sha256.c:43
static int addr
Definition: z80asm.c:58

References addr, c, jump(), RZ_NEW0, and val.

Referenced by rz_analysis_switch_op_add_case().

◆ rz_analysis_switch_op_add_case()

RZ_API RzAnalysisCaseOp* rz_analysis_switch_op_add_case ( RzAnalysisSwitchOp swop,
ut64  addr,
ut64  value,
ut64  jump 
)

Definition at line 49 of file switch.c.

49  {
52  if (caseop) {
53  rz_list_append(swop->cases, caseop);
54  }
55  return caseop;
56 }
static int value
Definition: cmd_api.c:93
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define UT64_MAX
Definition: rz_types_base.h:86
RZ_API RzAnalysisCaseOp * rz_analysis_case_op_new(ut64 addr, ut64 val, ut64 jump)
Definition: switch.c:32

References addr, rz_analysis_switch_obj_t::cases, jump(), NULL, rz_analysis_case_op_new(), rz_list_append(), rz_return_val_if_fail, UT64_MAX, and value.

Referenced by rz_analysis_block_add_switch_case(), and rz_serialize_analysis_switch_op_load().

◆ rz_analysis_switch_op_free()

RZ_API void rz_analysis_switch_op_free ( RzAnalysisSwitchOp swop)

Definition at line 42 of file switch.c.

42  {
43  if (swop) {
44  rz_list_free(swop->cases);
45  free(swop);
46  }
47 }
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137

References rz_analysis_switch_obj_t::cases, free(), and rz_list_free().

Referenced by block_free(), rz_analysis_block_chop_noreturn(), rz_analysis_block_merge(), and rz_analysis_op_fini().

◆ rz_analysis_switch_op_new()

RZ_API RzAnalysisSwitchOp* rz_analysis_switch_op_new ( ut64  addr,
ut64  min_val,
ut64  max_val,
ut64  def_val 
)

Definition at line 21 of file switch.c.

21  {
23  if (swop) {
24  swop->addr = addr;
25  swop->min_val = min_val;
26  swop->def_val = def_val;
27  swop->max_val = max_val;
28  }
29  return swop;
30 }
static RzAnalysisSwitchOp * __switch_op_new(void)
Definition: switch.c:7

References __switch_op_new(), addr, rz_analysis_switch_obj_t::addr, rz_analysis_switch_obj_t::def_val, rz_analysis_switch_obj_t::max_val, and rz_analysis_switch_obj_t::min_val.

Referenced by rz_analysis_block_add_switch_case(), and rz_serialize_analysis_switch_op_load().