diff --git a/librz/bin/bin.c b/librz/bin/bin.c index cac5e64b933..81deea270aa 100644 --- a/librz/bin/bin.c +++ b/librz/bin/bin.c @@ -610,12 +610,6 @@ RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_fields(RZ_NO return o ? (RzList *)rz_bin_object_get_fields(o) : NULL; } -RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_imports(RZ_NONNULL RzBin *bin) { - rz_return_val_if_fail(bin, NULL); - RzBinObject *o = rz_bin_cur_object(bin); - return o ? (RzList *)rz_bin_object_get_imports(o) : NULL; -} - RZ_DEPRECATE RZ_API RZ_BORROW RzBinInfo *rz_bin_get_info(RzBin *bin) { rz_return_val_if_fail(bin, NULL); RzBinObject *o = rz_bin_cur_object(bin); diff --git a/librz/bin/bin_language.c b/librz/bin/bin_language.c index e181f20bdba..e87f5837df9 100644 --- a/librz/bin/bin_language.c +++ b/librz/bin/bin_language.c @@ -116,7 +116,9 @@ RZ_API RzBinLanguage rz_bin_language_detect(RzBinFile *binfile) { } if (is_macho || is_elf) { - rz_list_foreach (o->imports, iter, imp) { + void **vec_it; + rz_pvector_foreach (o->imports, vec_it) { + imp = *vec_it; const char *name = imp->name; if (!strcmp(name, "_NSConcreteGlobalBlock")) { is_blocks = true; diff --git a/librz/bin/bobj.c b/librz/bin/bobj.c index fcc30f08168..f867991befd 100644 --- a/librz/bin/bobj.c +++ b/librz/bin/bobj.c @@ -194,7 +194,7 @@ RZ_IPI void rz_bin_object_free(RzBinObject *o) { rz_list_free(o->classes); rz_list_free(o->entries); rz_list_free(o->fields); - rz_list_free(o->imports); + rz_pvector_free(o->imports); rz_list_free(o->libs); rz_list_free(o->maps); rz_list_free(o->mem); @@ -665,7 +665,7 @@ RZ_API const RzList /**/ *rz_bin_object_get_fields(RZ_NONNULL RzBi /** * \brief Get list of \p RzBinImport representing the imports of the binary object. */ -RZ_API const RzList /**/ *rz_bin_object_get_imports(RZ_NONNULL RzBinObject *obj) { +RZ_API const RzPVector /**/ *rz_bin_object_get_imports(RZ_NONNULL RzBinObject *obj) { rz_return_val_if_fail(obj, NULL); return obj->imports; } diff --git a/librz/bin/bobj_process_import.c b/librz/bin/bobj_process_import.c index dd23bef7616..d6ee8d35cfc 100644 --- a/librz/bin/bobj_process_import.c +++ b/librz/bin/bobj_process_import.c @@ -32,23 +32,23 @@ RZ_IPI RzBinProcessLanguage rz_bin_process_language_import(RzBinObject *o) { RZ_IPI void rz_bin_set_imports_from_plugin(RzBinFile *bf, RzBinObject *o) { RzBinPlugin *plugin = o->plugin; - rz_list_free(o->imports); + rz_pvector_free(o->imports); if (!plugin->imports || !(o->imports = plugin->imports(bf))) { - o->imports = rz_list_newf((RzListFree)rz_bin_import_free); + o->imports = rz_pvector_new((RzPVectorFree)rz_bin_import_free); } - rz_warn_if_fail(o->imports->free); } RZ_IPI void rz_bin_process_imports(RzBinFile *bf, RzBinObject *o, const RzDemanglerPlugin *demangler, RzDemanglerFlag flags) { - if (!demangler || rz_list_length(o->imports) < 1) { + if (!demangler || rz_pvector_len(o->imports) < 1) { return; } RzBinProcessLanguage language_cb = rz_bin_process_language_import(o); - RzListIter *it; + void **it; RzBinImport *element; - rz_list_foreach (o->imports, it, element) { + rz_pvector_foreach (o->imports, it) { + element = *it; if (!element->name) { continue; } @@ -67,9 +67,10 @@ RZ_IPI void rz_bin_process_imports(RzBinFile *bf, RzBinObject *o, const RzDemang } RZ_IPI void rz_bin_demangle_imports_with_flags(RzBinObject *o, const RzDemanglerPlugin *demangler, RzDemanglerFlag flags) { - RzListIter *it; + void **it; RzBinImport *element; - rz_list_foreach (o->imports, it, element) { + rz_pvector_foreach (o->imports, it) { + element = *it; if (!element->name) { continue; } diff --git a/librz/bin/format/dex/dex.c b/librz/bin/format/dex/dex.c index 3d3dcc585fa..ede29cf6512 100644 --- a/librz/bin/format/dex/dex.c +++ b/librz/bin/format/dex/dex.c @@ -1392,21 +1392,21 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_dex_symbols(RZ_NONNULL RzBinDex } /** - * \brief Returns a RzList containing the dex imports + * \brief Returns a RzPVector containing the dex imports */ -RZ_API RZ_OWN RzList /**/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex *dex) { +RZ_API RZ_OWN RzPVector /**/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex *dex) { rz_return_val_if_fail(dex, NULL); DexFieldId *field_id; DexMethodId *method_id; DexClassDef *class_def; - RzList *imports = NULL; + RzPVector *imports = NULL; ut32 *class_ids = NULL; void **vit; ut32 n_classes = rz_pvector_len(dex->class_defs); if (n_classes < 1) { - return rz_list_newf((RzListFree)rz_bin_import_free); + return rz_pvector_new((RzPVectorFree)rz_bin_import_free); } class_ids = RZ_NEWS0(ut32, n_classes); @@ -1421,7 +1421,7 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex j++; } - imports = rz_list_newf((RzListFree)rz_bin_import_free); + imports = rz_pvector_new((RzPVectorFree)rz_bin_import_free); if (!imports) { free(class_ids); return NULL; @@ -1453,7 +1453,7 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex import->type = RZ_BIN_TYPE_FIELD_STR; import->ordinal = ordinal; - if (!rz_list_append(imports, import)) { + if (!rz_pvector_push(imports, import)) { rz_bin_import_free(import); break; } @@ -1487,7 +1487,7 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex import->ordinal = ordinal; free(name); - if (!rz_list_append(imports, import)) { + if (!rz_pvector_push(imports, import)) { rz_bin_import_free(import); break; } diff --git a/librz/bin/format/dex/dex.h b/librz/bin/format/dex/dex.h index ba76dee89e0..41b4149f4c5 100644 --- a/librz/bin/format/dex/dex.h +++ b/librz/bin/format/dex/dex.h @@ -212,7 +212,7 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_dex_classes(RZ_NONNULL RzBinDex RZ_API RZ_OWN RzList /**/ *rz_bin_dex_fields(RZ_NONNULL RzBinDex *dex); RZ_API RZ_OWN RzList /**/ *rz_bin_dex_sections(RZ_NONNULL RzBinDex *dex); RZ_API RZ_OWN RzList /**/ *rz_bin_dex_symbols(RZ_NONNULL RzBinDex *dex); -RZ_API RZ_OWN RzList /**/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex *dex); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex *dex); RZ_API RZ_OWN RzList /**/ *rz_bin_dex_libraries(RZ_NONNULL RzBinDex *dex); RZ_API RZ_OWN RzBinAddr *rz_bin_dex_resolve_symbol(RZ_NONNULL RzBinDex *dex, RzBinSpecialSymbol resolve); RZ_API RZ_OWN RzList /**/ *rz_bin_dex_entrypoints(RZ_NONNULL RzBinDex *dex); diff --git a/librz/bin/format/java/class_bin.c b/librz/bin/format/java/class_bin.c index 8ce0e1107e3..c35484ed004 100644 --- a/librz/bin/format/java/class_bin.c +++ b/librz/bin/format/java/class_bin.c @@ -1551,12 +1551,12 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_const_pool_as_symbol } /** - * \brief Returns a RzList containing the class const pool + * \brief Returns a RzPVector containing the class const pool */ -RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_const_pool_as_imports(RZ_NONNULL RzBinJavaClass *bin) { +RZ_API RZ_OWN RzPVector /**/ *rz_bin_java_class_const_pool_as_imports(RZ_NONNULL RzBinJavaClass *bin) { rz_return_val_if_fail(bin, NULL); - RzList *imports = rz_list_newf((RzListFree)rz_bin_import_free); + RzPVector *imports = rz_pvector_new((RzListFree)rz_bin_import_free); if (!imports) { return NULL; } @@ -1604,7 +1604,7 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_const_pool_as_import import->type = is_main ? RZ_BIN_TYPE_FUNC_STR : import_type(cpool); import->descriptor = java_class_constant_pool_stringify_at(bin, descriptor_index); import->ordinal = i; - rz_list_append(imports, import); + rz_pvector_push(imports, import); free(object); } } @@ -1638,7 +1638,7 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_const_pool_as_import import->bind = RZ_BIN_BIND_WEAK_STR; import->type = RZ_BIN_TYPE_IFACE_STR; import->ordinal = i; - rz_list_append(imports, import); + rz_pvector_push(imports, import); free(object); } } @@ -2033,4 +2033,4 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_as_classes(RZ_NONNULL } return list; -} \ No newline at end of file +} diff --git a/librz/bin/format/java/class_bin.h b/librz/bin/format/java/class_bin.h index 3e01bfdaa7b..b9341efa61c 100644 --- a/librz/bin/format/java/class_bin.h +++ b/librz/bin/format/java/class_bin.h @@ -91,7 +91,7 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_fields_as_binfie RZ_API void rz_bin_java_class_fields_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb); RZ_API void rz_bin_java_class_fields_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j); RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_const_pool_as_symbols(RZ_NONNULL RzBinJavaClass *bin); -RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_const_pool_as_imports(RZ_NONNULL RzBinJavaClass *bin); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_java_class_const_pool_as_imports(RZ_NONNULL RzBinJavaClass *bin); RZ_API void rz_bin_java_class_const_pool_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb); RZ_API void rz_bin_java_class_const_pool_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j); RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_as_sections(RZ_NONNULL RzBinJavaClass *bin); diff --git a/librz/bin/format/le/le.c b/librz/bin/format/le/le.c index 19e84511f5a..37ecf34584d 100644 --- a/librz/bin/format/le/le.c +++ b/librz/bin/format/le/le.c @@ -216,7 +216,7 @@ static RZ_BORROW RzBinImport *le_add_bin_import(rz_bin_le_obj_t *bin, const LE_i } import->bind = RZ_BIN_BIND_GLOBAL_STR; import->type = RZ_BIN_TYPE_UNKNOWN_STR; - CHECK(rz_list_append(bin->imports, import)); + CHECK(rz_pvector_push(bin->imports, import)); import->ordinal = ++bin->reloc_targets_count; return import; } @@ -1508,7 +1508,7 @@ static void rz_bin_le_free(rz_bin_le_obj_t *bin) { rz_pvector_free(bin->imp_mod_names); rz_list_free(bin->symbols); rz_vector_free(bin->le_entries); - rz_list_free(bin->imports); + rz_pvector_free(bin->imports); ht_pp_free(bin->le_import_ht); rz_list_free(bin->le_relocs); free(bin); @@ -1552,7 +1552,7 @@ bool rz_bin_le_load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb * err_ctx = ", unable to build maps."; CHECK(bin->le_maps = le_create_maps(bin)); err_ctx = ", unable to load imports."; - CHECK(bin->imports = rz_list_newf((RzListFree)rz_bin_import_free)); + CHECK(bin->imports = rz_pvector_new((RzListFree)rz_bin_import_free)); CHECK(bin->symbols = rz_list_newf((RzListFree)rz_bin_symbol_free)); CHECK(bin->imp_mod_names = le_load_import_mod_names(bin)); CHECK(bin->le_entries = le_load_entries(bin)); @@ -1570,13 +1570,13 @@ bool rz_bin_le_check_buffer(RzBuffer *b) { static void no_free(void *unused) {} -RZ_OWN RzList /**/ *rz_bin_le_get_imports(RzBinFile *bf) { +RZ_OWN RzPVector /**/ *rz_bin_le_get_imports(RzBinFile *bf) { rz_bin_le_obj_t *bin = bf->o->bin_obj; - if (rz_list_empty(bin->imports)) { + if (rz_pvector_empty(bin->imports)) { return NULL; } - RzList *l = rz_list_clone(bin->imports); - l->free = no_free; // silence assertion, there's no need to delete imports + RzPVector *l = rz_pvector_clone(bin->imports); + l->v.free_user = no_free; // silence assertion, there's no need to delete imports return l; } diff --git a/librz/bin/format/le/le.h b/librz/bin/format/le/le.h index 90381149fd8..49ff020f481 100644 --- a/librz/bin/format/le/le.h +++ b/librz/bin/format/le/le.h @@ -93,7 +93,7 @@ typedef struct rz_bin_le_obj_s { RzPVector /**/ *imp_mod_names; RzList /**/ *symbols; RzVector /**/ *le_entries; - RzList /**/ *imports; + RzPVector /**/ *imports; HtPP /**/ *le_import_ht; RzList /**/ *le_relocs; ut32 reloc_target_map_base; @@ -107,7 +107,7 @@ RZ_OWN RzList /**/ *rz_bin_le_get_maps(RzBinFile *bf); RZ_OWN RzList /**/ *rz_bin_le_get_entry_points(RzBinFile *bf); RZ_OWN RzList /**/ *rz_bin_le_get_sections(RzBinFile *bf); RZ_OWN RzList /**/ *rz_bin_le_get_symbols(RzBinFile *bf); -RZ_OWN RzList /**/ *rz_bin_le_get_imports(RzBinFile *bf); +RZ_OWN RzPVector /**/ *rz_bin_le_get_imports(RzBinFile *bf); RZ_OWN RzList /**/ *rz_bin_le_get_libs(RzBinFile *bf); RZ_OWN RzList /**/ *rz_bin_le_get_relocs(RzBinFile *bf); RZ_OWN RzList /**/ *rz_bin_le_get_virtual_files(RzBinFile *bf); diff --git a/librz/bin/format/mdmp/mdmp_pe.c b/librz/bin/format/mdmp/mdmp_pe.c index 9546dc4b511..48510b95a3a 100644 --- a/librz/bin/format/mdmp/mdmp_pe.c +++ b/librz/bin/format/mdmp/mdmp_pe.c @@ -87,16 +87,17 @@ static void filter_import(ut8 *n) { } } -RzList /**/ *PE_(rz_bin_mdmp_pe_get_imports)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin) { +RzPVector /**/ *PE_(rz_bin_mdmp_pe_get_imports)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin) { int i; ut64 offset; struct rz_bin_pe_import_t *imports = NULL; RzBinImport *ptr = NULL; RzBinReloc *rel; - RzList *ret, *relocs; + RzPVector *ret; + RzList *relocs; imports = PE_(rz_bin_pe_get_imports)(pe_bin->bin); - ret = rz_list_new(); + ret = rz_pvector_new(NULL); relocs = rz_list_newf(free); if (!imports || !ret || !relocs) { @@ -117,7 +118,7 @@ RzList /**/ *PE_(rz_bin_mdmp_pe_get_imports)(struct PE_(rz_bin_md ptr->bind = "NONE"; ptr->type = RZ_BIN_TYPE_FUNC_STR; ptr->ordinal = imports[i].ordinal; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); if (!(rel = RZ_NEW0(RzBinReloc))) { break; diff --git a/librz/bin/format/mdmp/mdmp_pe.h b/librz/bin/format/mdmp/mdmp_pe.h index 11b89faea9e..aab371852cc 100644 --- a/librz/bin/format/mdmp/mdmp_pe.h +++ b/librz/bin/format/mdmp/mdmp_pe.h @@ -21,7 +21,7 @@ struct PE_(rz_bin_mdmp_pe_bin) { }; RzList /**/ *PE_(rz_bin_mdmp_pe_get_entrypoint)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin); -RzList /**/ *PE_(rz_bin_mdmp_pe_get_imports)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin); +RzPVector /**/ *PE_(rz_bin_mdmp_pe_get_imports)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin); RzList /**/ *PE_(rz_bin_mdmp_pe_get_sections)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin); RzList /**/ *PE_(rz_bin_mdmp_pe_get_symbols)(RzBin *rbin, struct PE_(rz_bin_mdmp_pe_bin) * pe_bin); diff --git a/librz/bin/format/ne/ne.c b/librz/bin/format/ne/ne.c index 354bd099b6f..3a65dffcc2d 100644 --- a/librz/bin/format/ne/ne.c +++ b/librz/bin/format/ne/ne.c @@ -354,8 +354,8 @@ static bool __ne_get_resources(rz_bin_ne_obj_t *bin) { return true; } -RzList /**/ *rz_bin_ne_get_imports(rz_bin_ne_obj_t *bin) { - RzList *imports = rz_list_newf((RzListFree)rz_bin_import_free); +RzPVector /**/ *rz_bin_ne_get_imports(rz_bin_ne_obj_t *bin) { + RzPVector *imports = rz_pvector_new((RzListFree)rz_bin_import_free); if (!imports) { return NULL; } @@ -383,7 +383,7 @@ RzList /**/ *rz_bin_ne_get_imports(rz_bin_ne_obj_t *bin) { name[sz] = '\0'; imp->name = name; imp->ordinal = i + 1; - rz_list_append(imports, imp); + rz_pvector_push(imports, imp); off += sz; } bin->imports = imports; diff --git a/librz/bin/format/ne/ne.h b/librz/bin/format/ne/ne.h index c9ff692d03b..05fd2fdbece 100644 --- a/librz/bin/format/ne/ne.h +++ b/librz/bin/format/ne/ne.h @@ -31,7 +31,7 @@ typedef struct { RzList /**/ *segments; RzList /**/ *entries; RzList /**/ *resources; - RzList /**/ *imports; + RzPVector /**/ *imports; RzList /**/ *symbols; char *os; } rz_bin_ne_obj_t; @@ -39,7 +39,7 @@ typedef struct { void rz_bin_ne_free(rz_bin_ne_obj_t *bin); rz_bin_ne_obj_t *rz_bin_ne_new_buf(RzBuffer *buf, bool verbose); RzList /**/ *rz_bin_ne_get_relocs(rz_bin_ne_obj_t *bin); -RzList /**/ *rz_bin_ne_get_imports(rz_bin_ne_obj_t *bin); +RzPVector /**/ *rz_bin_ne_get_imports(rz_bin_ne_obj_t *bin); RzList /**/ *rz_bin_ne_get_symbols(rz_bin_ne_obj_t *bin); RzList /**/ *rz_bin_ne_get_segments(rz_bin_ne_obj_t *bin); RzList /**/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin); diff --git a/librz/bin/format/nxo/nxo.c b/librz/bin/format/nxo/nxo.c index 59e52bac82b..bea3e461906 100644 --- a/librz/bin/format/nxo/nxo.c +++ b/librz/bin/format/nxo/nxo.c @@ -96,8 +96,8 @@ static void walkSymbols(RzBuffer *buf, RzBinNXOObj *bin, ut64 symtab, ut64 strta if (!imp->bind) { goto out_walk_symbol; } - imp->ordinal = bin->imports_list->length; - rz_list_append(bin->imports_list, imp); + imp->ordinal = bin->imports_vec->v.len; + rz_pvector_push(bin->imports_vec, imp); sym->is_imported = true; sym->name = strdup(symName); if (!sym->name) { diff --git a/librz/bin/format/nxo/nxo.h b/librz/bin/format/nxo/nxo.h index 41aec99b499..f079625e069 100644 --- a/librz/bin/format/nxo/nxo.h +++ b/librz/bin/format/nxo/nxo.h @@ -60,7 +60,7 @@ typedef struct { typedef struct { ut32 *strings; RzList /**/ *methods_list; - RzList /**/ *imports_list; + RzPVector /**/ *imports_vec; RZ_NULLABLE RzBuffer *decompressed; /// nso-only void *header; } RzBinNXOObj; diff --git a/librz/bin/p/bin_coff.c b/librz/bin/p/bin_coff.c index 4d7d8ea9768..0c9cadd7521 100644 --- a/librz/bin/p/bin_coff.c +++ b/librz/bin/p/bin_coff.c @@ -355,10 +355,10 @@ static RzList /**/ *symbols(RzBinFile *bf) { return ret; } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { int i; struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj; - RzList *ret = rz_list_newf((RzListFree)rz_bin_import_free); + RzPVector *ret = rz_pvector_new((RzListFree)rz_bin_import_free); if (!ret) { return NULL; } @@ -367,7 +367,7 @@ static RzList /**/ *imports(RzBinFile *bf) { for (i = 0; i < obj->hdr.f_nsyms; i++) { RzBinImport *ptr = ht_up_find(obj->imp_ht, i, NULL); if (ptr) { - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } i += obj->symbols[i].n_numaux; } diff --git a/librz/bin/p/bin_dex.c b/librz/bin/p/bin_dex.c index 48b5d5579b1..3a215ff3968 100644 --- a/librz/bin/p/bin_dex.c +++ b/librz/bin/p/bin_dex.c @@ -77,7 +77,7 @@ static RzList /**/ *classes(RzBinFile *bf) { return rz_bin_dex_classes(dex); } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { RzBinDex *dex = rz_bin_file_get_dex(bf); if (!dex) { return NULL; diff --git a/librz/bin/p/bin_elf.inc b/librz/bin/p/bin_elf.inc index 14177fc7c9a..d19ebf5c24e 100644 --- a/librz/bin/p/bin_elf.inc +++ b/librz/bin/p/bin_elf.inc @@ -153,7 +153,7 @@ typedef struct rz_bin_reloc_formular_symbols_t { static RzBinInfo *info(RzBinFile *bf); static void patch_relocs(RzBinFile *bf, struct Elf_(rz_bin_elf_obj_t) * bin); -static RzList /**/ *imports(RzBinFile *bf); +static RzPVector /**/ *imports(RzBinFile *bf); struct special_symbol_translation { RzBinSpecialSymbol symbol; @@ -1669,7 +1669,7 @@ static RzList /**/ *symbols(RzBinFile *bf) { return ret; } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { rz_return_val_if_fail(bf && bf->o, NULL); ELFOBJ *bin = bf->o->bin_obj; @@ -1678,7 +1678,7 @@ static RzList /**/ *imports(RzBinFile *bf) { return NULL; } - RzList *result = rz_list_newf((RzListFree)rz_bin_import_free); + RzPVector *result = rz_pvector_new((RzPVectorFree)rz_bin_import_free); if (!result) { return NULL; } @@ -1687,11 +1687,11 @@ static RzList /**/ *imports(RzBinFile *bf) { rz_bin_elf_foreach_imports(bin, import) { RzBinImport *tmp = convert_import(import); if (!tmp) { - rz_list_free(result); + rz_pvector_free(result); return NULL; } - rz_list_append(result, tmp); + rz_pvector_push(result, tmp); } return result; @@ -1788,17 +1788,21 @@ static void lookup_sections(RzBinFile *bf, RzBinInfo *ret) { static bool has_sanitizers(RzBinFile *bf) { bool ret = false; - RzList *imports_list = imports(bf); - RzListIter *iter; + RzPVector *imports_vec = imports(bf); + if (!imports_vec) { + return ret; + } + void **iter; RzBinImport *import; - rz_list_foreach (imports_list, iter, import) { + rz_pvector_foreach (imports_vec, iter) { + import = *iter; if (strstr(import->name, "__sanitizer") || strstr(import->name, "__ubsan")) { ret = true; break; } } - rz_list_free(imports_list); + rz_pvector_free(imports_vec); return ret; } diff --git a/librz/bin/p/bin_java.c b/librz/bin/p/bin_java.c index 70bc522c660..91be6ea83e1 100644 --- a/librz/bin/p/bin_java.c +++ b/librz/bin/p/bin_java.c @@ -76,7 +76,7 @@ static RzList /**/ *classes(RzBinFile *bf) { return rz_bin_java_class_as_classes(jclass); } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { RzBinJavaClass *jclass = rz_bin_file_get_java_class(bf); if (!jclass) { return NULL; diff --git a/librz/bin/p/bin_mach0.c b/librz/bin/p/bin_mach0.c index cae20f83441..c66a30e7850 100644 --- a/librz/bin/p/bin_mach0.c +++ b/librz/bin/p/bin_mach0.c @@ -319,7 +319,7 @@ static RzBinImport *import_from_name(RzBin *rbin, const char *orig_name, HtPP *i typedef struct { RzBin *bin; struct MACH0_(obj_t) * obj; - RzList /**/ *imports_dst; + RzPVector /**/ *imports_dst; } ImportsForeachCtx; static void imports_foreach_cb(char *name, int ord, void *user) { @@ -343,11 +343,11 @@ static void imports_foreach_cb(char *name, int ord, void *user) { if (!strcmp(name, "_NSConcreteGlobalBlock")) { ctx->obj->has_blocks_ext = true; } - rz_list_append(ctx->imports_dst, ptr); + rz_pvector_push(ctx->imports_dst, ptr); free(name); } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { RzBinObject *obj = bf ? bf->o : NULL; struct MACH0_(obj_t) *bin = bf ? bf->o->bin_obj : NULL; if (!obj || !bin || !obj->bin_obj) { @@ -357,7 +357,7 @@ static RzList /**/ *imports(RzBinFile *bf) { bin->has_retguard = -1; bin->has_sanitizers = false; bin->has_blocks_ext = false; - RzList *ret = rz_list_newf((RzListFree)rz_bin_import_free); + RzPVector *ret = rz_pvector_new((RzListFree)rz_bin_import_free); if (!ret) { return NULL; } diff --git a/librz/bin/p/bin_mdmp.c b/librz/bin/p/bin_mdmp.c index 3510a9a22ce..239c59851d1 100644 --- a/librz/bin/p/bin_mdmp.c +++ b/librz/bin/p/bin_mdmp.c @@ -400,14 +400,14 @@ static RzList /**/ *mdmp_relocs(RzBinFile *bf) { return ret; } -static RzList /**/ *mdmp_imports(RzBinFile *bf) { +static RzPVector /**/ *mdmp_imports(RzBinFile *bf) { MiniDmpObj *obj; struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin; struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin; - RzList *list; + RzPVector *vec; RzListIter *it; - RzList *ret = rz_list_newf((RzListFree)rz_bin_import_free); + RzPVector *ret = rz_pvector_new((RzListFree)rz_bin_import_free); if (!ret) { return NULL; } @@ -415,17 +415,27 @@ static RzList /**/ *mdmp_imports(RzBinFile *bf) { obj = (MiniDmpObj *)bf->o->bin_obj; rz_list_foreach (obj->pe32_bins, it, pe32_bin) { - list = Pe32_rz_bin_mdmp_pe_get_imports(pe32_bin); - if (list) { - rz_list_join(ret, list); - rz_list_free(list); + vec = Pe32_rz_bin_mdmp_pe_get_imports(pe32_bin); + if (vec) { + void **vec_it; + rz_pvector_foreach (vec, vec_it) { + RzBinImport *import = *vec_it; + rz_pvector_push(ret, import); + } + // this won't free import + rz_pvector_free(vec); } } rz_list_foreach (obj->pe64_bins, it, pe64_bin) { - list = Pe64_rz_bin_mdmp_pe_get_imports(pe64_bin); - if (list) { - rz_list_join(ret, list); - rz_list_free(list); + vec = Pe64_rz_bin_mdmp_pe_get_imports(pe64_bin); + if (vec) { + void **vec_it; + rz_pvector_foreach (vec, vec_it) { + RzBinImport *import = *vec_it; + rz_pvector_push(ret, import); + } + // this won't free import + rz_pvector_free(vec); } } return ret; diff --git a/librz/bin/p/bin_ne.c b/librz/bin/p/bin_ne.c index a3652ef17c4..a5b1a1813b5 100644 --- a/librz/bin/p/bin_ne.c +++ b/librz/bin/p/bin_ne.c @@ -103,7 +103,7 @@ RzList /**/ *symbols(RzBinFile *bf) { return rz_bin_ne_get_symbols(bf->o->bin_obj); } -RzList /**/ *imports(RzBinFile *bf) { +RzPVector /**/ *imports(RzBinFile *bf) { return rz_bin_ne_get_imports(bf->o->bin_obj); } diff --git a/librz/bin/p/bin_nro.c b/librz/bin/p/bin_nro.c index 5f99b04ab52..a8c9546096c 100644 --- a/librz/bin/p/bin_nro.c +++ b/librz/bin/p/bin_nro.c @@ -62,7 +62,7 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *b, Sdb *sdb) ut64 ba = baddr(bf); bin->methods_list = rz_list_newf((RzListFree)rz_bin_symbol_free); - bin->imports_list = rz_list_newf((RzListFree)rz_bin_import_free); + bin->imports_vec = rz_pvector_new((RzListFree)rz_bin_import_free); parseMod(b, bin, mod0, ba); obj->bin_obj = bin; @@ -277,13 +277,13 @@ static RzList /**/ *symbols(RzBinFile *bf) { return bin->methods_list; } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { RzBinNXOObj *bin; if (!bf || !bf->o || !bf->o->bin_obj) { return NULL; } bin = (RzBinNXOObj *)bf->o->bin_obj; - return bin->imports_list; + return bin->imports_vec; } static RzList /**/ *libs(RzBinFile *bf) { diff --git a/librz/bin/p/bin_p9.c b/librz/bin/p/bin_p9.c index 359978f90c2..020cfea8d3a 100644 --- a/librz/bin/p/bin_p9.c +++ b/librz/bin/p/bin_p9.c @@ -160,7 +160,7 @@ static RzList /**/ *symbols(RzBinFile *bf) { return NULL; } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { return NULL; } diff --git a/librz/bin/p/bin_pe.inc b/librz/bin/p/bin_pe.inc index 3a4feb7720f..65e5bf44ac9 100644 --- a/librz/bin/p/bin_pe.inc +++ b/librz/bin/p/bin_pe.inc @@ -409,7 +409,7 @@ static void filter_import(ut8 *n) { } } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { RzList *relocs = NULL; RzBinImport *ptr = NULL; RzBinReloc *rel = NULL; @@ -419,7 +419,7 @@ static RzList /**/ *imports(RzBinFile *bf) { if (!bf || !bf->o || !bf->o->bin_obj) { return NULL; } - RzList *ret = rz_list_newf((RzListFree)rz_bin_import_free); + RzPVector *ret = rz_pvector_new((RzListFree)rz_bin_import_free); if (!ret) { return NULL; } @@ -430,7 +430,7 @@ static RzList /**/ *imports(RzBinFile *bf) { } if (!(relocs = rz_list_newf(free))) { - free(ret); + rz_pvector_free(ret); return NULL; } ((struct PE_(rz_bin_pe_obj_t) *)bf->o->bin_obj)->relocs = relocs; @@ -451,7 +451,7 @@ static RzList /**/ *imports(RzBinFile *bf) { // NOTE(eddyb) a PE hint is just an optional possible DLL export table // index for the import. There is no point in exposing it. // ptr->hint = imports[i].hint; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); if (!(rel = RZ_NEW0(RzBinReloc))) { break; @@ -593,11 +593,11 @@ static bool is_vb6(RzBinFile *bf) { static int has_canary(RzBinFile *bf) { // XXX: We only need imports here but this causes leaks, we need to wait for the below. This is a horrible solution! // TODO: use O(1) when imports sdbized - RzListIter *iter; struct PE_(rz_bin_pe_obj_t) *bin = bf->o->bin_obj; if (bin) { const RzList *relocs_list = bin->relocs; RzBinReloc *rel; + RzListIter *iter; if (relocs_list) { rz_list_foreach (relocs_list, iter, rel) { if (!strcmp(rel->import->name, "__security_init_cookie")) { @@ -606,10 +606,12 @@ static int has_canary(RzBinFile *bf) { } } } else { // rz_bin needs this as it will not initialise bin - const RzList *imports_list = imports(bf); + const RzPVector *imports_vec = imports(bf); RzBinImport *imp; - if (imports_list) { - rz_list_foreach (imports_list, iter, imp) { + void **vec_it; + if (imports_vec) { + rz_pvector_foreach (imports_vec, vec_it) { + imp = *vec_it; if (!strcmp(imp->name, "__security_init_cookie")) { return true; } diff --git a/librz/bin/p/bin_wasm.c b/librz/bin/p/bin_wasm.c index a9fddad54da..5d789500285 100644 --- a/librz/bin/p/bin_wasm.c +++ b/librz/bin/p/bin_wasm.c @@ -222,7 +222,7 @@ static RzList /**/ *symbols(RzBinFile *bf) { return NULL; } -static RzList /**/ *imports(RzBinFile *bf) { +static RzPVector /**/ *imports(RzBinFile *bf) { RzBinWasmObj *bin = NULL; RzList *imports = NULL; RzBinImport *ptr = NULL; @@ -231,7 +231,7 @@ static RzList /**/ *imports(RzBinFile *bf) { return NULL; } bin = bf->o->bin_obj; - RzList *ret = rz_list_newf((RzListFree)rz_bin_import_free); + RzPVector *ret = rz_pvector_new((RzListFree)rz_bin_import_free); if (!ret) { return NULL; } @@ -264,12 +264,12 @@ static RzList /**/ *imports(RzBinFile *bf) { ptr->type = "GLOBAL"; break; } - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; bad_alloc: rz_list_free(imports); - rz_list_free(ret); + rz_pvector_free(ret); return NULL; } diff --git a/librz/core/cbin.c b/librz/core/cbin.c index 8b5c4f4e94f..a5dafd56078 100644 --- a/librz/core/cbin.c +++ b/librz/core/cbin.c @@ -1233,10 +1233,11 @@ RZ_API bool rz_core_bin_apply_imports(RzCore *core, RzBinFile *binfile, bool va) if (cdsz <= 0) { return false; } - RzListIter *iter; + void **iter; RzBinImport *import; - RzList *imports = o->imports; - rz_list_foreach (imports, iter, import) { + RzPVector *imports = o->imports; + rz_pvector_foreach (imports, iter) { + import = *iter; if (!import->libname || !strstr(import->libname, ".dll")) { continue; } @@ -2034,16 +2035,17 @@ RZ_API bool rz_core_bin_imports_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinF rz_return_val_if_fail(core && bf && bf->o && state, false); int va = (core->io->va || core->bin->is_debugger) ? VA_TRUE : VA_FALSE; - const RzList *imports = rz_bin_object_get_imports(bf->o); + const RzPVector *imports = rz_bin_object_get_imports(bf->o); RzBinObject *o = bf->o; RzBinImport *import; - RzListIter *iter; + void **iter; bool demangle = rz_config_get_b(core->config, "bin.demangle"); rz_cmd_state_output_array_start(state); rz_cmd_state_output_set_columnsf(state, "nXssss", "nth", "vaddr", "bind", "type", "lib", "name"); - rz_list_foreach (imports, iter, import) { + rz_pvector_foreach (imports, iter) { + import = *iter; if (!import->name) { continue; } diff --git a/librz/core/cfile.c b/librz/core/cfile.c index 0937143aba8..fc1c984ae91 100644 --- a/librz/core/cfile.c +++ b/librz/core/cfile.c @@ -1081,8 +1081,11 @@ RZ_API bool rz_core_bin_load(RZ_NONNULL RzCore *r, RZ_NULLABLE const char *filen rz_config_set_b(r->config, "bin.at", true); RZ_LOG_INFO("Linking imports...\n"); RzBinImport *imp; - RzList *imports = rz_bin_get_imports(r->bin); - rz_list_foreach (imports, iter, imp) { + RzBinObject *bin_obj = rz_bin_cur_object(r->bin); + const RzPVector *imports = rz_bin_object_get_imports(bin_obj); + void **vec_iter; + rz_pvector_foreach (imports, vec_iter) { + imp = *vec_iter; char *name = rz_str_newf("sym.imp.%s", imp->name); rz_name_filter(name + 8, strlen(name + 8) + 1, true); diff --git a/librz/core/cgraph.c b/librz/core/cgraph.c index 9c4d6db1742..31e65dea432 100644 --- a/librz/core/cgraph.c +++ b/librz/core/cgraph.c @@ -153,9 +153,10 @@ RZ_API RZ_OWN RzGraph /**/ *rz_core_graph_importxrefs(RZ_NONN } bool va = core->io->va || core->bin->is_debugger; - RzListIter *iter; + void **iter; RzBinImport *imp; - rz_list_foreach (obj->imports, iter, imp) { + rz_pvector_foreach (obj->imports, iter) { + imp = *iter; RzBinSymbol *sym = rz_bin_object_get_symbol_of_import(obj, imp); ut64 addr = sym ? (va ? rz_bin_object_get_vaddr(obj, sym->paddr, sym->vaddr) : sym->paddr) : UT64_MAX; if (addr && addr != UT64_MAX) { diff --git a/librz/core/cmd/cmd.c b/librz/core/cmd/cmd.c index 46d3bb016a1..a57d21bfc37 100644 --- a/librz/core/cmd/cmd.c +++ b/librz/core/cmd/cmd.c @@ -2569,9 +2569,12 @@ RZ_API int rz_core_cmd_foreach3(RzCore *core, const char *cmd, char *each) { // { RzBinImport *imp; ut64 offorig = core->offset; - list = rz_bin_get_imports(core->bin); + RzBinObject *bin_obj = rz_bin_cur_object(core->bin); + const RzPVector *imports = rz_bin_object_get_imports(bin_obj); + void **vec_iter = NULL; RzList *lost = rz_list_newf(free); - rz_list_foreach (list, iter, imp) { + rz_pvector_foreach (imports, vec_iter) { + imp = *vec_iter; char *impflag = rz_str_newf("sym.imp.%s", imp->name); ut64 addr = rz_num_math(core->num, impflag); ut64 *n = RZ_NEW(ut64); diff --git a/librz/include/rz_bin.h b/librz/include/rz_bin.h index 5775d8c2d26..a30940b9d37 100644 --- a/librz/include/rz_bin.h +++ b/librz/include/rz_bin.h @@ -1,6 +1,7 @@ #ifndef RZ_BIN_H #define RZ_BIN_H +#include "rz_vector.h" #include #include #include @@ -268,7 +269,7 @@ typedef struct rz_bin_object_t { RzList /**/ *vfiles; RzList /**/ *maps; RzList /**/ *sections; - RzList /**/ *imports; + RzPVector /**/ *imports; RzList /**/ *symbols; RzList /**/ *resources; /** @@ -532,7 +533,7 @@ typedef struct rz_bin_plugin_t { RzList /**/ *(*sections)(RzBinFile *bf); RZ_OWN RzBinSourceLineInfo *(*lines)(RzBinFile *bf); //< only called once on load, ownership is transferred to the caller RzList /**/ *(*symbols)(RzBinFile *bf); - RzList /**/ *(*imports)(RzBinFile *bf); + RzPVector /**/ *(*imports)(RzBinFile *bf); RzList /**/ *(*strings)(RzBinFile *bf); RzBinInfo *(*info)(RzBinFile *bf); RzList /**/ *(*fields)(RzBinFile *bf); @@ -919,7 +920,6 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_file_strings(RZ_NONNULL RzBinFi // use RzBinFile instead RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_entries(RZ_NONNULL RzBin *bin); RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_fields(RZ_NONNULL RzBin *bin); -RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_imports(RZ_NONNULL RzBin *bin); RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_libs(RZ_NONNULL RzBin *bin); RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_sections(RZ_NONNULL RzBin *bin); RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_classes(RZ_NONNULL RzBin *bin); @@ -931,7 +931,7 @@ RZ_API RzList /**/ *rz_bin_file_get_trycatch(RZ_NONNULL RzBinFi RZ_API const RzList /**/ *rz_bin_object_get_entries(RZ_NONNULL RzBinObject *obj); RZ_API const RzList /**/ *rz_bin_object_get_fields(RZ_NONNULL RzBinObject *obj); -RZ_API const RzList /**/ *rz_bin_object_get_imports(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_imports(RZ_NONNULL RzBinObject *obj); RZ_API const RzBinInfo *rz_bin_object_get_info(RZ_NONNULL RzBinObject *obj); RZ_API const RzList /**/ *rz_bin_object_get_libs(RZ_NONNULL RzBinObject *obj); RZ_API const RzList /**/ *rz_bin_object_get_sections_all(RZ_NONNULL RzBinObject *obj); diff --git a/librz/main/rz-diff.c b/librz/main/rz-diff.c index 07649d756e2..604e5f6dcff 100644 --- a/librz/main/rz-diff.c +++ b/librz/main/rz-diff.c @@ -707,6 +707,12 @@ static const void *rz_diff_list_elem_at(const RzList /**/ *array, ut32 i return rz_list_get_n(array, index); } +/**************************************** rzpvector ***************************************/ + +static const void *rz_diff_pvector_elem_at(const RzPVector /**/ *array, ut32 index) { + return rz_pvector_at(array, index); +} + /**************************************** imports ***************************************/ static ut32 import_hash(const RzBinImport *elem) { @@ -730,31 +736,31 @@ static int import_compare(const RzBinImport *a, const RzBinImport *b) { } static RzDiff *rz_diff_imports_new(DiffFile *dfile_a, DiffFile *dfile_b) { - RzList *list_a = NULL; - RzList *list_b = NULL; + RzPVector *vec_a = NULL; + RzPVector *vec_b = NULL; - list_a = rz_diff_file_get(dfile_a, imports); - if (!list_a) { + vec_a = rz_diff_file_get(dfile_a, imports); + if (!vec_a) { rz_diff_error_ret(NULL, "cannot get imports from '%s'\n", dfile_a->dio->filename); } - list_b = rz_diff_file_get(dfile_b, imports); - if (!list_b) { + vec_b = rz_diff_file_get(dfile_b, imports); + if (!vec_b) { rz_diff_error_ret(NULL, "cannot get imports from '%s'\n", dfile_b->dio->filename); } - rz_list_sort(list_a, (RzListComparator)import_compare); - rz_list_sort(list_b, (RzListComparator)import_compare); + rz_pvector_sort(vec_a, (RzPVectorComparator)import_compare); + rz_pvector_sort(vec_b, (RzPVectorComparator)import_compare); RzDiffMethods methods = { - .elem_at = (RzDiffMethodElemAt)rz_diff_list_elem_at, + .elem_at = (RzDiffMethodElemAt)rz_diff_pvector_elem_at, .elem_hash = (RzDiffMethodElemHash)import_hash, .compare = (RzDiffMethodCompare)import_compare, .stringify = (RzDiffMethodStringify)import_stringify, .ignore = NULL, }; - return rz_diff_generic_new(list_a, rz_list_length(list_a), list_b, rz_list_length(list_b), &methods); + return rz_diff_generic_new(vec_a, rz_pvector_len(vec_a), vec_b, rz_pvector_len(vec_b), &methods); } /**************************************** symbols ***************************************/ diff --git a/librz/main/rz-find.c b/librz/main/rz-find.c index b67df2b9543..d03a3a3d278 100644 --- a/librz/main/rz-find.c +++ b/librz/main/rz-find.c @@ -226,8 +226,10 @@ static int rzfind_open_file(RzfindOptions *ro, const char *file, const ut8 *data if (ro->import || ro->symbol) { RzBinFile *bf; - const RzList *symbols, *imports; + const RzList *symbols; + const RzPVector *imports; RzListIter *iter, *it; + void **vec_it; RzBinSymbol *symbol; RzBinImport *import; RzBin *bin = rz_bin_new(); @@ -254,7 +256,8 @@ static int rzfind_open_file(RzfindOptions *ro, const char *file, const ut8 *data if (!kw) { continue; } - rz_list_foreach (imports, it, import) { + rz_pvector_foreach (imports, vec_it) { + import = *vec_it; if (!strcmp(import->name, kw)) { printf("ordinal: %d %s\n", import->ordinal, kw); } diff --git a/test/integration/test_bin.c b/test/integration/test_bin.c index 69ca548e8d4..bc04573249f 100644 --- a/test/integration/test_bin.c +++ b/test/integration/test_bin.c @@ -33,13 +33,15 @@ bool test_rz_bin(void) { mu_assert_eq(entry->vaddr, 0x8048360, "entry virtual address"); mu_assert_eq(entry->paddr, 0x360, "entry file offset"); - const RzList *imports = rz_bin_object_get_imports(obj); - mu_assert_eq(rz_list_length(imports), 5, "rz_bin_object_get_imports"); + const RzPVector *imports = rz_bin_object_get_imports(obj); + mu_assert_eq(rz_pvector_len(imports), 5, "rz_bin_object_get_imports"); const char *import_names[] = { "__libc_start_main", "printf", "scanf", "strcmp", "__gmon_start__" }; bool has_import_names[sizeof(import_names)] = { 0 }; RzBinImport *import; RzListIter *it; - rz_list_foreach (imports, it, import) { + void **vec_it; + rz_pvector_foreach (imports, vec_it) { + import = *vec_it; for (int i = 0; i < RZ_ARRAY_SIZE(import_names); ++i) { if (!strcmp(import->name, import_names[i])) { has_import_names[i] = true; diff --git a/test/integration/test_bin_symbols.c b/test/integration/test_bin_symbols.c index 6822c73c332..d0bc637fb6d 100644 --- a/test/integration/test_bin_symbols.c +++ b/test/integration/test_bin_symbols.c @@ -67,12 +67,14 @@ bool test_rz_bin_symbols(void) { } } mu_assert_eq(matches, expected, "all checked symbols match"); - - const RzList *imports = rz_bin_object_get_imports(obj); + + const RzPVector *imports = rz_bin_object_get_imports(obj); + void **vec_it = NULL; mu_assert_notnull(symbols, "mipsbe-ip imports"); matches = 0; expected = RZ_ARRAY_SIZE(mipsbe_ip_imports) - 1; - rz_list_foreach (imports, it, sym) { + rz_pvector_foreach (imports, vec_it) { + sym = *vec_it; for (int i = 0; i < expected; i++) { if (sym && sym->name && !strcmp(sym->name, mipsbe_ip_imports[i].name)) { matches++; @@ -80,7 +82,7 @@ bool test_rz_bin_symbols(void) { } } mu_assert_eq(matches, expected, "all checked imports match"); - + rz_bin_free(bin); rz_io_free(io); mu_end;