mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 11:43:39 +00:00
46 lines
1.0 KiB
C
46 lines
1.0 KiB
C
#include <r_anal.h>
|
|
|
|
|
|
RAnalSwitchOp *switch_op_new() {
|
|
RAnalSwitchOp * swop = R_NEW0 (RAnalSwitchOp);
|
|
if (!swop) return NULL;
|
|
swop->cases = r_list_new ();
|
|
if (!swop->cases) {
|
|
free (swop);
|
|
return NULL;
|
|
}
|
|
swop->cases->free = (void *)free;
|
|
swop->min_val = swop->def_val = swop->max_val = 0;
|
|
return swop;
|
|
}
|
|
|
|
R_API RAnalSwitchOp * r_anal_switch_op_new(ut64 addr, ut64 min_val, ut64 def_val) {
|
|
RAnalSwitchOp *swop = switch_op_new();
|
|
if (swop) {
|
|
swop->addr = addr;
|
|
swop->min_val = min_val;
|
|
swop->def_val = min_val;
|
|
swop->max_val = min_val;
|
|
}
|
|
return swop;
|
|
}
|
|
|
|
R_API void r_anal_switch_op_free(RAnalSwitchOp * swop) {
|
|
if (!swop || (((ut32)(size_t)swop)==UT32_MAX)) return;
|
|
if (swop->cases)
|
|
r_list_free(swop->cases);
|
|
free(swop);
|
|
}
|
|
|
|
R_API RAnalCaseOp* r_anal_switch_op_add_case(RAnalSwitchOp * swop, ut64 addr, ut64 value, ut64 jump) {
|
|
RAnalCaseOp * caseop = R_NEW0(RAnalCaseOp);
|
|
if (!caseop) return NULL;
|
|
caseop->addr = addr;
|
|
caseop->value = value;
|
|
caseop->jump = jump;
|
|
r_list_append (swop->cases, caseop);
|
|
return caseop;
|
|
}
|
|
|
|
|