Rename rz_list_first() / rz_list_last() to rz_list_first_val() / rz_list_last_val() (#5654)
This commit is contained in:
parent
f2f26b4466
commit
b96202ad48
44 changed files with 175 additions and 175 deletions
|
|
@ -283,7 +283,7 @@ static bool parse_asm_path(const char *path, RzStrConstPool *strpool, const char
|
|||
// arm_32
|
||||
// arm_cortex_32
|
||||
|
||||
char *arch = rz_list_last(file_tokens);
|
||||
char *arch = rz_list_last_val(file_tokens);
|
||||
if (!*arch) {
|
||||
rz_list_free(file_tokens);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ int main(int argc, char **argv) {
|
|||
|
||||
// Verify structure
|
||||
if (node->child_list && rz_list_length(node->child_list) > 0) {
|
||||
RzFlirtNode *child = rz_list_first(node->child_list);
|
||||
RzFlirtNode *child = rz_list_first_val(node->child_list);
|
||||
if (child && child->module_list && rz_list_length(child->module_list) > 0) {
|
||||
RzFlirtModule *module = rz_list_first(child->module_list);
|
||||
RzFlirtModule *module = rz_list_first_val(child->module_list);
|
||||
if (module && module->public_functions && rz_list_length(module->public_functions) > 0) {
|
||||
RzFlirtFunction *func = rz_list_first(module->public_functions);
|
||||
RzFlirtFunction *func = rz_list_first_val(module->public_functions);
|
||||
printf("\nFirst function in signature:\n");
|
||||
printf(" Name: %s\n", func->name);
|
||||
printf(" Offset: 0x%04x\n", func->offset);
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ RZ_API RzAnalysisBlock *rz_analysis_create_block(RzAnalysis *analysis, ut64 addr
|
|||
RZ_API void rz_analysis_delete_block(RzAnalysisBlock *bb) {
|
||||
rz_analysis_block_ref(bb);
|
||||
while (!rz_list_empty(bb->fcns)) {
|
||||
rz_analysis_function_remove_block(rz_list_first(bb->fcns), bb);
|
||||
rz_analysis_function_remove_block(rz_list_first_val(bb->fcns), bb);
|
||||
}
|
||||
rz_analysis_block_unref(bb);
|
||||
}
|
||||
|
|
@ -343,7 +343,7 @@ RZ_API bool rz_analysis_block_merge(RzAnalysisBlock *a, RzAnalysisBlock *b) {
|
|||
// Keep a ref to b, but remove all references of b from its functions
|
||||
rz_analysis_block_ref(b);
|
||||
while (!rz_list_empty(b->fcns)) {
|
||||
rz_analysis_function_remove_block(rz_list_first(b->fcns), b);
|
||||
rz_analysis_function_remove_block(rz_list_first_val(b->fcns), b);
|
||||
}
|
||||
|
||||
// merge ops from b into a
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ static bool fcn_takeover_block_recursive_followthrough_cb(RzAnalysisBlock *block
|
|||
RzAnalysisFunction *our_fcn = ctx->fcn;
|
||||
rz_analysis_block_ref(block);
|
||||
while (!rz_list_empty(block->fcns)) {
|
||||
RzAnalysisFunction *other_fcn = rz_list_first(block->fcns);
|
||||
RzAnalysisFunction *other_fcn = rz_list_first_val(block->fcns);
|
||||
if (other_fcn->addr == block->addr) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1722,7 +1722,7 @@ RZ_DEPRECATE RZ_API RzAnalysisFunction *rz_analysis_get_fcn_in(RzAnalysis *analy
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ret = rz_list_first(list);
|
||||
ret = rz_list_first_val(list);
|
||||
}
|
||||
}
|
||||
rz_list_free(list);
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ RzList /*<char *>*/ *v850_tokenize(const char *assembly, size_t length) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
buf = rz_list_first(tokens);
|
||||
buf = rz_list_first_val(tokens);
|
||||
for (i = 0; i < RZ_ARRAY_SIZE(v850_short_op); ++i) {
|
||||
if (!strcmp(buf, v850_short_op[i])) {
|
||||
rz_list_insert(tokens, 1, rz_str_dup("0"));
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ RzList /*<char *>*/ *z80_tokenize(const char *assembly, size_t length) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!strcmp((char *)rz_list_first(tokens), "call") && rz_list_length(tokens) == 3) {
|
||||
if (!strcmp((char *)rz_list_first_val(tokens), "call") && rz_list_length(tokens) == 3) {
|
||||
void *arg1 = rz_list_get_n(tokens, 1);
|
||||
void *arg2 = rz_list_get_n(tokens, 2);
|
||||
rz_list_set_n(tokens, 1, arg2);
|
||||
|
|
|
|||
|
|
@ -529,7 +529,7 @@ static void *analysis_match_one_function(SharedContext *shared) {
|
|||
ut32 size_a = 0, size_b = 0;
|
||||
ut8 *buf_a = NULL, *buf_b = NULL;
|
||||
|
||||
fcn_b = rz_list_first(shared->list_b);
|
||||
fcn_b = rz_list_first_val(shared->list_b);
|
||||
if (!shared_context_alloc_a(shared, fcn_b, &buf_b, &size_b)) {
|
||||
RZ_LOG_ERROR("analysis_match: cannot allocate buffer for function %s (B)\n", fcn_b->name);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ RZ_API RZ_NULLABLE char *rz_analysis_function_var_expr_for_reg_access_at(RzAnaly
|
|||
// var found, create string
|
||||
RzList *paths = rz_type_path_by_offset(fcn->analysis->typedb, var->type, var_offset, 1);
|
||||
if (paths && !rz_list_empty(paths)) {
|
||||
RzTypePath *path = rz_list_first(paths);
|
||||
RzTypePath *path = rz_list_first_val(paths);
|
||||
char *r = rz_str_newf("%s%s", var->name, path->path);
|
||||
rz_list_free(paths);
|
||||
return r;
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ static RZ_BORROW RzBinSymbol *le_add_symbol(rz_bin_le_obj_t *bin, ut32 ordinal,
|
|||
if (rz_list_empty(bin->symbols)) {
|
||||
ordinal = 1;
|
||||
} else {
|
||||
ordinal = ((RzBinSymbol *)rz_list_last(bin->symbols))->ordinal + 1;
|
||||
ordinal = ((RzBinSymbol *)rz_list_last_val(bin->symbols))->ordinal + 1;
|
||||
}
|
||||
}
|
||||
if (!rz_list_append(bin->symbols, sym)) {
|
||||
|
|
|
|||
|
|
@ -2371,7 +2371,7 @@ static int walk_exports(struct MACH0_(obj_t) * bin, ExportsIterator iterator, vo
|
|||
rz_list_push(states, root);
|
||||
|
||||
do {
|
||||
TrieState *state = rz_list_last(states);
|
||||
TrieState *state = rz_list_last_val(states);
|
||||
p = state->node;
|
||||
ut64 len = read_uleb128(&p, end);
|
||||
if (len == UT64_MAX) {
|
||||
|
|
|
|||
|
|
@ -984,7 +984,7 @@ ut32 rz_bin_wasm_get_entrypoint(RzBinWasmObj *bin) {
|
|||
start = bin->g_start;
|
||||
} else if (!(secs = rz_bin_wasm_get_sections_by_id(bin->g_sections, RZ_BIN_WASM_SECTION_START))) {
|
||||
return 0;
|
||||
} else if (!(sec = (RzBinWasmSection *)rz_list_first(secs))) {
|
||||
} else if (!(sec = (RzBinWasmSection *)rz_list_first_val(secs))) {
|
||||
rz_list_free(secs);
|
||||
return 0;
|
||||
} else {
|
||||
|
|
@ -1019,7 +1019,7 @@ RzList /*<RzBinWasmImportEntry *>*/ *rz_bin_wasm_get_imports(RzBinWasmObj *bin)
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple import sections against spec
|
||||
if (!(import = (RzBinWasmSection *)rz_list_first(imports))) {
|
||||
if (!(import = (RzBinWasmSection *)rz_list_first_val(imports))) {
|
||||
rz_list_free(imports);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1042,7 +1042,7 @@ RzList /*<RzBinWasmExportEntry *>*/ *rz_bin_wasm_get_exports(RzBinWasmObj *bin)
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple export sections against spec
|
||||
if (!(export = (RzBinWasmSection *)rz_list_first(exports))) {
|
||||
if (!(export = (RzBinWasmSection *)rz_list_first_val(exports))) {
|
||||
rz_list_free(exports);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1065,7 +1065,7 @@ RzList /*<RzBinWasmTypeEntry *>*/ *rz_bin_wasm_get_types(RzBinWasmObj *bin) {
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple export sections against spec
|
||||
if (!(type = (RzBinWasmSection *)rz_list_first(types))) {
|
||||
if (!(type = (RzBinWasmSection *)rz_list_first_val(types))) {
|
||||
rz_list_free(types);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1088,7 +1088,7 @@ RzList /*<RzBinWasmTableEntry *>*/ *rz_bin_wasm_get_tables(RzBinWasmObj *bin) {
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple export sections against spec
|
||||
if (!(table = (RzBinWasmSection *)rz_list_first(tables))) {
|
||||
if (!(table = (RzBinWasmSection *)rz_list_first_val(tables))) {
|
||||
rz_list_free(tables);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1114,7 +1114,7 @@ RzList /*<RzBinWasmMemoryEntry *>*/ *rz_bin_wasm_get_memories(RzBinWasmObj *bin)
|
|||
}
|
||||
|
||||
// support for multiple export sections against spec
|
||||
if (!(memory = (RzBinWasmSection *)rz_list_first(memories))) {
|
||||
if (!(memory = (RzBinWasmSection *)rz_list_first_val(memories))) {
|
||||
rz_list_free(memories);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1138,7 +1138,7 @@ RzList /*<RzBinWasmGlobalEntry *>*/ *rz_bin_wasm_get_globals(RzBinWasmObj *bin)
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple export sections against spec
|
||||
if (!(global = (RzBinWasmSection *)rz_list_first(globals))) {
|
||||
if (!(global = (RzBinWasmSection *)rz_list_first_val(globals))) {
|
||||
rz_list_free(globals);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1161,7 +1161,7 @@ RzList /*<RzBinWasmElementEntry *>*/ *rz_bin_wasm_get_elements(RzBinWasmObj *bin
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple export sections against spec
|
||||
if (!(element = (RzBinWasmSection *)rz_list_first(elements))) {
|
||||
if (!(element = (RzBinWasmSection *)rz_list_first_val(elements))) {
|
||||
rz_list_free(elements);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1184,7 +1184,7 @@ RzList /*<RzBinWasmCodeEntry *>*/ *rz_bin_wasm_get_codes(RzBinWasmObj *bin) {
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple export sections against spec
|
||||
if (!(code = (RzBinWasmSection *)rz_list_first(codes))) {
|
||||
if (!(code = (RzBinWasmSection *)rz_list_first_val(codes))) {
|
||||
rz_list_free(codes);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1207,7 +1207,7 @@ RzList /*<RzBinWasmDataEntry *>*/ *rz_bin_wasm_get_datas(RzBinWasmObj *bin) {
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple export sections against spec
|
||||
if (!(data = (RzBinWasmSection *)rz_list_first(datas))) {
|
||||
if (!(data = (RzBinWasmSection *)rz_list_first_val(datas))) {
|
||||
rz_list_free(datas);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
@ -1229,7 +1229,7 @@ RzList /*<RzBinWasmCustomNameEntry *>*/ *rz_bin_wasm_get_custom_names(RzBinWasmO
|
|||
return rz_list_new();
|
||||
}
|
||||
// support for multiple "name" sections against spec
|
||||
if (!(cust = (RzBinWasmSection *)rz_list_first(customs)) || strncmp(cust->name, "name", 5)) {
|
||||
if (!(cust = (RzBinWasmSection *)rz_list_first_val(customs)) || strncmp(cust->name, "name", 5)) {
|
||||
rz_list_free(customs);
|
||||
return rz_list_new();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ RZ_API RzCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut
|
|||
|
||||
switch (r) {
|
||||
case YXML_ELEMSTART: {
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last(stack);
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last_val(stack);
|
||||
RzCFParseState *next_state = NULL;
|
||||
|
||||
if (!strcmp(x.elem, "dict")) {
|
||||
|
|
@ -189,7 +189,7 @@ RZ_API RzCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut
|
|||
}
|
||||
case YXML_ELEMEND: {
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_pop(stack);
|
||||
RzCFParseState *next_state = (RzCFParseState *)rz_list_last(stack);
|
||||
RzCFParseState *next_state = (RzCFParseState *)rz_list_last_val(stack);
|
||||
if (!state || !next_state) {
|
||||
goto beach;
|
||||
}
|
||||
|
|
@ -317,7 +317,7 @@ RZ_API RzCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut
|
|||
break;
|
||||
}
|
||||
case YXML_CONTENT: {
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last(stack);
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last_val(stack);
|
||||
if (state->phase == RZ_CF_STATE_IN_IGNORE) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ RZ_API RzCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut
|
|||
}
|
||||
case YXML_ATTRSTART: {
|
||||
if (idlist) {
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last(stack);
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last_val(stack);
|
||||
if (state->phase != RZ_CF_STATE_IN_DICT && state->phase != RZ_CF_STATE_IN_ARRAY && state->phase != RZ_CF_STATE_IN_SCALAR) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -356,7 +356,7 @@ RZ_API RzCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut
|
|||
}
|
||||
case YXML_ATTRVAL: {
|
||||
if (idlist) {
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last(stack);
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last_val(stack);
|
||||
if (state->phase != RZ_CF_STATE_IN_ATTR_ID && state->phase != RZ_CF_STATE_IN_ATTR_IDREF) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -366,12 +366,12 @@ RZ_API RzCFValueDict *rz_cf_value_dict_parse(RzBuffer *file_buf, ut64 offset, ut
|
|||
}
|
||||
case YXML_ATTREND: {
|
||||
if (idlist) {
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last(stack);
|
||||
RzCFParseState *state = (RzCFParseState *)rz_list_last_val(stack);
|
||||
if (state->phase != RZ_CF_STATE_IN_ATTR_ID && state->phase != RZ_CF_STATE_IN_ATTR_IDREF) {
|
||||
break;
|
||||
}
|
||||
rz_list_pop(stack);
|
||||
RzCFParseState *next_state = (RzCFParseState *)rz_list_last(stack);
|
||||
RzCFParseState *next_state = (RzCFParseState *)rz_list_last_val(stack);
|
||||
next_state->id = (ut32)rz_num_get(NULL, content);
|
||||
next_state->idstate = state->phase == RZ_CF_STATE_IN_ATTR_ID ? RZ_CF_ID_STATE_SET : RZ_CF_ID_STATE_REF;
|
||||
RZ_FREE(content);
|
||||
|
|
|
|||
|
|
@ -1722,7 +1722,7 @@ static void fix_back_edge_dummy_nodes(RzAGraph *g, RzANode *from, RzANode *to) {
|
|||
}
|
||||
tmp = v;
|
||||
while (tmp->is_dummy) {
|
||||
tmp = (RzANode *)(((RzGraphNode *)rz_list_first(tmp->gnode->out_nodes))->data);
|
||||
tmp = (RzANode *)(((RzGraphNode *)rz_list_first_val(tmp->gnode->out_nodes))->data);
|
||||
}
|
||||
if (tmp->gnode->idx == from->gnode->idx) {
|
||||
break;
|
||||
|
|
@ -1733,7 +1733,7 @@ static void fix_back_edge_dummy_nodes(RzAGraph *g, RzANode *from, RzANode *to) {
|
|||
tmp = v;
|
||||
while (tmp->gnode->idx != from->gnode->idx) {
|
||||
v = tmp;
|
||||
tmp = (RzANode *)(((RzGraphNode *)rz_list_first(v->gnode->out_nodes))->data);
|
||||
tmp = (RzANode *)(((RzGraphNode *)rz_list_first_val(v->gnode->out_nodes))->data);
|
||||
|
||||
i = 0;
|
||||
while (v->gnode->idx != g->layers[v->layer].nodes[i]->idx) {
|
||||
|
|
@ -1760,7 +1760,7 @@ static int get_edge_number(const RzAGraph *g, RzANode *src, RzANode *dst, bool o
|
|||
RzANode *v;
|
||||
|
||||
if (outgoing && src->is_dummy) {
|
||||
RzANode *in = (RzANode *)(((RzGraphNode *)rz_list_first((src->gnode)->in_nodes))->data);
|
||||
RzANode *in = (RzANode *)(((RzGraphNode *)rz_list_first_val((src->gnode)->in_nodes))->data);
|
||||
cur_nth = get_edge_number(g, in, src, outgoing);
|
||||
} else {
|
||||
const RzList *neighbours = outgoing
|
||||
|
|
@ -2947,9 +2947,9 @@ static void agraph_print_edges(RzAGraph *g) {
|
|||
|
||||
bool parent_many = false;
|
||||
if (a->is_dummy) {
|
||||
RzANode *in = (RzANode *)(((RzGraphNode *)rz_list_first(ga->in_nodes))->data);
|
||||
RzANode *in = (RzANode *)(((RzGraphNode *)rz_list_first_val(ga->in_nodes))->data);
|
||||
while (in && in->is_dummy) {
|
||||
in = (RzANode *)(((RzGraphNode *)rz_list_first((in->gnode)->in_nodes))->data);
|
||||
in = (RzANode *)(((RzGraphNode *)rz_list_first_val((in->gnode)->in_nodes))->data);
|
||||
}
|
||||
if (in && in->gnode) {
|
||||
parent_many = rz_list_length(in->gnode->out_nodes) > 2;
|
||||
|
|
@ -3867,7 +3867,7 @@ RZ_API void rz_agraph_foreach_edge(RzAGraph *g, RAEdgeCallback cb, void *user) {
|
|||
|
||||
RZ_API RzANode *rz_agraph_get_first_node(const RzAGraph *g) {
|
||||
const RzList *l = rz_graph_get_nodes(g->graph);
|
||||
RzGraphNode *rgn = rz_list_first(l);
|
||||
RzGraphNode *rgn = rz_list_first_val(l);
|
||||
return get_anode(rgn);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static bool find_string_at(RzCore *core, RzBinObject *bobj, ut64 pointer, char *
|
|||
|
||||
rz_io_pread_at(core->io, pointer, buffer, sizeof(buffer));
|
||||
if (rz_scan_strings_raw(buffer, strings, &scan_opt, 0, sizeof(buffer), strenc) < 1 ||
|
||||
!(detected = rz_list_first(strings)) ||
|
||||
!(detected = rz_list_first_val(strings)) ||
|
||||
// ignore any address that is not address 0
|
||||
// because we only want strings starting at 0
|
||||
detected->addr) {
|
||||
|
|
@ -497,7 +497,7 @@ RZ_IPI void rz_core_analysis_bbs_info_print(RzCore *core, RzAnalysisFunction *fc
|
|||
RZ_IPI void rz_core_analysis_bb_info_print(RzCore *core, RzAnalysisBlock *bb, ut64 addr, RzCmdStateOutput *state) {
|
||||
rz_return_if_fail(core && bb && state);
|
||||
rz_cmd_state_output_set_columnsf(state, "xdxx", "addr", "size", "jump", "fail");
|
||||
RzAnalysisFunction *fcn = rz_list_first(bb->fcns);
|
||||
RzAnalysisFunction *fcn = rz_list_first_val(bb->fcns);
|
||||
bb_info_print(core, fcn, bb, addr, state->mode, state->d.pj, state->d.t);
|
||||
}
|
||||
|
||||
|
|
@ -767,7 +767,7 @@ static void autoname_imp_trampoline(RzCore *core, RzAnalysisFunction *fcn) {
|
|||
if (rz_pvector_len(fcn->bbs) == 1 && ((RzAnalysisBlock *)rz_pvector_head(fcn->bbs))->ninstr == 1) {
|
||||
RzList *xrefs = rz_analysis_function_get_xrefs_from(fcn);
|
||||
if (xrefs && rz_list_length(xrefs) == 1) {
|
||||
RzAnalysisXRef *xref = rz_list_first(xrefs);
|
||||
RzAnalysisXRef *xref = rz_list_first_val(xrefs);
|
||||
if (xref->type != RZ_ANALYSIS_XREF_TYPE_CALL) { /* Some fcns don't return */
|
||||
RzFlagItem *flg = rz_flag_get_i(core->flags, xref->to);
|
||||
if (flg && rz_str_startswith(flg->name, "sym.imp.")) {
|
||||
|
|
|
|||
|
|
@ -1011,7 +1011,7 @@ RZ_API ut32 rz_core_asm_bwdis_len(RzCore *core, int *instr_len, ut64 *start_addr
|
|||
*instr_len = 0;
|
||||
}
|
||||
if (hits && rz_list_length(hits) > 0) {
|
||||
hit = rz_list_first(hits);
|
||||
hit = rz_list_first_val(hits);
|
||||
if (start_addr) {
|
||||
*start_addr = hit->addr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ RZ_API bool rz_core_debug_continue_until(RzCore *core, ut64 addr) {
|
|||
old_sp = cur_sp;
|
||||
prev_call = false;
|
||||
} else if (prev_ret) {
|
||||
RzDebugFrame *head = rz_list_first(core->dbg->call_frames);
|
||||
RzDebugFrame *head = rz_list_first_val(core->dbg->call_frames);
|
||||
if (head && head->addr != pc) {
|
||||
RZ_LOG_DEBUG("*");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1161,7 +1161,7 @@ RZ_API RZ_BORROW RzCoreFile *rz_core_file_open_many(RZ_NONNULL RzCore *r, RZ_NUL
|
|||
}
|
||||
|
||||
rz_list_free(list_fds);
|
||||
return rz_list_first(r->files);
|
||||
return rz_list_first_val(r->files);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1526,7 +1526,7 @@ RZ_API bool rz_core_file_close_fd(RzCore *core, int fd) {
|
|||
RzListIter *iter;
|
||||
if (fd == -1) {
|
||||
while (!rz_list_empty(core->files)) {
|
||||
rz_core_file_close(rz_list_first(core->files));
|
||||
rz_core_file_close(rz_list_first_val(core->files));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1230,7 +1230,7 @@ static inline bool get_next_i(IterCtx *ctx, size_t *next_i) {
|
|||
rz_reg_arena_push(ctx->fcn->analysis->reg);
|
||||
RzListIter *bbit = NULL;
|
||||
if (bb->switch_op) {
|
||||
RzAnalysisCaseOp *cop = rz_list_first(bb->switch_op->cases);
|
||||
RzAnalysisCaseOp *cop = rz_list_first_val(bb->switch_op->cases);
|
||||
bbit = rz_list_find(ctx->bbl, &cop->jump, (RzListComparator)find_bb, NULL);
|
||||
if (bbit) {
|
||||
rz_list_push(ctx->switch_path, bb->switch_op->cases->head);
|
||||
|
|
@ -1242,7 +1242,7 @@ static inline bool get_next_i(IterCtx *ctx, size_t *next_i) {
|
|||
}
|
||||
}
|
||||
if (!bbit) {
|
||||
RzListIter *cop_it = rz_list_last(ctx->switch_path);
|
||||
RzListIter *cop_it = rz_list_last_val(ctx->switch_path);
|
||||
RzAnalysisBlock *prev_bb = NULL;
|
||||
do {
|
||||
rz_reg_arena_pop(ctx->fcn->analysis->reg);
|
||||
|
|
@ -1266,7 +1266,7 @@ static inline bool get_next_i(IterCtx *ctx, size_t *next_i) {
|
|||
}
|
||||
if (cop_it && !rz_list_iter_has_next(cop_it)) {
|
||||
rz_list_pop(ctx->switch_path);
|
||||
cop_it = rz_list_last(ctx->switch_path);
|
||||
cop_it = rz_list_last_val(ctx->switch_path);
|
||||
}
|
||||
} while (!bbit && !rz_list_empty(ctx->path));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2093,7 +2093,7 @@ DEFINE_HANDLE_TS_FCN_AND_SYMBOL(iter_instrs_stmt) {
|
|||
RZ_LOG_ERROR("core: No basic block contains current address\n");
|
||||
return RZ_CMD_STATUS_INVALID;
|
||||
}
|
||||
RzAnalysisBlock *bb = rz_list_last(bbl);
|
||||
RzAnalysisBlock *bb = rz_list_last_val(bbl);
|
||||
rz_analysis_block_ref(bb);
|
||||
rz_list_free(bbl);
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ static RzAnalysisFunction *analysis_get_function_in(RzAnalysis *analysis, ut64 o
|
|||
offset);
|
||||
goto exit;
|
||||
}
|
||||
fcn = rz_list_first(list);
|
||||
fcn = rz_list_first_val(list);
|
||||
if (!fcn) {
|
||||
rz_warn_if_reached();
|
||||
}
|
||||
|
|
@ -1772,7 +1772,7 @@ RZ_IPI RzCmdStatus rz_analysis_function_blocks_del_handler(RzCore *core, int arg
|
|||
RZ_LOG_ERROR("core: Cannot find basic block\n");
|
||||
return RZ_CMD_STATUS_ERROR;
|
||||
}
|
||||
RzAnalysisFunction *fcn = rz_list_first(b->fcns);
|
||||
RzAnalysisFunction *fcn = rz_list_first_val(b->fcns);
|
||||
rz_analysis_function_remove_block(fcn, b);
|
||||
return RZ_CMD_STATUS_OK;
|
||||
}
|
||||
|
|
@ -1796,7 +1796,7 @@ RZ_IPI RzCmdStatus rz_analysis_function_blocks_edge_handler(RzCore *core, int ar
|
|||
rz_list_free(blocks);
|
||||
return RZ_CMD_STATUS_ERROR;
|
||||
}
|
||||
rz_analysis_block_add_switch_case(rz_list_first(blocks), switch_addr, 0, case_addr);
|
||||
rz_analysis_block_add_switch_case(rz_list_first_val(blocks), switch_addr, 0, case_addr);
|
||||
rz_list_free(blocks);
|
||||
return RZ_CMD_STATUS_OK;
|
||||
}
|
||||
|
|
@ -1809,7 +1809,7 @@ RZ_IPI RzCmdStatus rz_analysis_function_blocks_switch_type_handler(RzCore *core,
|
|||
rz_list_free(blocks);
|
||||
return RZ_CMD_STATUS_ERROR;
|
||||
}
|
||||
RzAnalysisBlock *b = rz_list_first(blocks);
|
||||
RzAnalysisBlock *b = rz_list_first_val(blocks);
|
||||
if (!b->switch_op) {
|
||||
RZ_LOG_ERROR("Block does not have a switch case\n");
|
||||
return RZ_CMD_STATUS_INVALID;
|
||||
|
|
@ -4220,12 +4220,12 @@ RZ_IPI RzCmdStatus rz_analysis_function_analyze_jmptable_handler(RzCore *core, i
|
|||
if (!blocks) {
|
||||
return RZ_CMD_STATUS_ERROR;
|
||||
}
|
||||
RzAnalysisBlock *block = rz_list_first(blocks);
|
||||
RzAnalysisBlock *block = rz_list_first_val(blocks);
|
||||
if (block && !rz_list_empty(block->fcns)) {
|
||||
ut64 table = rz_num_math(core->num, argv[1]);
|
||||
ut64 elements = rz_num_math(core->num, argv[2]);
|
||||
RzStackAddr sp = rz_analysis_block_get_sp_at(block, core->offset);
|
||||
rz_analysis_jmptbl(core->analysis, rz_list_first(block->fcns), block, core->offset, table, elements, UT64_MAX, sp);
|
||||
rz_analysis_jmptbl(core->analysis, rz_list_first_val(block->fcns), block, core->offset, table, elements, UT64_MAX, sp);
|
||||
} else {
|
||||
RZ_LOG_ERROR("No function defined here\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1975,7 +1975,7 @@ RZ_IPI RzCmdStatus rz_print_first_string_current_block_handler(RzCore *core, int
|
|||
return RZ_CMD_STATUS_ERROR;
|
||||
}
|
||||
|
||||
detected = rz_list_first(found);
|
||||
detected = rz_list_first_val(found);
|
||||
if (detected) {
|
||||
rz_cons_memcat(detected->string, detected->size);
|
||||
rz_cons_newline();
|
||||
|
|
@ -4928,7 +4928,7 @@ static CoreBlockRange *calculate_blocks_range(RzCore *core, ut64 from, ut64 to,
|
|||
free(brange);
|
||||
return NULL;
|
||||
}
|
||||
RzIOMap *map = rz_list_first(boundaries);
|
||||
RzIOMap *map = rz_list_first_val(boundaries);
|
||||
if (map) {
|
||||
brange->from = map->itv.addr;
|
||||
RzIOMap *m;
|
||||
|
|
|
|||
|
|
@ -954,7 +954,7 @@ static void do_string_search(RzCore *core, RzInterval search_itv, struct search_
|
|||
break;
|
||||
}
|
||||
if (param->outmode != RZ_MODE_JSON) {
|
||||
RzSearchKeyword *kw = rz_list_first(core->search->kws);
|
||||
RzSearchKeyword *kw = rz_list_first_val(core->search->kws);
|
||||
eprintf("Searching");
|
||||
if (!param->regex_search) {
|
||||
int lenstr = kw ? kw->keyword_length : 0;
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ static bool meta_string_guess_add(RzCore *core, ut64 addr, size_t limit, char **
|
|||
free(name);
|
||||
return false;
|
||||
}
|
||||
*ds = rz_list_first(str_list);
|
||||
*ds = rz_list_first_val(str_list);
|
||||
rz_list_free(str_list);
|
||||
rz_str_ncpy(name, (*ds)->string, limit);
|
||||
name[limit] = '\0';
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ static void set_offset_hint(RzCore *core, RzAnalysisOp *op, RZ_BORROW RzTypePath
|
|||
// possible member offset and the global variable at the laddr
|
||||
RzList *paths = rz_analysis_type_paths_by_address(core->analysis, laddr + offimm);
|
||||
if (paths && rz_list_length(paths)) {
|
||||
RzTypePathTuple *match = rz_list_last(paths);
|
||||
RzTypePathTuple *match = rz_list_last_val(paths);
|
||||
rz_analysis_hint_set_offset(core->analysis, at, match->path->path);
|
||||
}
|
||||
rz_list_free(paths);
|
||||
|
|
@ -697,7 +697,7 @@ static void resolve_global_var_types(RzCore *core, ut64 at, struct GVTAnalysisCo
|
|||
|
||||
// TODO: Handle register based arg for types offset/path propagation
|
||||
if (vtpaths && rz_list_length(vtpaths) && ctx->var && ctx->var->storage.type == RZ_ANALYSIS_VAR_STORAGE_STACK) {
|
||||
RzTypePathTuple *vtpath = rz_list_last(vtpaths);
|
||||
RzTypePathTuple *vtpath = rz_list_last_val(vtpaths);
|
||||
// if a var addr matches with compound type, change its type and name
|
||||
// var int local_e0h --> var struct foo
|
||||
if (!*resolved) {
|
||||
|
|
@ -710,10 +710,10 @@ static void resolve_global_var_types(RzCore *core, ut64 at, struct GVTAnalysisCo
|
|||
vtpath->root = NULL;
|
||||
}
|
||||
} else if (stpaths && rz_list_length(stpaths)) {
|
||||
RzTypePathTuple *stpath = rz_list_last(stpaths);
|
||||
RzTypePathTuple *stpath = rz_list_last_val(stpaths);
|
||||
set_offset_hint(core, ctx->aop, stpath, ctx->src_addr, at - ret, ctx->src_imm);
|
||||
} else if (dtpaths && rz_list_length(dtpaths)) {
|
||||
RzTypePathTuple *dtpath = rz_list_last(dtpaths);
|
||||
RzTypePathTuple *dtpath = rz_list_last_val(dtpaths);
|
||||
set_offset_hint(core, ctx->aop, dtpath, ctx->dst_addr, at - ret, ctx->dst_imm);
|
||||
}
|
||||
rz_list_free(stpaths);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ static RzList /*<RzAnalysisFunction *>*/ *list_new_fcns(RzCore *core) {
|
|||
rz_list_foreach (list, it, fcn) {
|
||||
char *res = strstr(fcn->name, "sym.imp.operator_new");
|
||||
if (res != NULL) {
|
||||
rz_list_push(ret_list, it->elem);
|
||||
rz_list_push(ret_list, it->val);
|
||||
}
|
||||
}
|
||||
return ret_list;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ static bool rz_rop_print_table_mode(const RzCore *core, const RzCoreAsmHit *hit,
|
|||
rz_asm_op_free(asmop);
|
||||
return false;
|
||||
}
|
||||
const ut64 addr_last = ((RzCoreAsmHit *)rz_list_last(hitlist))->addr;
|
||||
const ut64 addr_last = ((RzCoreAsmHit *)rz_list_last_val(hitlist))->addr;
|
||||
if (addr_last != hit->addr) {
|
||||
*asmop_str = rz_str_append(*asmop_str, "; ");
|
||||
}
|
||||
|
|
@ -975,7 +975,7 @@ static bool print_rop(const RzCore *core, RzList /*<RzCoreAsmHit *>*/ *hitlist,
|
|||
return false;
|
||||
}
|
||||
rz_cmd_state_output_set_columnsf(state, "XXs", "addr", "bytes", "disasm");
|
||||
RzCoreAsmHit *hit = (RzCoreAsmHit *)rz_list_first(hitlist);
|
||||
RzCoreAsmHit *hit = (RzCoreAsmHit *)rz_list_first_val(hitlist);
|
||||
if (!hit) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1252,11 +1252,11 @@ static RzRopGadgetInfo *perform_gadget_analysis(RzCore *core, const ut8 crop, co
|
|||
if (!core->analysis->ht_rop_semantics) {
|
||||
core->analysis->ht_rop_semantics = ht_up_new(NULL, (HtUPFreeValue)rz_core_rop_gadget_info_free);
|
||||
}
|
||||
const RzCoreAsmHit *hit_last = (RzCoreAsmHit *)rz_list_last(hitlist);
|
||||
const RzCoreAsmHit *hit_last = (RzCoreAsmHit *)rz_list_last_val(hitlist);
|
||||
if (!is_ret_gadget(core, hit_last, crop)) {
|
||||
return rop_gadget_info;
|
||||
}
|
||||
const ut64 addr_start = ((RzCoreAsmHit *)rz_list_first(hitlist))->addr;
|
||||
const ut64 addr_start = ((RzCoreAsmHit *)rz_list_first_val(hitlist))->addr;
|
||||
rop_gadget_info = ht_up_find(core->analysis->ht_rop_semantics, addr_start, NULL);
|
||||
if (rop_gadget_info) {
|
||||
return rop_gadget_info;
|
||||
|
|
|
|||
|
|
@ -1770,7 +1770,7 @@ RZ_API void rz_debug_switch_to_first_thread(RZ_NONNULL RzDebug *debug) {
|
|||
rz_return_if_fail(debug);
|
||||
RzList *threads = rz_debug_pids(debug, debug->pid);
|
||||
if (rz_list_length(threads) > 0) {
|
||||
RzDebugPid *th = rz_list_first(threads);
|
||||
RzDebugPid *th = rz_list_first_val(threads);
|
||||
rz_debug_select(debug, debug->pid, th->pid);
|
||||
}
|
||||
rz_list_free(threads);
|
||||
|
|
|
|||
|
|
@ -809,7 +809,7 @@ static void add_library(DWORD pid, LPVOID lpBaseOfDll, HANDLE hFile, char *dllna
|
|||
}
|
||||
|
||||
static void *last_library(void) {
|
||||
return lib_list ? rz_list_last(lib_list) : NULL;
|
||||
return lib_list ? rz_list_last_val(lib_list) : NULL;
|
||||
}
|
||||
|
||||
static bool breaked = false;
|
||||
|
|
|
|||
|
|
@ -750,12 +750,12 @@ RZ_API RZ_OWN RzList /*<RzList<RzDiffOp *> *>*/ *rz_diff_opcodes_grouped_new(RZ_
|
|||
}
|
||||
}
|
||||
|
||||
op = rz_list_first(opcodes);
|
||||
op = rz_list_first_val(opcodes);
|
||||
if (op->type == RZ_DIFF_OP_EQUAL) {
|
||||
opcode_set(op, op->type, RZ_MAX(op->a_beg, op->a_end - n_groups), op->a_end, RZ_MAX(op->b_beg, op->b_end - n_groups), op->b_end);
|
||||
}
|
||||
|
||||
op = rz_list_last(opcodes);
|
||||
op = rz_list_last_val(opcodes);
|
||||
if (op->type == RZ_DIFF_OP_EQUAL) {
|
||||
opcode_set(op, op->type, op->a_beg, RZ_MIN(op->a_end, op->a_beg + n_groups), op->b_beg, RZ_MIN(op->b_end, op->b_beg + n_groups));
|
||||
}
|
||||
|
|
@ -808,7 +808,7 @@ RZ_API RZ_OWN RzList /*<RzList<RzDiffOp *> *>*/ *rz_diff_opcodes_grouped_new(RZ_
|
|||
}
|
||||
}
|
||||
|
||||
op = rz_list_first(opcodes);
|
||||
op = rz_list_first_val(opcodes);
|
||||
if (!(rz_list_length(opcodes) == 1 && op->type == RZ_DIFF_OP_EQUAL)) {
|
||||
if (!rz_list_append(groups, group)) {
|
||||
RZ_LOG_ERROR("rz_diff_opcodes_grouped_new: cannot append group into groups\n");
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ static inline void diff_unified_append_ranges(RzList /*<RzDiffOp *>*/ *opcodes,
|
|||
const char *color_beg = color ? Color_RANGE : "";
|
||||
const char *color_end = color ? Color_RESET : "";
|
||||
|
||||
RzDiffOp *first = rz_list_first(opcodes);
|
||||
RzDiffOp *last = rz_list_last(opcodes);
|
||||
RzDiffOp *first = rz_list_first_val(opcodes);
|
||||
RzDiffOp *last = rz_list_last_val(opcodes);
|
||||
st32 a_len = last->a_end - first->a_beg;
|
||||
st32 b_len = last->b_end - first->b_beg;
|
||||
|
||||
|
|
@ -51,8 +51,8 @@ static inline void diff_unified_append_ranges(RzList /*<RzDiffOp *>*/ *opcodes,
|
|||
}
|
||||
|
||||
static inline void diff_unified_json_ranges(RzList /*<RzDiffOp *>*/ *opcodes, PJ *pj) {
|
||||
RzDiffOp *first = rz_list_first(opcodes);
|
||||
RzDiffOp *last = rz_list_last(opcodes);
|
||||
RzDiffOp *first = rz_list_first_val(opcodes);
|
||||
RzDiffOp *last = rz_list_last_val(opcodes);
|
||||
st32 a_len = last->a_end - first->a_beg;
|
||||
st32 b_len = last->b_end - first->b_beg;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ static const char *str_callback(RzNum *user, ut64 off, int *ok) {
|
|||
}
|
||||
if (f) {
|
||||
const RzList *list = rz_flag_get_list(f, off);
|
||||
RzFlagItem *item = rz_list_last(list);
|
||||
RzFlagItem *item = rz_list_last_val(list);
|
||||
if (item) {
|
||||
if (ok) {
|
||||
*ok = true;
|
||||
|
|
@ -358,7 +358,7 @@ RZ_API bool rz_flag_reset_obj_flags(RZ_NONNULL RZ_BORROW RzFlag *flags, RZ_NULLA
|
|||
RZ_API RzFlagItem *rz_flag_get_i(RzFlag *f, ut64 off) {
|
||||
rz_return_val_if_fail(f, NULL);
|
||||
const RzList *list = rz_flag_get_list(f, off);
|
||||
return list ? evalFlag(f, rz_list_last(list)) : NULL;
|
||||
return list ? evalFlag(f, rz_list_last_val(list)) : NULL;
|
||||
}
|
||||
|
||||
/* return the first flag that matches an offset ordered by the order of
|
||||
|
|
@ -382,7 +382,7 @@ RZ_API RzFlagItem *rz_flag_get_by_spaces(RzFlag *f, ut64 off, ...) {
|
|||
goto beach;
|
||||
}
|
||||
if (rz_list_length(list) == 1) {
|
||||
ret = rz_list_last(list);
|
||||
ret = rz_list_last_val(list);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -417,13 +417,13 @@ double rz_ssdeep_compare(const char *hash_a, const char *hash_b) {
|
|||
goto end;
|
||||
}
|
||||
|
||||
block_a = strtol(rz_list_first(token_a), NULL, 10);
|
||||
block_a = strtol(rz_list_first_val(token_a), NULL, 10);
|
||||
digest_a0 = remove_triplets(rz_list_get_n(token_a, 1));
|
||||
digest_a1 = remove_triplets(rz_list_last(token_a));
|
||||
digest_a1 = remove_triplets(rz_list_last_val(token_a));
|
||||
|
||||
block_b = strtol(rz_list_first(token_b), NULL, 10);
|
||||
block_b = strtol(rz_list_first_val(token_b), NULL, 10);
|
||||
digest_b0 = remove_triplets(rz_list_get_n(token_b, 1));
|
||||
digest_b1 = remove_triplets(rz_list_last(token_b));
|
||||
digest_b1 = remove_triplets(rz_list_last_val(token_b));
|
||||
|
||||
if (!block_a || !block_b || !digest_a0 || !digest_a1 || !digest_b0 || !digest_b1) {
|
||||
RZ_LOG_ERROR("diff: the expected hashes are not in ssdeep format\n");
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ typedef void (*RzListFree)(void *ptr);
|
|||
typedef struct rz_list_iter_t RzListIter;
|
||||
|
||||
struct rz_list_iter_t {
|
||||
void *elem;
|
||||
void *val;
|
||||
RzListIter *next;
|
||||
RzListIter *prev;
|
||||
};
|
||||
|
|
@ -31,32 +31,32 @@ typedef int (*RzListComparator)(const void *value, const void *list_data, void *
|
|||
|
||||
#ifdef RZ_API
|
||||
|
||||
#define rz_list_foreach(list, it, pos) \
|
||||
#define rz_list_foreach(list, it, var) \
|
||||
if (list) \
|
||||
for (it = list->head; it && (pos = it->elem, 1); it = it->next)
|
||||
#define rz_list_foreach_enum(list, it, pos, i) \
|
||||
for (it = list->head; it && (var = it->val, 1); it = it->next)
|
||||
#define rz_list_foreach_enum(list, it, var, i) \
|
||||
if (list) \
|
||||
for (it = list->head, i = 0; it && (pos = it->elem, 1); it = it->next, ++i)
|
||||
#define rz_list_foreach_iter(iter, it, pos) \
|
||||
for (it = iter; it && (pos = it->elem, 1); it = it->next)
|
||||
for (it = list->head, i = 0; it && (var = it->val, 1); it = it->next, ++i)
|
||||
#define rz_list_foreach_iter(iter, it, var) \
|
||||
for (it = iter; it && (var = it->val, 1); it = it->next)
|
||||
/* Safe when calling rz_list_delete() while iterating over the list. */
|
||||
#define rz_list_foreach_safe(list, it, tmp, pos) \
|
||||
#define rz_list_foreach_safe(list, it, tmp, var) \
|
||||
if (list) \
|
||||
for (it = list->head; it && (pos = it->elem, tmp = it->next, 1); it = tmp)
|
||||
#define rz_list_foreach_iter_safe(iter, it, tmp, pos) \
|
||||
for (it = iter; it && (pos = it->elem, tmp = it->next, 1); it = tmp)
|
||||
#define rz_list_foreach_prev(list, it, pos) \
|
||||
for (it = list->head; it && (var = it->val, tmp = it->next, 1); it = tmp)
|
||||
#define rz_list_foreach_iter_safe(iter, it, tmp, var) \
|
||||
for (it = iter; it && (var = it->val, tmp = it->next, 1); it = tmp)
|
||||
#define rz_list_foreach_prev(list, it, var) \
|
||||
if (list) \
|
||||
for (it = list->tail; it && (pos = it->elem, 1); it = it->prev)
|
||||
#define rz_list_foreach_prev_safe(list, it, tmp, pos) \
|
||||
for (it = list->tail; it && (pos = it->elem, tmp = it->prev, 1); it = tmp)
|
||||
for (it = list->tail; it && (var = it->val, 1); it = it->prev)
|
||||
#define rz_list_foreach_prev_safe(list, it, tmp, var) \
|
||||
for (it = list->tail; it && (var = it->val, tmp = it->prev, 1); it = tmp)
|
||||
|
||||
#define rz_list_empty(x) (!(x) || !(x)->length)
|
||||
#define rz_list_head(x) ((x) ? (x)->head : NULL)
|
||||
#define rz_list_tail(x) ((x) ? (x)->tail : NULL)
|
||||
|
||||
#define rz_list_iter_get(x) \
|
||||
x->elem; \
|
||||
x->val; \
|
||||
x = x->next
|
||||
#define rz_list_iter_next(x) (x ? 1 : 0)
|
||||
#define rz_list_iter_cur(x) x->prev
|
||||
|
|
@ -79,8 +79,8 @@ RZ_API RZ_BORROW RzListIter *rz_list_append(RZ_NONNULL RzList *list, RZ_NONNULL
|
|||
RZ_API RZ_BORROW RzListIter *rz_list_prepend(RZ_NONNULL RzList *list, RZ_NONNULL void *data);
|
||||
RZ_API RZ_BORROW RzListIter *rz_list_insert(RZ_NONNULL RzList *list, ut32 n, RZ_NONNULL void *data);
|
||||
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list);
|
||||
RZ_API RZ_BORROW void *rz_list_first(RZ_NONNULL const RzList *list);
|
||||
RZ_API RZ_BORROW void *rz_list_last(RZ_NONNULL const RzList *list);
|
||||
RZ_API RZ_BORROW void *rz_list_first_val(RZ_NONNULL const RzList *list);
|
||||
RZ_API RZ_BORROW void *rz_list_last_val(RZ_NONNULL const RzList *list);
|
||||
RZ_API RZ_BORROW RzListIter *rz_list_add_sorted(RZ_NONNULL RzList *list, RZ_NONNULL void *data, RZ_NONNULL RzListComparator cmp, void *user);
|
||||
RZ_API void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp, void *user);
|
||||
RZ_API void rz_list_merge_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp, void *user);
|
||||
|
|
|
|||
|
|
@ -1878,7 +1878,7 @@ static RzAnalysisFunction *find_best_matching_function(RzAnalysis *analysis_a, R
|
|||
|
||||
result = rz_analysis_match_functions(list_a, analysis_b->fcns, &opts);
|
||||
if (result && rz_list_length(result->matches) > 0) {
|
||||
pair = (RzAnalysisMatchPair *)rz_list_first(result->matches);
|
||||
pair = (RzAnalysisMatchPair *)rz_list_first_val(result->matches);
|
||||
match = (RzAnalysisFunction *)pair->pair_b;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ RZ_API void rz_reg_arena_pop(RzReg *reg) {
|
|||
}
|
||||
a = rz_list_pop(reg->regset[i].pool);
|
||||
rz_reg_arena_free(a);
|
||||
a = rz_list_last(reg->regset[i].pool);
|
||||
a = rz_list_last_val(reg->regset[i].pool);
|
||||
if (a) {
|
||||
reg->regset[i].arena = a;
|
||||
reg->regset[i].cur = rz_list_tail(reg->regset[i].pool);
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ static bool parse_reg_profile_str(RZ_OUT RzList /*<RzRegProfileAlias *>*/ *alias
|
|||
}
|
||||
if (rz_str_strchr(line, "#")) {
|
||||
RzList *line_and_cmt = rz_str_split_duplist_n_regex(line, "\\#", 0, true);
|
||||
char *raw_comment = rz_str_dup(rz_list_last(line_and_cmt));
|
||||
char *raw_comment = rz_str_dup(rz_list_last_val(line_and_cmt));
|
||||
if (!raw_comment) {
|
||||
RZ_LOG_WARN("Comment could not be split from register definition. Line: \"%s\"\n", line);
|
||||
continue;
|
||||
|
|
@ -299,7 +299,7 @@ static bool parse_reg_profile_str(RZ_OUT RzList /*<RzRegProfileAlias *>*/ *alias
|
|||
RZ_LOG_WARN("Could not prepend # to comment. Line: \"%s\".\n", line);
|
||||
continue;
|
||||
}
|
||||
toks = rz_str_split_duplist_n_regex(rz_list_first(line_and_cmt), "\\s+", 0, true);
|
||||
toks = rz_str_split_duplist_n_regex(rz_list_first_val(line_and_cmt), "\\s+", 0, true);
|
||||
rz_list_append(toks, comment);
|
||||
rz_list_free(line_and_cmt);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -237,8 +237,8 @@ static int flirt_compare_module(const RzFlirtModule *a, const RzFlirtModule *b)
|
|||
} else if (a->crc_length != b->crc_length) {
|
||||
return a->crc_length - b->crc_length;
|
||||
}
|
||||
const RzFlirtFunction *af = rz_list_first(a->public_functions);
|
||||
const RzFlirtFunction *bf = rz_list_first(b->public_functions);
|
||||
const RzFlirtFunction *af = rz_list_first_val(a->public_functions);
|
||||
const RzFlirtFunction *bf = rz_list_first_val(b->public_functions);
|
||||
return strcmp(af->name, bf->name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1545,7 +1545,7 @@ static bool flirt_write_node(RZ_NONNULL const RzFlirtNode *node, RZ_NONNULL RzBu
|
|||
// leaf
|
||||
ut8 flags = 0;
|
||||
|
||||
RzFlirtModule *last = rz_list_last(node->module_list);
|
||||
RzFlirtModule *last = rz_list_last_val(node->module_list);
|
||||
rz_list_foreach (node->module_list, it, module) {
|
||||
bool already_found = !(flags & IDASIG_PARSE_MORE_MODULES_WITH_SAME_CRC);
|
||||
if (last != module) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ RZ_API RZ_BORROW void *rz_list_iter_get_prev_data(RZ_NONNULL RzListIter *iter) {
|
|||
if (!p) {
|
||||
return NULL;
|
||||
}
|
||||
return p->elem;
|
||||
return p->val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -45,7 +45,7 @@ RZ_API RZ_BORROW void *rz_list_iter_get_next_data(RZ_NONNULL RzListIter *iter) {
|
|||
if (!n) {
|
||||
return NULL;
|
||||
}
|
||||
return n->elem;
|
||||
return n->val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +54,7 @@ RZ_API RZ_BORROW void *rz_list_iter_get_next_data(RZ_NONNULL RzListIter *iter) {
|
|||
**/
|
||||
RZ_API void *rz_list_iter_get_data(RZ_NONNULL RzListIter *iter) {
|
||||
rz_return_val_if_fail(iter, NULL);
|
||||
return iter->elem;
|
||||
return iter->val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +63,7 @@ RZ_API void *rz_list_iter_get_data(RZ_NONNULL RzListIter *iter) {
|
|||
**/
|
||||
RZ_API bool rz_list_iter_set_data(RZ_NONNULL RzListIter *iter, RZ_NULLABLE void *data) {
|
||||
rz_return_val_if_fail(iter, false);
|
||||
iter->elem = data;
|
||||
iter->val = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -73,9 +73,9 @@ RZ_API bool rz_list_iter_set_data(RZ_NONNULL RzListIter *iter, RZ_NULLABLE void
|
|||
**/
|
||||
RZ_API bool rz_list_iter_swap_data(RZ_NONNULL RzListIter *iter0, RZ_NONNULL RzListIter *iter1) {
|
||||
rz_return_val_if_fail(iter0 && iter1, false);
|
||||
void *tmp = iter0->elem;
|
||||
iter0->elem = iter1->elem;
|
||||
iter1->elem = tmp;
|
||||
void *tmp = iter0->val;
|
||||
iter0->val = iter1->val;
|
||||
iter1->val = tmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -97,21 +97,21 @@ RZ_API RZ_BORROW RzListIter *rz_list_push(RZ_NONNULL RzList *list, void *item) {
|
|||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the first element of the list
|
||||
* \brief Returns the value stored in the first node of the list.
|
||||
*
|
||||
**/
|
||||
RZ_API RZ_BORROW void *rz_list_first(RZ_NONNULL const RzList *list) {
|
||||
RZ_API RZ_BORROW void *rz_list_first_val(RZ_NONNULL const RzList *list) {
|
||||
rz_return_val_if_fail(list, NULL);
|
||||
return list->head ? list->head->elem : NULL;
|
||||
return list->head ? list->head->val : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns the last element of the list.
|
||||
* \brief Returns the value stored in the last node of the list.
|
||||
*
|
||||
**/
|
||||
RZ_API RZ_BORROW void *rz_list_last(RZ_NONNULL const RzList *list) {
|
||||
RZ_API RZ_BORROW void *rz_list_last_val(RZ_NONNULL const RzList *list) {
|
||||
rz_return_val_if_fail(list, NULL);
|
||||
return list->tail ? list->tail->elem : NULL;
|
||||
return list->tail ? list->tail->val : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -189,10 +189,10 @@ RZ_API bool rz_list_delete_data(RZ_NONNULL RzList *list, void *ptr) {
|
|||
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter) {
|
||||
rz_return_if_fail(list && iter);
|
||||
rz_list_split_iter(list, iter);
|
||||
if (list->free && iter->elem) {
|
||||
list->free(iter->elem);
|
||||
if (list->free && iter->val) {
|
||||
list->free(iter->val);
|
||||
}
|
||||
iter->elem = NULL;
|
||||
iter->val = NULL;
|
||||
free(iter);
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ RZ_API void rz_list_split(RZ_NONNULL RzList *list, void *ptr) {
|
|||
|
||||
RzListIter *iter = rz_list_iterator(list);
|
||||
while (iter) {
|
||||
void *item = iter->elem;
|
||||
void *item = iter->val;
|
||||
if (ptr == item) {
|
||||
rz_list_split_iter(list, iter);
|
||||
free(iter);
|
||||
|
|
@ -325,7 +325,7 @@ RZ_API RZ_OWN RzList *rz_list_new_from_iterator(RZ_BORROW RZ_NONNULL RzIterator
|
|||
RZ_API RZ_OWN RzListIter *rz_list_item_new(RZ_NULLABLE void *data) {
|
||||
RzListIter *item = RZ_NEW0(RzListIter);
|
||||
if (item) {
|
||||
item->elem = data;
|
||||
item->val = data;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
|
@ -346,7 +346,7 @@ RZ_API RZ_BORROW RzListIter *rz_list_append(RZ_NONNULL RzList *list, RZ_NONNULL
|
|||
if (list->tail) {
|
||||
list->tail->next = item;
|
||||
}
|
||||
item->elem = data;
|
||||
item->val = data;
|
||||
item->prev = list->tail;
|
||||
item->next = NULL;
|
||||
list->tail = item;
|
||||
|
|
@ -372,7 +372,7 @@ RZ_API RZ_BORROW RzListIter *rz_list_prepend(RZ_NONNULL RzList *list, RZ_NONNULL
|
|||
if (list->head) {
|
||||
list->head->prev = item;
|
||||
}
|
||||
item->elem = data;
|
||||
item->val = data;
|
||||
item->next = list->head;
|
||||
item->prev = NULL;
|
||||
list->head = item;
|
||||
|
|
@ -397,13 +397,13 @@ RZ_API RZ_BORROW RzListIter *rz_list_insert(RZ_NONNULL RzList *list, ut32 n, RZ_
|
|||
if (!list->head || !n) {
|
||||
return rz_list_prepend(list, data);
|
||||
}
|
||||
for (it = list->head, i = 0; it && it->elem; it = it->next, i++) {
|
||||
for (it = list->head, i = 0; it && it->val; it = it->next, i++) {
|
||||
if (i == n) {
|
||||
item = RZ_NEW(RzListIter);
|
||||
if (!item) {
|
||||
return NULL;
|
||||
}
|
||||
item->elem = data;
|
||||
item->val = data;
|
||||
item->next = it;
|
||||
item->prev = it->prev;
|
||||
if (it->prev) {
|
||||
|
|
@ -436,7 +436,7 @@ RZ_API RZ_OWN void *rz_list_pop(RZ_NONNULL RzList *list) {
|
|||
list->tail = iter->prev;
|
||||
list->tail->next = NULL;
|
||||
}
|
||||
data = iter->elem;
|
||||
data = iter->val;
|
||||
free(iter);
|
||||
list->length--;
|
||||
}
|
||||
|
|
@ -460,7 +460,7 @@ RZ_API RZ_OWN void *rz_list_pop_head(RZ_NONNULL RzList *list) {
|
|||
list->head = iter->next;
|
||||
list->head->prev = NULL;
|
||||
}
|
||||
data = iter->elem;
|
||||
data = iter->val;
|
||||
free(iter);
|
||||
list->length--;
|
||||
}
|
||||
|
|
@ -477,7 +477,7 @@ RZ_API ut32 rz_list_del_n(RZ_NONNULL RzList *list, ut32 n) {
|
|||
|
||||
rz_return_val_if_fail(list, false);
|
||||
|
||||
for (it = list->head, i = 0; it && it->elem; it = it->next, i++) {
|
||||
for (it = list->head, i = 0; it && it->val; it = it->next, i++) {
|
||||
if (i == n) {
|
||||
if (!it->prev && !it->next) {
|
||||
list->head = list->tail = NULL;
|
||||
|
|
@ -507,7 +507,7 @@ RZ_API void rz_list_reverse(RZ_NONNULL RzList *list) {
|
|||
|
||||
rz_return_if_fail(list);
|
||||
|
||||
for (it = list->head; it && it->elem; it = it->prev) {
|
||||
for (it = list->head; it && it->val; it = it->prev) {
|
||||
tmp = it->prev;
|
||||
it->prev = it->next;
|
||||
it->next = tmp;
|
||||
|
|
@ -547,7 +547,7 @@ RZ_API RZ_BORROW RzListIter *rz_list_add_sorted(RZ_NONNULL RzList *list, RZ_NONN
|
|||
rz_return_val_if_fail(list && data && cmp, NULL);
|
||||
|
||||
RzListIter *it, *item = NULL;
|
||||
for (it = list->head; it && it->elem && cmp(data, it->elem, user) > 0; it = it->next) {
|
||||
for (it = list->head; it && it->val && cmp(data, it->val, user) > 0; it = it->next) {
|
||||
}
|
||||
if (it) {
|
||||
item = RZ_NEW0(RzListIter);
|
||||
|
|
@ -556,7 +556,7 @@ RZ_API RZ_BORROW RzListIter *rz_list_add_sorted(RZ_NONNULL RzList *list, RZ_NONN
|
|||
}
|
||||
item->next = it;
|
||||
item->prev = it->prev;
|
||||
item->elem = data;
|
||||
item->val = data;
|
||||
item->next->prev = item;
|
||||
if (!item->prev) {
|
||||
list->head = item;
|
||||
|
|
@ -583,9 +583,9 @@ RZ_API ut32 rz_list_set_n(RZ_NONNULL RzList *list, ut32 n, RZ_NONNULL void *data
|
|||
for (it = list->head, i = 0; it; it = it->next, i++) {
|
||||
if (i == n) {
|
||||
if (list->free) {
|
||||
list->free(it->elem);
|
||||
list->free(it->val);
|
||||
}
|
||||
it->elem = data;
|
||||
it->val = data;
|
||||
list->sorted = false;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -606,9 +606,9 @@ RZ_API RZ_BORROW void *rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
for (it = list->head, i = 0; it && it->elem; it = it->next, i++) {
|
||||
for (it = list->head, i = 0; it && it->val; it = it->next, i++) {
|
||||
if (i == n) {
|
||||
return it->elem;
|
||||
return it->val;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -668,7 +668,7 @@ static RzListIter *_merge(RzListIter *first, RzListIter *second, RzListComparato
|
|||
} else if (!first) {
|
||||
next = second;
|
||||
second = second->next;
|
||||
} else if (cmp(first->elem, second->elem, user) <= 0) {
|
||||
} else if (cmp(first->val, second->val, user) <= 0) {
|
||||
next = first;
|
||||
first = first->next;
|
||||
} else {
|
||||
|
|
@ -751,12 +751,12 @@ RZ_API void rz_list_insertion_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListCom
|
|||
}
|
||||
RzListIter *it;
|
||||
RzListIter *it2;
|
||||
for (it = list->head; it && it->elem; it = it->next) {
|
||||
for (it2 = it->next; it2 && it2->elem; it2 = it2->next) {
|
||||
if (cmp(it->elem, it2->elem, user) > 0) {
|
||||
void *t = it->elem;
|
||||
it->elem = it2->elem;
|
||||
it2->elem = t;
|
||||
for (it = list->head; it && it->val; it = it->next) {
|
||||
for (it2 = it->next; it2 && it2->val; it2 = it2->next) {
|
||||
if (cmp(it->val, it2->val, user) > 0) {
|
||||
void *t = it->val;
|
||||
it->val = it2->val;
|
||||
it2->val = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ static bool load_process_final_line(LoadCtx *ctx) {
|
|||
RzListIter *it;
|
||||
void *token_off_tmp;
|
||||
rz_list_foreach (ctx->path, it, token_off_tmp) {
|
||||
it->elem = (void *)((size_t)token_off_tmp - ctx->line_begin);
|
||||
it->val = (void *)((size_t)token_off_tmp - ctx->line_begin);
|
||||
}
|
||||
ctx->line_begin = 0;
|
||||
load_process_line(ctx);
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ bool winkd_set_target(RZ_BORROW RZ_NONNULL WindCtx *ctx, ut32 pid, ut32 tid) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
t = rz_list_first(l);
|
||||
t = rz_list_first_val(l);
|
||||
if (t) {
|
||||
ctx->target_thread = *t;
|
||||
found = true;
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ bool test_noreturn_functions_list() {
|
|||
|
||||
RzList *noret = rz_analysis_noreturn_functions(analysis);
|
||||
mu_assert_eq(rz_list_length(noret), 1, "Num functions");
|
||||
mu_assert_streq(rz_list_first(noret), "0x800800", "Addr");
|
||||
mu_assert_streq(rz_list_first_val(noret), "0x800800", "Addr");
|
||||
rz_list_free(noret);
|
||||
|
||||
rz_analysis_noreturn_drop(analysis, "0x800800");
|
||||
|
|
@ -448,7 +448,7 @@ bool test_noreturn_functions_list() {
|
|||
|
||||
noret = rz_analysis_noreturn_functions(analysis);
|
||||
mu_assert_eq(rz_list_length(noret), 1, "Num functions");
|
||||
mu_assert_streq(rz_list_first(noret), "0xdeadbeeff000bad1", "Long addr");
|
||||
mu_assert_streq(rz_list_first_val(noret), "0xdeadbeeff000bad1", "Long addr");
|
||||
rz_list_free(noret);
|
||||
|
||||
rz_analysis_noreturn_drop(analysis, "0xdeadbeeff000bad1");
|
||||
|
|
@ -456,7 +456,7 @@ bool test_noreturn_functions_list() {
|
|||
|
||||
noret = rz_analysis_noreturn_functions(analysis);
|
||||
mu_assert_eq(rz_list_length(noret), 1, "Num functions");
|
||||
mu_assert_streq(rz_list_first(noret), "foobar", "Name");
|
||||
mu_assert_streq(rz_list_first_val(noret), "foobar", "Name");
|
||||
rz_list_free(noret);
|
||||
|
||||
rz_analysis_noreturn_drop(analysis, "foobar");
|
||||
|
|
|
|||
|
|
@ -1321,7 +1321,7 @@ bool test_simple_macros(void) {
|
|||
mu_assert_true(res, "macro1 should be added");
|
||||
RzList *l = rz_cmd_macro_list(cmd);
|
||||
mu_assert_eq(rz_list_length(l), 1, "no macros");
|
||||
const RzCmdMacro *macro1 = (const RzCmdMacro *)rz_list_first(l);
|
||||
const RzCmdMacro *macro1 = (const RzCmdMacro *)rz_list_first_val(l);
|
||||
mu_assert_streq(macro1->name, "macro1", "macro should be named macro1");
|
||||
mu_assert_eq(macro1->nargs, 2, "macro1 should have 2 args");
|
||||
mu_assert_streq(macro1->args[0], "a", "macro1 first arg should be a");
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ bool test_rz_list_sort(void) {
|
|||
// Sort.
|
||||
rz_list_sort(list, (RzListComparator)strcmp, NULL);
|
||||
// Check that the list is actually sorted.
|
||||
mu_assert_streq((char *)list->head->elem, "AAAA", "first value in sorted list");
|
||||
mu_assert_streq((char *)list->head->next->elem, "BBBB", "second value in sorted list");
|
||||
mu_assert_streq((char *)list->head->next->next->elem, "CCCC", "third value in sorted list");
|
||||
mu_assert_streq((char *)list->head->val, "AAAA", "first value in sorted list");
|
||||
mu_assert_streq((char *)list->head->next->val, "BBBB", "second value in sorted list");
|
||||
mu_assert_streq((char *)list->head->next->next->val, "CCCC", "third value in sorted list");
|
||||
rz_list_free(list);
|
||||
mu_end;
|
||||
}
|
||||
|
|
@ -111,9 +111,9 @@ bool test_rz_list_sort2(void) {
|
|||
// Sort.
|
||||
rz_list_merge_sort(list, (RzListComparator)strcmp, NULL);
|
||||
// Check that the list is actually sorted.
|
||||
mu_assert_streq((char *)list->head->elem, "AAAA", "first value in sorted list");
|
||||
mu_assert_streq((char *)list->head->next->elem, "BBBB", "second value in sorted list");
|
||||
mu_assert_streq((char *)list->head->next->next->elem, "CCCC", "third value in sorted list");
|
||||
mu_assert_streq((char *)list->head->val, "AAAA", "first value in sorted list");
|
||||
mu_assert_streq((char *)list->head->next->val, "BBBB", "second value in sorted list");
|
||||
mu_assert_streq((char *)list->head->next->next->val, "CCCC", "third value in sorted list");
|
||||
rz_list_free(list);
|
||||
mu_end;
|
||||
}
|
||||
|
|
@ -136,9 +136,9 @@ bool test_rz_list_sort3(void) {
|
|||
// Sort.
|
||||
rz_list_merge_sort(list, (RzListComparator)cmp_range, NULL);
|
||||
// Check that the list is actually sorted.
|
||||
mu_assert_eq(*(int *)list->head->elem, 33480, "first value in sorted list");
|
||||
mu_assert_eq(*(int *)list->head->next->elem, 33508, "second value in sorted list");
|
||||
mu_assert_eq(*(int *)list->head->next->next->elem, 33964, "third value in sorted list");
|
||||
mu_assert_eq(*(int *)list->head->val, 33480, "first value in sorted list");
|
||||
mu_assert_eq(*(int *)list->head->next->val, 33508, "second value in sorted list");
|
||||
mu_assert_eq(*(int *)list->head->next->next->val, 33964, "third value in sorted list");
|
||||
rz_list_free(list);
|
||||
mu_end;
|
||||
}
|
||||
|
|
@ -213,8 +213,8 @@ bool test_rz_list_sort5(void) {
|
|||
}
|
||||
// add more than 43 elements to trigger merge sort
|
||||
rz_list_sort(list, (RzListComparator)strcmp, NULL);
|
||||
mu_assert_streq((char *)list->head->elem, upper[0], "First element");
|
||||
mu_assert_streq((char *)list->tail->elem, lower[25], "Last element");
|
||||
mu_assert_streq((char *)list->head->val, upper[0], "First element");
|
||||
mu_assert_streq((char *)list->tail->val, lower[25], "Last element");
|
||||
rz_list_free(list);
|
||||
mu_end;
|
||||
}
|
||||
|
|
@ -274,7 +274,7 @@ bool test_rz_list_mergesort_pint() {
|
|||
// assert the list is sorted as expected
|
||||
RzListIter *iter;
|
||||
for (i = 0, iter = list->head; i < RZ_ARRAY_SIZE(expected); i++, iter = iter->next) {
|
||||
mu_assert_eq(*(int *)iter->elem, expected[i], "array content mismatch");
|
||||
mu_assert_eq(*(int *)iter->val, expected[i], "array content mismatch");
|
||||
}
|
||||
|
||||
rz_list_free(list);
|
||||
|
|
@ -311,7 +311,7 @@ bool test_rz_list_sort4(void) {
|
|||
for (i = 0; i < RZ_ARRAY_SIZE(exp_tests_odd); ++i) {
|
||||
char buf[BUF_LENGTH];
|
||||
snprintf(buf, BUF_LENGTH, "%d-th value in sorted list", i);
|
||||
mu_assert_streq((char *)next->elem, exp_tests_odd[i], buf);
|
||||
mu_assert_streq((char *)next->val, exp_tests_odd[i], buf);
|
||||
next = next->next;
|
||||
}
|
||||
|
||||
|
|
@ -351,7 +351,7 @@ bool test_rz_list_sort4(void) {
|
|||
for (i = 0; i < RZ_ARRAY_SIZE(exp_tests_even); ++i) {
|
||||
char buf[BUF_LENGTH];
|
||||
snprintf(buf, BUF_LENGTH, "%d-th value in sorted list", i);
|
||||
mu_assert_streq((char *)next->elem, exp_tests_even[i], buf);
|
||||
mu_assert_streq((char *)next->val, exp_tests_even[i], buf);
|
||||
next = next->next;
|
||||
}
|
||||
rz_list_free(list);
|
||||
|
|
@ -385,7 +385,7 @@ bool test_rz_list_append_prepend(void) {
|
|||
iter = list->head;
|
||||
for (i = 0; i < RZ_ARRAY_SIZE(test); ++i) {
|
||||
snprintf(buf, BUF_LENGTH, "%d-th value in list from head", i);
|
||||
mu_assert_streq((char *)iter->elem, test[i], buf);
|
||||
mu_assert_streq((char *)iter->val, test[i], buf);
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
|
|
@ -393,7 +393,7 @@ bool test_rz_list_append_prepend(void) {
|
|||
iter = list->tail;
|
||||
for (i = (RZ_ARRAY_SIZE(test)) - 1; i > 0; --i) {
|
||||
snprintf(buf, BUF_LENGTH, "%d-th value in list from tail", i);
|
||||
mu_assert_streq((char *)iter->elem, test[i], buf);
|
||||
mu_assert_streq((char *)iter->val, test[i], buf);
|
||||
iter = iter->prev;
|
||||
}
|
||||
|
||||
|
|
@ -449,7 +449,7 @@ bool test_rz_list_reverse(void) {
|
|||
RzListIter *iter = list->head;
|
||||
for (i = 0; i < RZ_ARRAY_SIZE(test); ++i) {
|
||||
snprintf(buf, BUF_LENGTH, "%d-th value in list after reverse", i);
|
||||
mu_assert_streq((char *)iter->elem, test[i], buf);
|
||||
mu_assert_streq((char *)iter->val, test[i], buf);
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
|
|
@ -476,7 +476,7 @@ bool test_rz_list_clone(void) {
|
|||
RzListIter *iter2 = list2->head;
|
||||
for (i = 0; i < RZ_ARRAY_SIZE(test); ++i) {
|
||||
snprintf(buf, BUF_LENGTH, "%d-th value after clone", i);
|
||||
mu_assert_streq((char *)iter2->elem, (char *)iter1->elem, buf);
|
||||
mu_assert_streq((char *)iter2->val, (char *)iter1->val, buf);
|
||||
iter1 = iter1->next;
|
||||
iter2 = iter2->next;
|
||||
}
|
||||
|
|
@ -514,9 +514,9 @@ bool test_rz_list_sorted_uniq() {
|
|||
RzList *list = rz_list_new_from_array((const void **)test_strings, RZ_ARRAY_SIZE(test_strings));
|
||||
rz_list_sorted_uniq(list, (RzListComparator)strcmp, NULL);
|
||||
mu_assert_eq(rz_list_length(list), 3, "unique strings");
|
||||
mu_assert_streq(rz_list_first(list), "cccc", "first");
|
||||
mu_assert_streq(rz_list_first_val(list), "cccc", "first");
|
||||
mu_assert_streq(rz_list_get_n(list, 1), "bbbb", "second");
|
||||
mu_assert_streq(rz_list_last(list), "aaaa", "third");
|
||||
mu_assert_streq(rz_list_last_val(list), "aaaa", "third");
|
||||
rz_list_free(list);
|
||||
mu_end;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue