mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
Remove RList.get_top and RList.get_bottom
This commit is contained in:
parent
7874971313
commit
22d71f931a
@ -658,10 +658,10 @@ R_API void r_anal_esil_cfg_merge_blocks(RAnalEsilCFG *cfg) {
|
||||
r_list_foreach_safe (cfg->g->nodes, iter, ator, node) {
|
||||
if (r_list_length (node->in_nodes) == 1) {
|
||||
REsilBB *bb = (REsilBB *)node->data;
|
||||
RGraphNode *top = (RGraphNode *)r_list_get_top (node->out_nodes);
|
||||
RGraphNode *top = (RGraphNode *)r_list_last (node->out_nodes);
|
||||
// segfaults here ?
|
||||
if (!(top && bb->enter == R_ESIL_BLOCK_ENTER_GLUE && (r_list_length (top->in_nodes) > 1))) {
|
||||
RGraphNode *block = (RGraphNode *)r_list_get_top (node->in_nodes);
|
||||
RGraphNode *block = (RGraphNode *)r_list_last (node->in_nodes);
|
||||
if (r_list_length (block->out_nodes) == 1) {
|
||||
merge_2_blocks (cfg, node, block);
|
||||
}
|
||||
|
@ -1834,7 +1834,7 @@ static int _dfg_gnode_reducer_insert_cmp(void *incoming, void *in, void *user) {
|
||||
static void _dfg_filter_rev_dfs(RGraphNode *n, RAnalEsilDFGFilter *filter) {
|
||||
RAnalEsilDFGNode *node = (RAnalEsilDFGNode *)n->data;
|
||||
if (node->type & R_ANAL_ESIL_DFG_TAG_RESULT) {
|
||||
RGraphNode *previous = (RGraphNode *)r_list_get_top (n->in_nodes);
|
||||
RGraphNode *previous = (RGraphNode *)r_list_last (n->in_nodes);
|
||||
if (!previous) {
|
||||
return;
|
||||
}
|
||||
@ -1946,7 +1946,7 @@ static RStrBuf *filter_gnode_expr(RAnalEsilDFG *dfg, RGraphNode *gnode) { //TODO
|
||||
RAnalEsilDFGNode *node = (RAnalEsilDFGNode *)gnode->data;
|
||||
if ((node->type & (R_ANAL_ESIL_DFG_TAG_RESULT |
|
||||
R_ANAL_ESIL_DFG_TAG_REG | R_ANAL_ESIL_DFG_TAG_MEM)) == R_ANAL_ESIL_DFG_TAG_RESULT) {
|
||||
RGraphNode *previous = (RGraphNode *)r_list_get_top (gnode->in_nodes);
|
||||
RGraphNode *previous = (RGraphNode *)r_list_last (gnode->in_nodes);
|
||||
if (((RAnalEsilDFGNode *)previous->data)->type & R_ANAL_ESIL_DFG_TAG_GENERATIVE) {
|
||||
r_crbtree_insert (filter.tree, previous->data, _dfg_node_filter_insert_cmp, NULL);
|
||||
}
|
||||
@ -2011,7 +2011,7 @@ R_API void r_anal_esil_dfg_fold_const(RAnal *anal, RAnalEsilDFG *dfg) {
|
||||
// ok, so gnode here cannot contain a generative node, only const-results
|
||||
// get_resolved_expr expects a generative node
|
||||
// the predecessor of a const-result node is always a generative node
|
||||
RGraphNode *previous_gnode = (RGraphNode *)r_list_get_top (gnode->in_nodes);
|
||||
RGraphNode *previous_gnode = (RGraphNode *)r_list_last (gnode->in_nodes);
|
||||
// it can never be NULL
|
||||
|
||||
RAnalEsilDFGNode *enode = (RAnalEsilDFGNode *)previous_gnode->data;
|
||||
@ -2042,7 +2042,7 @@ R_API void r_anal_esil_dfg_fold_const(RAnal *anal, RAnalEsilDFG *dfg) {
|
||||
|
||||
gnode = (RGraphNode *)r_queue_dequeue (dfg->todo);
|
||||
enode = (RAnalEsilDFGNode *)gnode->data;
|
||||
RGraphNode *next_gnode = (RGraphNode *)r_list_get_top (gnode->out_nodes);
|
||||
RGraphNode *next_gnode = (RGraphNode *)r_list_last (gnode->out_nodes);
|
||||
if (next_gnode) {
|
||||
// Cannot assume that there is another operation
|
||||
// Fix string reference
|
||||
|
@ -1317,7 +1317,7 @@ static bool closest_match_update(RSignItem *it, ClosestMatchData *data) {
|
||||
r_sign_close_match_free (r_list_pop (data->output));
|
||||
|
||||
// get new infimum
|
||||
row = r_list_get_top (data->output);
|
||||
row = r_list_last (data->output);
|
||||
data->infimum = row->score;
|
||||
}
|
||||
return true;
|
||||
|
@ -414,7 +414,7 @@ R_API char *r_anal_var_prot_serialize(RList *l, bool spaces) {
|
||||
const char * const sep = spaces? ", ": ",";
|
||||
size_t len = strlen (sep);
|
||||
RAnalVarProt *v;
|
||||
RAnalVarProt *top = (RAnalVarProt *)r_list_get_top (l);
|
||||
RAnalVarProt *top = (RAnalVarProt *)r_list_last (l);
|
||||
RListIter *iter;
|
||||
r_list_foreach (l, iter, v) {
|
||||
if (!serialize_single_var (v, sb) || (v != top && !r_strbuf_append_n (sb, sep, len))) {
|
||||
|
@ -2644,7 +2644,7 @@ static int walk_exports(struct MACH0_(obj_t) *bin, RExportsIterator iterator, vo
|
||||
r_list_push (states, root);
|
||||
|
||||
do {
|
||||
RTrieState * state = r_list_get_top (states);
|
||||
RTrieState *state = r_list_last (states);
|
||||
p = state->node;
|
||||
ut64 len = read_uleb128 (&p, end);
|
||||
if (len == UT64_MAX) {
|
||||
|
@ -139,7 +139,7 @@ RList *r_bin_mz_get_segments(const struct r_bin_mz_obj_t *bin) {
|
||||
section->add = true;
|
||||
section_number++;
|
||||
}
|
||||
section = r_list_get_top (seg_list);
|
||||
section = r_list_last (seg_list);
|
||||
section->size = bin->load_module_size - section->vaddr;
|
||||
section->vsize = section->size;
|
||||
|
||||
|
@ -88,7 +88,7 @@ RCFValueDict *r_cf_value_dict_parse (RBuffer *file_buf, ut64 offset, ut64 size,
|
||||
|
||||
switch (r) {
|
||||
case R_XML_ELEMSTART: {
|
||||
RCFParseState *state = (RCFParseState *)r_list_get_top (stack);
|
||||
RCFParseState *state = (RCFParseState *)r_list_last (stack);
|
||||
RCFParseState *next_state = NULL;
|
||||
|
||||
if (!strcmp (x->elem, "dict")) {
|
||||
@ -157,7 +157,7 @@ RCFValueDict *r_cf_value_dict_parse (RBuffer *file_buf, ut64 offset, ut64 size,
|
||||
}
|
||||
case R_XML_ELEMEND: {
|
||||
RCFParseState *state = (RCFParseState *)r_list_pop (stack);
|
||||
RCFParseState *next_state = (RCFParseState *)r_list_get_top (stack);
|
||||
RCFParseState *next_state = (RCFParseState *)r_list_last (stack);
|
||||
if (!state || !next_state) {
|
||||
goto beach;
|
||||
}
|
||||
@ -248,7 +248,7 @@ RCFValueDict *r_cf_value_dict_parse (RBuffer *file_buf, ut64 offset, ut64 size,
|
||||
break;
|
||||
}
|
||||
case R_XML_CONTENT: {
|
||||
RCFParseState *state = (RCFParseState *)r_list_get_top (stack);
|
||||
RCFParseState *state = (RCFParseState *)r_list_last (stack);
|
||||
if (state->phase == R_CF_STATE_IN_IGNORE) {
|
||||
break;
|
||||
}
|
||||
|
@ -782,7 +782,7 @@ R_API ut32 r_core_asm_bwdis_len(RCore* core, int* instr_len, ut64* start_addr, u
|
||||
*instr_len = 0;
|
||||
}
|
||||
if (hits && r_list_length (hits) > 0) {
|
||||
hit = r_list_get_bottom (hits);
|
||||
hit = r_list_first (hits);
|
||||
if (start_addr) {
|
||||
*start_addr = hit->addr;
|
||||
}
|
||||
|
@ -1387,7 +1387,7 @@ static int bin_source(RCore *r, PJ *pj, int mode) {
|
||||
ls_foreach (ls, iter, kv) {
|
||||
char *v = sdbkv_value (kv);
|
||||
RList *list = r_str_split_list (v, "|", 0);
|
||||
srcline = r_list_get_bottom (list);
|
||||
srcline = r_list_first (list);
|
||||
if (srcline) {
|
||||
if (!strstr (srcline, "0x")) {
|
||||
r_list_append (final_list, srcline);
|
||||
|
@ -4497,7 +4497,7 @@ static bool cmd_dcu(RCore *core, const char *input) {
|
||||
old_sp = cur_sp;
|
||||
prev_call = false;
|
||||
} else if (prev_ret) {
|
||||
RDebugFrame *head = r_list_get_bottom (core->dbg->call_frames);
|
||||
RDebugFrame *head = r_list_first (core->dbg->call_frames);
|
||||
if (head && head->addr != pc) {
|
||||
eprintf ("*");
|
||||
} else {
|
||||
|
@ -4903,7 +4903,7 @@ static void func_walk_blocks(RCore *core, RAnalFunction *f, char input, char typ
|
||||
if (!b) {
|
||||
if (r_list_length (f->bbs) >= 1) {
|
||||
ut32 fcn_size = r_anal_function_realsize (f);
|
||||
b = r_list_get_top (f->bbs);
|
||||
b = r_list_last (f->bbs);
|
||||
if (b->size > fcn_size) {
|
||||
b->size = fcn_size;
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ static bool __core_visual_gogo(RCore *core, int ch) {
|
||||
RIOBank *bank = r_io_bank_get (core->io, core->io->bank);
|
||||
if (bank && r_list_length (bank->maprefs)) {
|
||||
map = r_io_map_get (core->io,
|
||||
((RIOMapRef *)r_list_get_top (bank->maprefs))->id);
|
||||
((RIOMapRef *)r_list_last (bank->maprefs))->id);
|
||||
}
|
||||
}
|
||||
if (map) {
|
||||
@ -267,7 +267,7 @@ static bool __core_visual_gogo(RCore *core, int ch) {
|
||||
RIOBank *bank = r_io_bank_get (core->io, core->io->bank);
|
||||
if (bank && r_list_length (bank->maprefs)) {
|
||||
map = r_io_map_get (core->io,
|
||||
((RIOMapRef *)r_list_get_top (bank->maprefs))->id);
|
||||
((RIOMapRef *)r_list_last (bank->maprefs))->id);
|
||||
}
|
||||
}
|
||||
if (map) {
|
||||
@ -3760,7 +3760,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) {
|
||||
RIOBank *bank = r_io_bank_get (core->io, core->io->bank);
|
||||
if (bank && r_list_length (bank->maprefs)) {
|
||||
map = r_io_map_get (core->io,
|
||||
((RIOMapRef *)r_list_get_top (bank->maprefs))->id);
|
||||
((RIOMapRef *)r_list_last (bank->maprefs))->id);
|
||||
}
|
||||
if (map) {
|
||||
entry = r_io_map_from (map);
|
||||
|
@ -18,7 +18,7 @@ static const char *str_callback(RNum *user, ut64 off, int *ok) {
|
||||
}
|
||||
if (f) {
|
||||
const RList *list = r_flag_get_list (f, off);
|
||||
RFlagItem *item = r_list_get_top (list);
|
||||
RFlagItem *item = r_list_last (list);
|
||||
if (item) {
|
||||
if (ok) {
|
||||
*ok = true;
|
||||
@ -520,7 +520,7 @@ R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off) {
|
||||
off &= f->mask;
|
||||
}
|
||||
const RList *list = r_flag_get_list (f, off);
|
||||
return list? evalFlag (f, r_list_get_top (list)): NULL;
|
||||
return list? evalFlag (f, r_list_last (list)): NULL;
|
||||
}
|
||||
|
||||
/* return the first flag that matches an offset ordered by the order of
|
||||
@ -547,7 +547,7 @@ R_API RFlagItem *r_flag_get_by_spaces(RFlag *f, ut64 off, ...) {
|
||||
goto beach;
|
||||
}
|
||||
if (r_list_length (list) == 1) {
|
||||
ret = r_list_get_top (list);
|
||||
ret = r_list_last (list);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,8 @@ R_API void r_list_split_iter(RList *list, RListIter *iter);
|
||||
R_API int r_list_join(RList *list1, RList *list2);
|
||||
R_API void *r_list_get_n(const RList *list, int n);
|
||||
R_API int r_list_del_n(RList *list, int n);
|
||||
R_API void *r_list_get_top(const RList *list);
|
||||
R_API void *r_list_get_bottom(const RList *list);
|
||||
R_DEPRECATE R_API void *r_list_get_top(const RList *list);
|
||||
R_DEPRECATE R_API void *r_list_get_bottom(const RList *list);
|
||||
R_API void r_list_iter_to_top(RList *list, RListIter *iter);
|
||||
R_API void *r_list_pop(RList *list);
|
||||
R_API void *r_list_pop_head(RList *list);
|
||||
|
@ -125,7 +125,7 @@ R_IPI int search_rk(RSearch *srch, ut64 from, ut64 to) {
|
||||
return rk_many (srch, from, to);
|
||||
}
|
||||
|
||||
RSearchKeyword *kw = r_list_get_top (srch->kws);
|
||||
RSearchKeyword *kw = r_list_last (srch->kws);
|
||||
if (!kw) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -343,13 +343,13 @@ R_API int r_list_del_n(RList *list, int n) {
|
||||
return false;
|
||||
}
|
||||
|
||||
R_API void *r_list_get_top(const RList *list) {
|
||||
R_DEPRECATE R_API void *r_list_get_top(const RList *list) {
|
||||
r_return_val_if_fail (list, NULL);
|
||||
|
||||
return list->tail ? list->tail->data : NULL;
|
||||
}
|
||||
|
||||
R_API void *r_list_get_bottom(const RList *list) {
|
||||
R_DEPRECATE R_API void *r_list_get_bottom(const RList *list) {
|
||||
r_return_val_if_fail (list, NULL);
|
||||
|
||||
return list->head ? list->head->data : NULL;
|
||||
|
@ -232,9 +232,9 @@ bool test_r_anal_var() {
|
||||
vps = r_anal_var_deserialize ("ts-16:var_name:char **, tr48:var_name_b:size_t");
|
||||
mu_assert ("Failed r_anal_var_deserialize", vps && r_list_length (vps) == 2);
|
||||
|
||||
RAnalVarProt *vp = (RAnalVarProt *)r_list_get_bottom (vps);
|
||||
RAnalVarProt *vp = (RAnalVarProt *)r_list_first (vps);
|
||||
mu_assert ("Deserialize name[0]", !strcmp (vp->name, "var_name") && !strcmp (vp->type, "char **"));
|
||||
vp = (RAnalVarProt *)r_list_get_top (vps);
|
||||
vp = (RAnalVarProt *)r_list_last (vps);
|
||||
mu_assert ("Deserialize name[1]", !strcmp (vp->name, "var_name_b") && !strcmp (vp->type, "size_t"));
|
||||
|
||||
mu_assert ("r_anal_function_set_var_prot", r_anal_function_set_var_prot (fcn, vps));
|
||||
|
Loading…
Reference in New Issue
Block a user