diff --git a/librz/bin/bin.c b/librz/bin/bin.c index 0367a964740..9bf902150e3 100644 --- a/librz/bin/bin.c +++ b/librz/bin/bin.c @@ -597,13 +597,6 @@ RZ_API void rz_bin_set_baddr(RzBin *bin, ut64 baddr) { } } -// XXX: those accessors are redundant -RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_entries(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_entries(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/bobj.c b/librz/bin/bobj.c index f6ab1183703..42a48320d8c 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_bin_source_line_info_free(o->lines); rz_bin_string_database_free(o->strings); rz_pvector_free(o->classes); - rz_list_free(o->entries); + rz_pvector_free(o->entries); rz_pvector_free(o->fields); rz_pvector_free(o->imports); rz_pvector_free(o->libs); @@ -649,9 +649,9 @@ RZ_API const RzBinAddr *rz_bin_object_get_special_symbol(RzBinObject *o, RzBinSp } /** - * \brief Get list of \p RzBinAddr representing the entry points of the binary object. + * \brief Get pvector of \p RzBinAddr representing the entry points of the binary object. */ -RZ_API const RzList /**/ *rz_bin_object_get_entries(RZ_NONNULL RzBinObject *obj) { +RZ_API const RzPVector /**/ *rz_bin_object_get_entries(RZ_NONNULL RzBinObject *obj) { rz_return_val_if_fail(obj, NULL); return obj->entries; } diff --git a/librz/bin/bobj_process_entry.c b/librz/bin/bobj_process_entry.c index 89dd0a036f8..d369ba7ca38 100644 --- a/librz/bin/bobj_process_entry.c +++ b/librz/bin/bobj_process_entry.c @@ -7,15 +7,16 @@ RZ_IPI void rz_bin_set_and_process_entries(RzBinFile *bf, RzBinObject *o) { RzBinPlugin *plugin = o->plugin; - rz_list_free(o->entries); + rz_pvector_free(o->entries); if (!plugin->entries || !(o->entries = plugin->entries(bf))) { - o->entries = rz_list_newf(free); + o->entries = rz_pvector_new(free); return; } - RzListIter *it; + void **it; RzBinAddr *element; - rz_list_foreach (o->entries, it, element) { + rz_pvector_foreach (o->entries, it) { + element = *it; // rebase physical address element->paddr += o->opts.loadaddr; } diff --git a/librz/bin/format/dex/dex.c b/librz/bin/format/dex/dex.c index 14abc966d71..4aea208f869 100644 --- a/librz/bin/format/dex/dex.c +++ b/librz/bin/format/dex/dex.c @@ -1688,12 +1688,12 @@ RZ_API RZ_OWN RzBinAddr *rz_bin_dex_resolve_symbol(RZ_NONNULL RzBinDex *dex, RzB return ret; } -static RzList /**/ *dex_resolve_entrypoints_in_class(RzBinDex *dex, DexClassDef *class_def) { +static RzPVector /**/ *dex_resolve_entrypoints_in_class(RzBinDex *dex, DexClassDef *class_def) { RzListIter *it; DexEncodedMethod *encoded_method = NULL; - RzList *entrypoints = NULL; + RzPVector *entrypoints = NULL; - entrypoints = rz_list_newf((RzListFree)free); + entrypoints = rz_pvector_new((RzPVectorFree)free); if (!entrypoints) { return NULL; } @@ -1732,7 +1732,7 @@ static RzList /**/ *dex_resolve_entrypoints_in_class(RzBinDex *dex, entrypoint->vaddr = encoded_method->code_offset; entrypoint->paddr = 0; } - if (entrypoint && !rz_list_append(entrypoints, entrypoint)) { + if (entrypoint && !rz_pvector_push(entrypoints, entrypoint)) { free(entrypoint); } } @@ -1776,7 +1776,7 @@ static RzList /**/ *dex_resolve_entrypoints_in_class(RzBinDex *dex, entrypoint->vaddr = encoded_method->code_offset; entrypoint->paddr = 0; } - if (entrypoint && !rz_list_append(entrypoints, entrypoint)) { + if (entrypoint && !rz_pvector_push(entrypoints, entrypoint)) { free(entrypoint); } } @@ -1785,27 +1785,26 @@ static RzList /**/ *dex_resolve_entrypoints_in_class(RzBinDex *dex, } /** - * \brief Returns a RzList containing the dex entripoints + * \brief Returns a RzPVector containing the dex entripoints */ -RZ_API RZ_OWN RzList /**/ *rz_bin_dex_entrypoints(RZ_NONNULL RzBinDex *dex) { +RZ_API RZ_OWN RzPVector /**/ *rz_bin_dex_entrypoints(RZ_NONNULL RzBinDex *dex) { rz_return_val_if_fail(dex, NULL); DexClassDef *class_def; - RzList *list = NULL; - RzList *entrypoints = NULL; + RzPVector *entrypoints = NULL, *vec = NULL; void **it; - entrypoints = rz_list_newf((RzListFree)free); + entrypoints = rz_pvector_new((RzPVectorFree)free); if (!entrypoints) { return NULL; } rz_pvector_foreach (dex->class_defs, it) { class_def = (DexClassDef *)*it; - list = dex_resolve_entrypoints_in_class(dex, class_def); - if (list) { - rz_list_join(entrypoints, list); - rz_list_free(list); + vec = dex_resolve_entrypoints_in_class(dex, class_def); + if (vec) { + rz_pvector_join(entrypoints, vec); + rz_pvector_free(vec); } } diff --git a/librz/bin/format/dex/dex.h b/librz/bin/format/dex/dex.h index 0f599d9f4b3..93dc42f3642 100644 --- a/librz/bin/format/dex/dex.h +++ b/librz/bin/format/dex/dex.h @@ -215,7 +215,7 @@ RZ_API RZ_OWN RzPVector /**/ *rz_bin_dex_symbols(RZ_NONNULL RzBin RZ_API RZ_OWN RzPVector /**/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex *dex); RZ_API RZ_OWN RzPVector /**/ *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); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_dex_entrypoints(RZ_NONNULL RzBinDex *dex); RZ_API RZ_BORROW RzBuffer *rz_bin_dex_relocations(RZ_NONNULL RzBinDex *dex); RZ_API RZ_OWN char *rz_bin_dex_resolve_method_by_idx(RZ_NONNULL RzBinDex *dex, ut32 method_idx); diff --git a/librz/bin/format/java/class_bin.c b/librz/bin/format/java/class_bin.c index a5135a5ecc3..75766d479b2 100644 --- a/librz/bin/format/java/class_bin.c +++ b/librz/bin/format/java/class_bin.c @@ -932,13 +932,13 @@ RZ_API RZ_OWN RzBinAddr *rz_bin_java_class_resolve_symbol(RZ_NONNULL RzBinJavaCl } /** - * \brief Returns a RzList containing the entrypoints + * \brief Returns a RzPVector containing the entrypoints */ -RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_entrypoints(RZ_NONNULL RzBinJavaClass *bin) { +RZ_API RZ_OWN RzPVector /**/ *rz_bin_java_class_entrypoints(RZ_NONNULL RzBinJavaClass *bin) { rz_return_val_if_fail(bin, NULL); - RzList *list = rz_list_newf(free); - if (!list) { + RzPVector *vec = rz_pvector_new(free); + if (!vec) { return NULL; } @@ -984,10 +984,10 @@ RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_entrypoints(RZ_NONNULL continue; } entrypoint->vaddr = entrypoint->paddr = addr; - rz_list_append(list, entrypoint); + rz_pvector_push(vec, entrypoint); } } - return list; + return vec; } /** diff --git a/librz/bin/format/java/class_bin.h b/librz/bin/format/java/class_bin.h index 64effa04669..059999481a8 100644 --- a/librz/bin/format/java/class_bin.h +++ b/librz/bin/format/java/class_bin.h @@ -83,7 +83,7 @@ RZ_API RZ_OWN char *rz_bin_java_class_const_pool_resolve_index(RZ_NONNULL RzBinJ RZ_API void rz_bin_java_class_as_source_code(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb); RZ_API RZ_OWN RzBinAddr *rz_bin_java_class_resolve_symbol(RZ_NONNULL RzBinJavaClass *bin, RzBinSpecialSymbol resolve); RZ_API RZ_OWN RzPVector /**/ *rz_bin_java_class_strings(RZ_NONNULL RzBinJavaClass *bin); -RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_entrypoints(RZ_NONNULL RzBinJavaClass *bin); +RZ_API RZ_OWN RzPVector /**/ *rz_bin_java_class_entrypoints(RZ_NONNULL RzBinJavaClass *bin); RZ_API RZ_OWN RzList /**/ *rz_bin_java_class_methods_as_symbols(RZ_NONNULL RzBinJavaClass *bin); RZ_API void rz_bin_java_class_methods_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb); RZ_API void rz_bin_java_class_methods_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j); diff --git a/librz/bin/format/le/le.c b/librz/bin/format/le/le.c index 8c0086aa2bb..c3d792c14ff 100644 --- a/librz/bin/format/le/le.c +++ b/librz/bin/format/le/le.c @@ -1649,14 +1649,14 @@ RZ_OWN RzPVector /**/ *rz_bin_le_get_sections(RzBinFile *bf) { return sections; } -RZ_OWN RzList /**/ *rz_bin_le_get_entry_points(RzBinFile *bf) { +RZ_OWN RzPVector /**/ *rz_bin_le_get_entry_points(RzBinFile *bf) { rz_bin_le_obj_t *bin = bf->o->bin_obj; LE_header *h = bin->header; RzBinAddr *addr = NULL; - RzList *entries = rz_list_newf((RzListFree)free); + RzPVector *entries = rz_pvector_new((RzPVectorFree)free); if (!entries) { fail_cleanup: - rz_list_free(entries); + rz_pvector_free(entries); free(addr); return NULL; } @@ -1667,7 +1667,7 @@ RZ_OWN RzList /**/ *rz_bin_le_get_entry_points(RzBinFile *bf) { CHECK(addr = RZ_NEW0(RzBinAddr)); addr->vaddr = bin->objects[h->startobj - 1].reloc_base_addr + h->eip; addr->paddr = le_vaddr_to_paddr(bin, addr->vaddr); - CHECK(rz_list_append(entries, addr)); + CHECK(rz_pvector_push(entries, addr)); addr = NULL; } @@ -1678,7 +1678,7 @@ RZ_OWN RzList /**/ *rz_bin_le_get_entry_points(RzBinFile *bf) { CHECK(addr = RZ_NEW0(RzBinAddr)); addr->vaddr = e->symbol->vaddr; addr->paddr = le_vaddr_to_paddr(bin, addr->vaddr); - CHECK(rz_list_append(entries, addr)); + CHECK(rz_pvector_push(entries, addr)); addr = NULL; } } diff --git a/librz/bin/format/le/le.h b/librz/bin/format/le/le.h index c2df90e9c73..b0ca3724c40 100644 --- a/librz/bin/format/le/le.h +++ b/librz/bin/format/le/le.h @@ -104,7 +104,7 @@ bool rz_bin_le_check_buffer(RzBuffer *b); bool rz_bin_le_load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb); void rz_bin_le_destroy(RzBinFile *bf); RZ_OWN RzPVector /**/ *rz_bin_le_get_maps(RzBinFile *bf); -RZ_OWN RzList /**/ *rz_bin_le_get_entry_points(RzBinFile *bf); +RZ_OWN RzPVector /**/ *rz_bin_le_get_entry_points(RzBinFile *bf); RZ_OWN RzPVector /**/ *rz_bin_le_get_sections(RzBinFile *bf); RZ_OWN RzPVector /**/ *rz_bin_le_get_symbols(RzBinFile *bf); RZ_OWN RzPVector /**/ *rz_bin_le_get_imports(RzBinFile *bf); diff --git a/librz/bin/format/luac/luac_bin.c b/librz/bin/format/luac/luac_bin.c index a3531c53e27..44c0f034a71 100644 --- a/librz/bin/format/luac/luac_bin.c +++ b/librz/bin/format/luac/luac_bin.c @@ -44,7 +44,7 @@ void luac_add_symbol(RzList /**/ *symbol_list, char *name, ut64 o rz_list_append(symbol_list, bin_sym); } -void luac_add_entry(RzList /**/ *entry_list, ut64 offset, int entry_type) { +void luac_add_entry(RzPVector /**/ *entry_vec, ut64 offset, int entry_type) { RzBinAddr *entry = RZ_NEW0(RzBinAddr); if (!entry) { return; @@ -54,7 +54,7 @@ void luac_add_entry(RzList /**/ *entry_list, ut64 offset, int entry entry->paddr = offset; entry->type = entry_type; - rz_list_append(entry_list, entry); + rz_pvector_push(entry_vec, entry); } void luac_add_string(RzList /**/ *string_list, char *string, ut64 offset, ut64 size) { @@ -112,7 +112,7 @@ void luac_build_info_free(LuacBinInfo *bin_info) { if (!bin_info) { return; } - rz_list_free(bin_info->entry_list); + rz_pvector_free(bin_info->entry_vec); rz_list_free(bin_info->symbol_list); rz_pvector_free(bin_info->section_vec); rz_list_free(bin_info->string_list); @@ -130,13 +130,13 @@ LuacBinInfo *luac_build_info(LuaProto *proto) { return NULL; } - ret->entry_list = rz_list_newf((RzListFree)free_rz_addr); + ret->entry_vec = rz_pvector_new((RzPVectorFree)free_rz_addr); ret->symbol_list = rz_list_newf((RzListFree)rz_bin_symbol_free); ret->section_vec = rz_pvector_new((RzPVectorFree)free_rz_section); ret->string_list = rz_list_newf((RzListFree)free_rz_string); - if (!(ret->entry_list && ret->symbol_list && ret->section_vec && ret->string_list)) { - rz_list_free(ret->entry_list); + if (!(ret->entry_vec && ret->symbol_list && ret->section_vec && ret->string_list)) { + rz_pvector_free(ret->entry_vec); rz_list_free(ret->symbol_list); rz_pvector_free(ret->section_vec); rz_list_free(ret->string_list); @@ -147,7 +147,7 @@ LuacBinInfo *luac_build_info(LuaProto *proto) { // add entry of main ut64 main_entry_offset; main_entry_offset = proto->code_offset + proto->code_skipped; - luac_add_entry(ret->entry_list, main_entry_offset, RZ_BIN_ENTRY_TYPE_PROGRAM); + luac_add_entry(ret->entry_vec, main_entry_offset, RZ_BIN_ENTRY_TYPE_PROGRAM); return ret; } diff --git a/librz/bin/format/luac/luac_common.h b/librz/bin/format/luac/luac_common.h index fa7114cb01b..e8014fabaf0 100644 --- a/librz/bin/format/luac/luac_common.h +++ b/librz/bin/format/luac/luac_common.h @@ -161,7 +161,7 @@ typedef struct luac_bin_info { st32 minor; ///< minor version RzPVector /**/ *section_vec; ///< list of sections RzList /**/ *symbol_list; ///< list of symbols - RzList /**/ *entry_list; ///< list of entries + RzPVector /**/ *entry_vec; ///< list of entries RzList /**/ *string_list; ///< list of strings RzBinInfo *general_info; ///< general binary info from luac header } LuacBinInfo; @@ -187,9 +187,9 @@ void lua_free_proto_entry(LuaProto *); * Common Operation to RzBinInfo * Implemented in 'bin/format/luac/luac_bin.c' * ======================================================== */ -void luac_add_section(RzPVector /**/ *section_list, char *name, ut64 offset, ut32 size, bool is_func); +void luac_add_section(RzPVector /**/ *section_vec, char *name, ut64 offset, ut32 size, bool is_func); void luac_add_symbol(RzList /**/ *symbol_list, char *name, ut64 offset, ut64 size, const char *type); -void luac_add_entry(RzList /**/ *entry_list, ut64 offset, int entry_type); +void luac_add_entry(RzPVector /**/ *entry_vec, ut64 offset, int entry_type); void luac_add_string(RzList /**/ *string_list, char *string, ut64 offset, ut64 size); LuacBinInfo *luac_build_info(LuaProto *proto); diff --git a/librz/bin/format/mdmp/mdmp_pe.c b/librz/bin/format/mdmp/mdmp_pe.c index d5914f0412a..25ceb2a9786 100644 --- a/librz/bin/format/mdmp/mdmp_pe.c +++ b/librz/bin/format/mdmp/mdmp_pe.c @@ -7,7 +7,7 @@ #include "mdmp_pe.h" -static void PE_(add_tls_callbacks)(struct PE_(rz_bin_pe_obj_t) * bin, RzList /**/ *list) { +static void PE_(add_tls_callbacks)(struct PE_(rz_bin_pe_obj_t) * bin, RzPVector /**/ *vec) { char *key; int count = 0; PE_DWord haddr, paddr, vaddr; @@ -36,22 +36,22 @@ static void PE_(add_tls_callbacks)(struct PE_(rz_bin_pe_obj_t) * bin, RzList /*< ptr->vaddr = vaddr; ptr->hpaddr = haddr; ptr->type = RZ_BIN_ENTRY_TYPE_TLS; - rz_list_append(list, ptr); + rz_pvector_push(vec, ptr); } count++; } while (vaddr); } -RzList /**/ *PE_(rz_bin_mdmp_pe_get_entrypoint)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin) { +RzPVector /**/ *PE_(rz_bin_mdmp_pe_get_entrypoint)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin) { ut64 offset; struct rz_bin_pe_addr_t *entry = NULL; RzBinAddr *ptr = NULL; - RzList *ret; + RzPVector *ret; if (!(entry = PE_(rz_bin_pe_get_entrypoint)(pe_bin->bin))) { return NULL; } - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(NULL))) { free(entry); return NULL; } @@ -66,7 +66,7 @@ RzList /**/ *PE_(rz_bin_mdmp_pe_get_entrypoint)(struct PE_(rz_bin_m ptr->hpaddr = pe_bin->paddr + entry->haddr; ptr->type = RZ_BIN_ENTRY_TYPE_PROGRAM; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } PE_(add_tls_callbacks) diff --git a/librz/bin/format/mdmp/mdmp_pe.h b/librz/bin/format/mdmp/mdmp_pe.h index 7fa08db16bf..5ac18e40412 100644 --- a/librz/bin/format/mdmp/mdmp_pe.h +++ b/librz/bin/format/mdmp/mdmp_pe.h @@ -20,7 +20,7 @@ struct PE_(rz_bin_mdmp_pe_bin) { struct PE_(rz_bin_pe_obj_t) * bin; }; -RzList /**/ *PE_(rz_bin_mdmp_pe_get_entrypoint)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin); +RzPVector /**/ *PE_(rz_bin_mdmp_pe_get_entrypoint)(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); RzPVector /**/ *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 1ddddd7f1f5..5501174cb78 100644 --- a/librz/bin/format/ne/ne.c +++ b/librz/bin/format/ne/ne.c @@ -125,7 +125,7 @@ RzPVector /**/ *rz_bin_ne_get_symbols(rz_bin_ne_obj_t *bin) { if (!symbols) { return NULL; } - RzList *entries = rz_bin_ne_get_entrypoints(bin); + RzPVector *entries = rz_bin_ne_get_entrypoints(bin); bool resident = true, first = true; while (true) { ut8 sz; @@ -170,7 +170,7 @@ RzPVector /**/ *rz_bin_ne_get_symbols(rz_bin_ne_obj_t *bin) { break; } off += 2; - RzBinAddr *entry = rz_list_get_n(entries, entry_off); + RzBinAddr *entry = (RzBinAddr *)rz_pvector_at(entries, entry_off); if (entry) { sym->paddr = entry->paddr; } else { @@ -180,10 +180,11 @@ RzPVector /**/ *rz_bin_ne_get_symbols(rz_bin_ne_obj_t *bin) { rz_pvector_push(symbols, sym); first = false; } - RzListIter *it; + void **it; RzBinAddr *en; int i = 1; - rz_list_foreach (entries, it, en) { + rz_pvector_foreach (entries, it) { + en = *it; if (!rz_pvector_find(symbols, &en->paddr, __find_symbol_by_paddr, NULL)) { sym = RZ_NEW0(RzBinSymbol); if (!sym) { @@ -390,28 +391,28 @@ RzPVector /**/ *rz_bin_ne_get_imports(rz_bin_ne_obj_t *bin) { return imports; } -RzList /**/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin) { - RzList *entries = rz_list_newf(free); +RzPVector /**/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin) { + RzPVector *entries = rz_pvector_new(free); if (!entries) { return NULL; } RzBinAddr *entry; RzPVector *segments = rz_bin_ne_get_segments(bin); if (!segments) { - rz_list_free(entries); + rz_pvector_free(entries); return NULL; } if (bin->ne_header->csEntryPoint) { entry = RZ_NEW0(RzBinAddr); if (!entry) { - rz_list_free(entries); + rz_pvector_free(entries); rz_pvector_free(segments); return NULL; } entry->bits = 16; RzBinSection *s = (RzBinSection *)rz_pvector_at(segments, bin->ne_header->csEntryPoint - 1); entry->paddr = bin->ne_header->ipEntryPoint + (s ? s->paddr : 0); - rz_list_append(entries, entry); + rz_pvector_push(entries, entry); } ut32 off = 0; while (off < bin->ne_header->EntryTableLength) { @@ -429,7 +430,7 @@ RzList /**/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin) { for (i = 0; i < bundle_length; i++) { entry = RZ_NEW0(RzBinAddr); if (!entry) { - rz_list_free(entries); + rz_pvector_free(entries); rz_pvector_free(segments); return NULL; } @@ -465,7 +466,7 @@ RzList /**/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin) { entry->paddr = (ut64)bin->segment_entries[bundle_type - 1].offset * bin->alignment + rz_read_le16(p); } off += 2; - rz_list_append(entries, entry); + rz_pvector_push(entries, entry); } } end: @@ -479,7 +480,7 @@ RzPVector /**/ *rz_bin_ne_get_relocs(rz_bin_ne_obj_t *bin) { if (!segments) { return NULL; } - RzList *entries = bin->entries; + RzPVector *entries = bin->entries; if (!entries) { return NULL; } @@ -589,7 +590,7 @@ RzPVector /**/ *rz_bin_ne_get_relocs(rz_bin_ne_obj_t *bin) { offset = -1; } } else { - RzBinAddr *entry = rz_list_get_n(entries, rel.entry_ordinal - 1); + RzBinAddr *entry = (RzBinAddr *)rz_pvector_at(entries, rel.entry_ordinal - 1); if (entry) { offset = entry->paddr; } else { diff --git a/librz/bin/format/ne/ne.h b/librz/bin/format/ne/ne.h index d0a5de725ee..955adfbbab2 100644 --- a/librz/bin/format/ne/ne.h +++ b/librz/bin/format/ne/ne.h @@ -29,7 +29,7 @@ typedef struct { ut8 *resident_name_table; RzBuffer *buf; RzPVector /**/ *segments; - RzList /**/ *entries; + RzPVector /**/ *entries; RzList /**/ *resources; RzPVector /**/ *imports; RzPVector /**/ *symbols; @@ -42,6 +42,6 @@ RzPVector /**/ *rz_bin_ne_get_relocs(rz_bin_ne_obj_t *bin); RzPVector /**/ *rz_bin_ne_get_imports(rz_bin_ne_obj_t *bin); RzPVector /**/ *rz_bin_ne_get_symbols(rz_bin_ne_obj_t *bin); RzPVector /**/ *rz_bin_ne_get_segments(rz_bin_ne_obj_t *bin); -RzList /**/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin); +RzPVector /**/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin); #endif diff --git a/librz/bin/p/bin_art.c b/librz/bin/p/bin_art.c index 1701f1267f2..6447d2e7572 100644 --- a/librz/bin/p/bin_art.c +++ b/librz/bin/p/bin_art.c @@ -132,13 +132,13 @@ static bool check_buffer(RzBuffer *buf) { return r == 4 && !strncmp(tmp, "art\n", 4); } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret = rz_list_newf(free); +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret = rz_pvector_new(free); if (ret) { RzBinAddr *ptr = RZ_NEW0(RzBinAddr); if (ptr) { ptr->paddr = ptr->vaddr = 0; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } } return ret; diff --git a/librz/bin/p/bin_avr.c b/librz/bin/p/bin_avr.c index 2b586b8e28a..c24c5adda9e 100644 --- a/librz/bin/p/bin_avr.c +++ b/librz/bin/p/bin_avr.c @@ -139,20 +139,19 @@ static RzBinInfo *info(RzBinFile *bf) { return bi; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBinAddr *ptr = NULL; if (tmp_entry == UT64_MAX) { return false; } - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(free))) { return NULL; } - ret->free = free; if ((ptr = RZ_NEW0(RzBinAddr))) { ut64 addr = tmp_entry; ptr->vaddr = ptr->paddr = addr; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_bf.c b/librz/bin/p/bin_bf.c index b37218c8053..314c47fe895 100644 --- a/librz/bin/p/bin_bf.c +++ b/librz/bin/p/bin_bf.c @@ -98,18 +98,18 @@ static bool check_filename(const char *filename) { return rz_str_endswith_icase(filename, ".bf"); } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBinAddr *ptr = NULL; - if (!(ret = rz_list_newf(free))) { + if (!(ret = rz_pvector_new(free))) { return NULL; } if (!(ptr = RZ_NEW0(RzBinAddr))) { return ret; } ptr->paddr = ptr->vaddr = 0; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_bflt.c b/librz/bin/p/bin_bflt.c index 5e9eb1b6ac4..ce96a239eb2 100644 --- a/librz/bin/p/bin_bflt.c +++ b/librz/bin/p/bin_bflt.c @@ -16,20 +16,20 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb return obj->bin_obj; } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { RzBfltObj *obj = bf->o->bin_obj; - RzList *ret; + RzPVector *ret; RzBinAddr *ptr; - if (!(ret = rz_list_newf(free))) { + if (!(ret = rz_pvector_new(free))) { return NULL; } ptr = rz_bflt_get_entry(obj); if (!ptr) { - rz_list_free(ret); + rz_pvector_free(ret); return NULL; } - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_bios.c b/librz/bin/p/bin_bios.c index 7ad5411523f..00168210cc9 100644 --- a/librz/bin/p/bin_bios.c +++ b/librz/bin/p/bin_bios.c @@ -117,19 +117,18 @@ static RzPVector /**/ *sections(RzBinFile *bf) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBinAddr *ptr = NULL; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(free))) { return NULL; } - ret->free = free; if (!(ptr = RZ_NEW0(RzBinAddr))) { return ret; } ptr->paddr = 0; // 0x70000; ptr->vaddr = 0xffff0; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_bootimg.c b/librz/bin/p/bin_bootimg.c index 27ec38473db..46fb1594f27 100644 --- a/librz/bin/p/bin_bootimg.c +++ b/librz/bin/p/bin_bootimg.c @@ -152,16 +152,16 @@ static bool check_buffer(RzBuffer *buf) { return r > 12 && !strncmp((const char *)tmp, "ANDROID!", 8); } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { BootImageObj *bio = bf->o->bin_obj; RzBinAddr *ptr = NULL; if (!bio) { return NULL; } BootImage *bi = &bio->bi; - RzList *ret; + RzPVector *ret; - if (!(ret = rz_list_newf(free))) { + if (!(ret = rz_pvector_new(free))) { return NULL; } if (!(ptr = RZ_NEW0(RzBinAddr))) { @@ -169,7 +169,7 @@ static RzList /**/ *entries(RzBinFile *bf) { } ptr->paddr = bi->page_size; ptr->vaddr = bi->kernel_addr; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_coff.c b/librz/bin/p/bin_coff.c index 16f338fdb38..71b116337b6 100644 --- a/librz/bin/p/bin_coff.c +++ b/librz/bin/p/bin_coff.c @@ -166,15 +166,15 @@ static RzBinImport *_fill_bin_import(struct rz_bin_coff_obj *bin, int idx) { return ptr; } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj; - RzList *ret; - if (!(ret = rz_list_newf(free))) { + RzPVector *ret; + if (!(ret = rz_pvector_new(free))) { return NULL; } RzBinAddr *ptr = rz_coff_get_entry(obj); if (ptr) { - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_dex.c b/librz/bin/p/bin_dex.c index 6caa9e35c4c..da0aaf6b035 100644 --- a/librz/bin/p/bin_dex.c +++ b/librz/bin/p/bin_dex.c @@ -122,7 +122,7 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol sym) { return rz_bin_dex_resolve_symbol(dex, sym); } -static RzList /**/ *entrypoints(RzBinFile *bf) { +static RzPVector /**/ *entrypoints(RzBinFile *bf) { RzBinDex *dex = rz_bin_file_get_dex(bf); if (!dex) { return NULL; diff --git a/librz/bin/p/bin_dol.c b/librz/bin/p/bin_dol.c index 02220a12752..96ee40abc2d 100644 --- a/librz/bin/p/bin_dol.c +++ b/librz/bin/p/bin_dol.c @@ -134,14 +134,14 @@ static RzPVector /**/ *sections(RzBinFile *bf) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { rz_return_val_if_fail(bf && bf->o && bf->o->bin_obj, NULL); - RzList *ret = rz_list_new(); + RzPVector *ret = rz_pvector_new(NULL); RzBinAddr *addr = RZ_NEW0(RzBinAddr); DolHeader *dol = bf->o->bin_obj; addr->vaddr = (ut64)dol->entrypoint; addr->paddr = addr->vaddr & 0xFFFF; - rz_list_append(ret, addr); + rz_pvector_push(ret, addr); return ret; } diff --git a/librz/bin/p/bin_dyldcache.c b/librz/bin/p/bin_dyldcache.c index 395adf04a4d..c66657d93fd 100644 --- a/librz/bin/p/bin_dyldcache.c +++ b/librz/bin/p/bin_dyldcache.c @@ -81,14 +81,14 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb return true; } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { RzBinAddr *ptr = NULL; - RzList *ret = rz_list_newf(free); + RzPVector *ret = rz_pvector_new(free); if (!ret) { return NULL; } if ((ptr = RZ_NEW0(RzBinAddr))) { - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_elf.inc b/librz/bin/p/bin_elf.inc index 8d2cfefb6b6..71b8fcecc2a 100644 --- a/librz/bin/p/bin_elf.inc +++ b/librz/bin/p/bin_elf.inc @@ -273,7 +273,7 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol sym) { return rz_bin_addr_new_from_paddr(bin, paddr); } -static void add_constructor(ELFOBJ *bin, ut64 addr, ut64 size, int type, RzList /**/ *result) { +static void add_constructor(ELFOBJ *bin, ut64 addr, ut64 size, int type, RzPVector /**/ *result) { ut64 constructor_offset = Elf_(rz_bin_elf_v2p)(bin, addr); if (constructor_offset == UT64_MAX) { return; @@ -303,13 +303,13 @@ static void add_constructor(ELFOBJ *bin, ut64 addr, ut64 size, int type, RzList tmp->hvaddr = addr + pos; tmp->type = type; - rz_list_append(result, tmp); + rz_pvector_push(result, tmp); pos += sizeof(Elf_(Addr)); } } -static void add_constructors(ELFOBJ *bin, RzList /**/ *result) { +static void add_constructors(ELFOBJ *bin, RzPVector /**/ *result) { ut64 addr, size; if (Elf_(rz_bin_elf_get_dt_info)(bin, DT_PREINIT_ARRAY, &addr) && Elf_(rz_bin_elf_get_dt_info)(bin, DT_PREINIT_ARRAYSZ, &size)) { @@ -325,7 +325,7 @@ static void add_constructors(ELFOBJ *bin, RzList /**/ *result) { } } -static void add_entry_offset(ELFOBJ *bin, RzList /**/ *result) { +static void add_entry_offset(ELFOBJ *bin, RzPVector /**/ *result) { ut64 paddr = Elf_(rz_bin_elf_get_entry_offset)(bin); if (paddr == UT64_MAX) { return; @@ -343,28 +343,28 @@ static void add_entry_offset(ELFOBJ *bin, RzList /**/ *result) { RZ_LOG_ERROR("Cannot determine entrypoint, using 0x%08" PFMT64x ".\n", tmp->vaddr); } - rz_list_append(result, tmp); + rz_pvector_push(result, tmp); } -static void add_java_libraries(ELFOBJ *bin, RzList /**/ *result) { +static void add_java_libraries(ELFOBJ *bin, RzPVector /**/ *result) { RzBinElfSymbol *symbol; rz_bin_elf_foreach_symbols(bin, symbol) { if (symbol->name && rz_str_startswith(symbol->name, "Java") && rz_str_endswith(symbol->name, "_init")) { RzBinAddr *tmp = rz_bin_addr_new_from_paddr(bin, symbol->paddr); tmp->type = RZ_BIN_ENTRY_TYPE_INIT; - rz_list_append(result, tmp); + rz_pvector_push(result, tmp); break; } } } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { rz_return_val_if_fail(bf && bf->o, NULL); ELFOBJ *bin = rz_bin_file_get_elf(bf); - RzList *result = rz_list_newf((RzListFree)free); + RzPVector *result = rz_pvector_new((RzPVectorFree)free); if (!result) { return NULL; } diff --git a/librz/bin/p/bin_java.c b/librz/bin/p/bin_java.c index 8e472f5cd70..ab1c52ac929 100644 --- a/librz/bin/p/bin_java.c +++ b/librz/bin/p/bin_java.c @@ -149,7 +149,7 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol sym) { return rz_bin_java_class_resolve_symbol(jclass, sym); } -static RzList /**/ *entrypoints(RzBinFile *bf) { +static RzPVector /**/ *entrypoints(RzBinFile *bf) { RzBinJavaClass *jclass = rz_bin_file_get_java_class(bf); if (!jclass) { return NULL; diff --git a/librz/bin/p/bin_luac.c b/librz/bin/p/bin_luac.c index 37132da7bf1..4f490d19236 100644 --- a/librz/bin/p/bin_luac.c +++ b/librz/bin/p/bin_luac.c @@ -112,7 +112,7 @@ static RzPVector /**/ *symbols(RzBinFile *bf) { return vec; } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { if (!bf) { return NULL; } @@ -121,7 +121,7 @@ static RzList /**/ *entries(RzBinFile *bf) { return NULL; } - return rz_list_clone(bin_info_obj->entry_list); + return rz_pvector_clone(bin_info_obj->entry_vec); } static RzPVector /**/ *strings(RzBinFile *bf) { diff --git a/librz/bin/p/bin_mach0.c b/librz/bin/p/bin_mach0.c index cfdb023f063..47bc346ffc2 100644 --- a/librz/bin/p/bin_mach0.c +++ b/librz/bin/p/bin_mach0.c @@ -94,7 +94,7 @@ static RzBinAddr *newEntry(ut64 hpaddr, ut64 paddr, int type, int bits) { return ptr; } -static void process_constructors(RzBinFile *bf, RzList /**/ *ret, int bits) { +static void process_constructors(RzBinFile *bf, RzPVector /**/ *ret, int bits) { RzPVector *secs = sections(bf); void **iter; RzBinSection *sec; @@ -122,7 +122,7 @@ static void process_constructors(RzBinFile *bf, RzList /**/ *ret, i ut32 addr32 = rz_read_le32(buf + i); RzBinAddr *ba = newEntry(sec->paddr + i, (ut64)addr32, type, bits); if (ba) { - rz_list_append(ret, ba); + rz_pvector_push(ret, ba); } } } else { @@ -130,7 +130,7 @@ static void process_constructors(RzBinFile *bf, RzList /**/ *ret, i ut64 addr64 = rz_read_le64(buf + i); RzBinAddr *ba = newEntry(sec->paddr + i, addr64, type, bits); if (ba) { - rz_list_append(ret, ba); + rz_pvector_push(ret, ba); } } } @@ -139,13 +139,13 @@ static void process_constructors(RzBinFile *bf, RzList /**/ *ret, i } } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { rz_return_val_if_fail(bf && bf->o, NULL); RzBinAddr *ptr = NULL; struct addr_t *entry = NULL; - RzList *ret = rz_list_newf(free); + RzPVector *ret = rz_pvector_new(free); if (!ret) { return NULL; } @@ -166,7 +166,7 @@ static RzList /**/ *entries(RzBinFile *bf) { ptr->vaddr--; } } - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } process_constructors(bf, ret, bits); diff --git a/librz/bin/p/bin_mbn.c b/librz/bin/p/bin_mbn.c index 19873c951f6..33304588bfa 100644 --- a/librz/bin/p/bin_mbn.c +++ b/librz/bin/p/bin_mbn.c @@ -85,15 +85,15 @@ static ut64 baddr(RzBinFile *bf) { return sb->vaddr; } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { SblHeader *sb = mbn_file_get_hdr(bf); - RzList *ret = rz_list_newf(free); + RzPVector *ret = rz_pvector_new(free); if (ret) { RzBinAddr *ptr = RZ_NEW0(RzBinAddr); if (ptr) { ptr->paddr = 40 + sb->code_pa; ptr->vaddr = 40 + sb->code_pa + sb->vaddr; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } } return ret; diff --git a/librz/bin/p/bin_mdmp.c b/librz/bin/p/bin_mdmp.c index 66760cca2ab..c431c91b7f9 100644 --- a/librz/bin/p/bin_mdmp.c +++ b/librz/bin/p/bin_mdmp.c @@ -20,28 +20,28 @@ static void mdmp_destroy(RzBinFile *bf) { rz_bin_mdmp_free((MiniDmpObj *)bf->o->bin_obj); } -static RzList /**/ *mdmp_entries(RzBinFile *bf) { +static RzPVector /**/ *mdmp_entries(RzBinFile *bf) { MiniDmpObj *obj; struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin; struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin; RzListIter *it; - RzList *ret, *list; + RzPVector *ret, *vec; - if (!(ret = rz_list_newf(free))) { + if (!(ret = rz_pvector_new(free))) { return NULL; } obj = (MiniDmpObj *)bf->o->bin_obj; rz_list_foreach (obj->pe32_bins, it, pe32_bin) { - list = Pe32_rz_bin_mdmp_pe_get_entrypoint(pe32_bin); - rz_list_join(ret, list); - rz_list_free(list); + vec = Pe32_rz_bin_mdmp_pe_get_entrypoint(pe32_bin); + rz_pvector_join(ret, vec); + rz_pvector_free(vec); } rz_list_foreach (obj->pe64_bins, it, pe64_bin) { - list = Pe64_rz_bin_mdmp_pe_get_entrypoint(pe64_bin); - rz_list_join(ret, list); - rz_list_free(list); + vec = Pe64_rz_bin_mdmp_pe_get_entrypoint(pe64_bin); + rz_pvector_join(ret, vec); + rz_pvector_free(vec); } return ret; diff --git a/librz/bin/p/bin_menuet.c b/librz/bin/p/bin_menuet.c index ac776605173..14d54721c7a 100644 --- a/librz/bin/p/bin_menuet.c +++ b/librz/bin/p/bin_menuet.c @@ -84,8 +84,8 @@ static ut64 menuetEntry(const ut8 *buf, int buf_size) { return UT64_MAX; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; ut8 buf[64] = { 0 }; RzBinAddr *ptr = NULL; const int buf_size = RZ_MIN(sizeof(buf), rz_buf_size(bf->buf)); @@ -95,14 +95,13 @@ static RzList /**/ *entries(RzBinFile *bf) { if (entry == UT64_MAX) { return NULL; } - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(free))) { return NULL; } - ret->free = free; if ((ptr = RZ_NEW0(RzBinAddr))) { ptr->paddr = rz_read_ble32(buf + 12, false); ptr->vaddr = ptr->paddr + baddr(bf); - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_mz.c b/librz/bin/p/bin_mz.c index be0ab356712..241113df1e2 100644 --- a/librz/bin/p/bin_mz.c +++ b/librz/bin/p/bin_mz.c @@ -149,15 +149,15 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { return mzaddr; } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { RzBinAddr *ptr = NULL; - RzList *res = NULL; - if (!(res = rz_list_newf(free))) { + RzPVector *res = NULL; + if (!(res = rz_pvector_new(free))) { return NULL; } ptr = rz_bin_mz_get_entrypoint(bf->o->bin_obj); if (ptr) { - rz_list_append(res, ptr); + rz_pvector_push(res, ptr); } return res; } diff --git a/librz/bin/p/bin_ne.c b/librz/bin/p/bin_ne.c index bce3aa0d0a2..f18f9fc0d31 100644 --- a/librz/bin/p/bin_ne.c +++ b/librz/bin/p/bin_ne.c @@ -95,7 +95,7 @@ RzBinInfo *info(RzBinFile *bf) { return i; } -RzList /**/ *entries(RzBinFile *bf) { +RzPVector /**/ *entries(RzBinFile *bf) { return rz_bin_ne_get_entrypoints(bf->o->bin_obj); } diff --git a/librz/bin/p/bin_nes.c b/librz/bin/p/bin_nes.c index 6c431f96e9a..c065bf6092f 100644 --- a/librz/bin/p/bin_nes.c +++ b/librz/bin/p/bin_nes.c @@ -199,10 +199,10 @@ static RzPVector /**/ *mem(RzBinFile *bf) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { // Should be 3 offsets pointed by NMI, RESET, IRQ after mapping && default = 1st CHR - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { // Should be 3 offsets pointed by NMI, RESET, IRQ after mapping && default = 1st CHR + RzPVector *ret; RzBinAddr *ptr = NULL; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(NULL))) { return NULL; } if (!(ptr = RZ_NEW0(RzBinAddr))) { @@ -210,7 +210,7 @@ static RzList /**/ *entries(RzBinFile *bf) { // Should be 3 offsets } ptr->paddr = INES_HDR_SIZE; ptr->vaddr = ROM_START_ADDRESS; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_nin3ds.c b/librz/bin/p/bin_nin3ds.c index f505cdfa82b..0340378133b 100644 --- a/librz/bin/p/bin_nin3ds.c +++ b/librz/bin/p/bin_nin3ds.c @@ -161,17 +161,17 @@ static RzPVector /**/ *n3ds_sections(RzBinFile *bf) { return ret; } -static RzList /**/ *n3ds_entries(RzBinFile *bf) { +static RzPVector /**/ *n3ds_entries(RzBinFile *bf) { if (!bf || !bf->o) { return NULL; } RzBinAddr *ptr9 = NULL, *ptr11 = NULL; - RzList *ret = rz_list_newf(free); + RzPVector *ret = rz_pvector_new(free); if (!ret || !(ptr9 = RZ_NEW0(RzBinAddr)) || !(ptr11 = RZ_NEW0(RzBinAddr))) { - rz_list_free(ret); + rz_pvector_free(ret); free(ptr9); return NULL; } @@ -179,11 +179,11 @@ static RzList /**/ *n3ds_entries(RzBinFile *bf) { /* ARM9 entry point */ ptr9->vaddr = hdr->arm9_ep; - rz_list_append(ret, ptr9); + rz_pvector_push(ret, ptr9); /* ARM11 entry point */ ptr11->vaddr = hdr->arm11_ep; - rz_list_append(ret, ptr11); + rz_pvector_push(ret, ptr11); for (size_t i = 0; i < 4; i++) { N3DSFirmSectHdr *shdr = &hdr->sections[i]; diff --git a/librz/bin/p/bin_ninds.c b/librz/bin/p/bin_ninds.c index c1db7a318cd..28fbdeb3b8c 100644 --- a/librz/bin/p/bin_ninds.c +++ b/librz/bin/p/bin_ninds.c @@ -150,17 +150,17 @@ static RzPVector /**/ *nds_sections(RzBinFile *bf) { return ret; } -static RzList /**/ *nds_entries(RzBinFile *bf) { +static RzPVector /**/ *nds_entries(RzBinFile *bf) { if (!bf || !bf->buf) { return NULL; } RzBinAddr *ptr9 = NULL, *ptr7 = NULL; - RzList *ret = NULL; + RzPVector *ret = NULL; - if (!(ret = rz_list_newf(free)) || + if (!(ret = rz_pvector_new(free)) || !(ptr9 = RZ_NEW0(RzBinAddr)) || !(ptr7 = RZ_NEW0(RzBinAddr))) { - rz_list_free(ret); + rz_pvector_free(ret); free(ptr9); return NULL; } @@ -169,12 +169,12 @@ static RzList /**/ *nds_entries(RzBinFile *bf) { /* ARM9 entry point */ ptr9->vaddr = hdr->arm9_entry_address; ptr9->paddr = hdr->arm9_rom_offset + (hdr->arm9_entry_address - hdr->arm9_ram_address); - rz_list_append(ret, ptr9); + rz_pvector_push(ret, ptr9); /* ARM7 entry point */ ptr7->vaddr = hdr->arm7_entry_address; ptr7->paddr = hdr->arm7_rom_offset + (hdr->arm7_entry_address - hdr->arm7_ram_address); - rz_list_append(ret, ptr7); + rz_pvector_push(ret, ptr7); return ret; } diff --git a/librz/bin/p/bin_ningb.c b/librz/bin/p/bin_ningb.c index c1f0cd18201..fe0f74703e9 100644 --- a/librz/bin/p/bin_ningb.c +++ b/librz/bin/p/bin_ningb.c @@ -41,20 +41,19 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { return NULL; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret = rz_list_new(); +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret = rz_pvector_new(free); RzBinAddr *ptr = NULL; if (bf && bf->buf != NULL) { if (!ret) { return NULL; } - ret->free = free; if (!(ptr = RZ_NEW0(RzBinAddr))) { return ret; } ptr->paddr = ptr->vaddr = ptr->hpaddr = 0x100; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_ningba.c b/librz/bin/p/bin_ningba.c index fb95587368e..8c5d7136baa 100644 --- a/librz/bin/p/bin_ningba.c +++ b/librz/bin/p/bin_ningba.c @@ -19,8 +19,8 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb return check_buffer(buf); } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret = rz_list_newf(free); +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret = rz_pvector_new(free); RzBinAddr *ptr = NULL; if (bf && bf->buf) { @@ -31,7 +31,7 @@ static RzList /**/ *entries(RzBinFile *bf) { return ret; } ptr->paddr = ptr->vaddr = 0x8000000; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_nro.c b/librz/bin/p/bin_nro.c index 196e15a5909..4d50ae7c43f 100644 --- a/librz/bin/p/bin_nro.c +++ b/librz/bin/p/bin_nro.c @@ -73,17 +73,16 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { return NULL; // TODO } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBinAddr *ptr = NULL; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(free))) { return NULL; } - ret->free = free; if ((ptr = RZ_NEW0(RzBinAddr))) { ptr->paddr = 0x80; ptr->vaddr = ptr->paddr + baddr(bf); - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_nso.c b/librz/bin/p/bin_nso.c index 6af46befcdb..ec5f1a7f0a5 100644 --- a/librz/bin/p/bin_nso.c +++ b/librz/bin/p/bin_nso.c @@ -191,32 +191,30 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { return NULL; // TODO } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBuffer *b = bf->buf; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(free))) { return NULL; } - ret->free = free; - RzBinAddr *ptr = RZ_NEW0(RzBinAddr); if (!ptr) { - rz_list_free(ret); + rz_pvector_free(ret); return NULL; } ut32 tmp; if (!rz_buf_read_le32_at(b, NSO_OFF(text_memoffset), &tmp)) { - rz_list_free(ret); + rz_pvector_free(ret); free(ptr); return NULL; } ptr->paddr = tmp; if (!rz_buf_read_le32_at(b, NSO_OFF(text_loc), &tmp)) { - rz_list_free(ret); + rz_pvector_free(ret); free(ptr); return NULL; } @@ -224,7 +222,7 @@ static RzList /**/ *entries(RzBinFile *bf) { ptr->vaddr += baddr(bf); - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_omf.c b/librz/bin/p/bin_omf.c index e856479664d..62e523a15fd 100644 --- a/librz/bin/p/bin_omf.c +++ b/librz/bin/p/bin_omf.c @@ -67,21 +67,21 @@ static ut64 baddr(RzBinFile *bf) { return OMF_BASE_ADDR; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBinAddr *addr; - if (!(ret = rz_list_newf(free))) { + if (!(ret = rz_pvector_new(free))) { return NULL; } if (!(addr = RZ_NEW0(RzBinAddr))) { - rz_list_free(ret); + rz_pvector_free(ret); return NULL; } if (!rz_bin_omf_get_entry(bf->o->bin_obj, addr)) { RZ_FREE(addr); } else { - rz_list_append(ret, addr); + rz_pvector_push(ret, addr); } return ret; } diff --git a/librz/bin/p/bin_p9.c b/librz/bin/p/bin_p9.c index 6c038b24c75..74bd2cba0b0 100644 --- a/librz/bin/p/bin_p9.c +++ b/librz/bin/p/bin_p9.c @@ -28,18 +28,17 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { return NULL; // TODO } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBinAddr *ptr = NULL; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(free))) { return NULL; } - ret->free = free; if ((ptr = RZ_NEW0(RzBinAddr))) { ptr->paddr = 8 * 4; ptr->vaddr = 8 * 4; // + baddr (bf); - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_pe.inc b/librz/bin/p/bin_pe.inc index 1015f9abe09..58dd8deb13c 100644 --- a/librz/bin/p/bin_pe.inc +++ b/librz/bin/p/bin_pe.inc @@ -60,7 +60,7 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { return ret; } -static void add_tls_callbacks(RzBinFile *bf, RzList /**/ *list) { +static void add_tls_callbacks(RzBinFile *bf, RzPVector /**/ *vec) { PE_DWord paddr, vaddr, haddr; int count = 0; RzBinAddr *ptr = NULL; @@ -90,18 +90,18 @@ static void add_tls_callbacks(RzBinFile *bf, RzList /**/ *list) { ptr->vaddr = vaddr; ptr->hpaddr = haddr; ptr->type = RZ_BIN_ENTRY_TYPE_TLS; - rz_list_append(list, ptr); + rz_pvector_push(vec, ptr); } count++; } while (vaddr); } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { struct rz_bin_pe_addr_t *entry = NULL; RzBinAddr *ptr = NULL; - RzList *ret; + RzPVector *ret; - if (!(ret = rz_list_newf(free))) { + if (!(ret = rz_pvector_new(free))) { return NULL; } if (!(entry = PE_(rz_bin_pe_get_entrypoint)(bf->o->bin_obj))) { @@ -112,7 +112,7 @@ static RzList /**/ *entries(RzBinFile *bf) { ptr->vaddr = entry->vaddr; ptr->hpaddr = entry->haddr; ptr->type = RZ_BIN_ENTRY_TYPE_PROGRAM; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } free(entry); // get TLS callback addresses diff --git a/librz/bin/p/bin_pebble.c b/librz/bin/p/bin_pebble.c index 38a8fb4f48b..b656df46e9c 100644 --- a/librz/bin/p/bin_pebble.c +++ b/librz/bin/p/bin_pebble.c @@ -160,24 +160,23 @@ static RzList* relocs(RzBinFile *bf) { } #endif -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { RzBinAddr *ptr = NULL; - RzList *ret; + RzPVector *ret; PebbleAppInfo pai; if (!rz_buf_read_at(bf->buf, 0, (ut8 *)&pai, sizeof(pai))) { RZ_LOG_ERROR("Truncated Header\n"); return NULL; } - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(free))) { return NULL; } - ret->free = free; if (!(ptr = RZ_NEW0(RzBinAddr))) { return ret; } ptr->paddr = pai.offset; ptr->vaddr = pai.offset; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_prg.c b/librz/bin/p/bin_prg.c index 2b8c6ea4b6c..dc80f94a4d6 100644 --- a/librz/bin/p/bin_prg.c +++ b/librz/bin/p/bin_prg.c @@ -60,8 +60,8 @@ static RzPVector /**/ *sections(RzBinFile *bf) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret = rz_list_newf(free); +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret = rz_pvector_new(free); if (!ret) { return NULL; } @@ -71,7 +71,7 @@ static RzList /**/ *entries(RzBinFile *bf) { } binaddr->paddr = 2; binaddr->vaddr = baddr(bf); - rz_list_append(ret, binaddr); + rz_pvector_push(ret, binaddr); return ret; } diff --git a/librz/bin/p/bin_psxexe.c b/librz/bin/p/bin_psxexe.c index ea9915dd6cd..ed6f2fa748a 100644 --- a/librz/bin/p/bin_psxexe.c +++ b/librz/bin/p/bin_psxexe.c @@ -80,23 +80,23 @@ static RzPVector /**/ *sections(RzBinFile *bf) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret = NULL; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret = NULL; RzBinAddr *addr = NULL; psxexe_header psxheader; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(NULL))) { return NULL; } if (!(addr = RZ_NEW0(RzBinAddr))) { - rz_list_free(ret); + rz_pvector_free(ret); return NULL; } if (rz_buf_fread_at(bf->buf, 0, (ut8 *)&psxheader, "8c17i", 1) < sizeof(psxexe_header)) { RZ_LOG_ERROR("Truncated Header\n"); - rz_list_free(ret); + rz_pvector_free(ret); free(addr); return NULL; } @@ -104,7 +104,7 @@ static RzList /**/ *entries(RzBinFile *bf) { addr->paddr = (psxheader.pc0 - psxheader.t_addr) + PSXEXE_TEXTSECTION_OFFSET; addr->vaddr = psxheader.pc0; - rz_list_append(ret, addr); + rz_pvector_push(ret, addr); return ret; } diff --git a/librz/bin/p/bin_pyc.c b/librz/bin/p/bin_pyc.c index 5082f482d30..b3b7f90a6df 100644 --- a/librz/bin/p/bin_pyc.c +++ b/librz/bin/p/bin_pyc.c @@ -117,26 +117,26 @@ static RzBinInfo *info(RzBinFile *arch) { return ret; } -static RzList /**/ *entries(RzBinFile *arch) { +static RzPVector /**/ *entries(RzBinFile *arch) { RzBinPycObj *pyc = arch->o->bin_obj; - RzList *entries = rz_list_newf((RzListFree)free); + RzPVector *entries = rz_pvector_new((RzPVectorFree)free); if (!entries) { return NULL; } RzBinAddr *addr = RZ_NEW0(RzBinAddr); if (!addr) { - rz_list_free(entries); + rz_pvector_free(entries); return NULL; } ut64 entrypoint = get_entrypoint(arch); addr->paddr = entrypoint; addr->vaddr = entrypoint; rz_buf_seek(arch->buf, entrypoint, RZ_IO_SEEK_SET); - rz_list_append(entries, addr); + rz_pvector_push(entries, addr); if (!init_pyc_cache(pyc, arch->buf)) { - rz_list_free(entries); + rz_pvector_free(entries); return NULL; } return entries; diff --git a/librz/bin/p/bin_qnx.c b/librz/bin/p/bin_qnx.c index 5c87cfb2618..6496b9aa99e 100644 --- a/librz/bin/p/bin_qnx.c +++ b/librz/bin/p/bin_qnx.c @@ -335,20 +335,19 @@ static ut64 baddr(RzBinFile *bf) { * Currently both physical and virtual address are set to 0 * The memory map has different values for entry */ -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBinAddr *ptr = NULL; QnxObj *qo = bf->o->bin_obj; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(free))) { return NULL; } - ret->free = free; if (!(ptr = RZ_NEW0(RzBinAddr))) { return ret; } ptr->paddr = qo->lmfh.code_offset; ptr->vaddr = qo->lmfh.code_offset + baddr(bf); - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_sfc.c b/librz/bin/p/bin_sfc.c index d845c7567f2..be9ed558d4f 100644 --- a/librz/bin/p/bin_sfc.c +++ b/librz/bin/p/bin_sfc.c @@ -267,9 +267,9 @@ static RzPVector /**/ *mem(RzBinFile *bf) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { // Should be 3 offsets pointed by NMI, RESET, IRQ after mapping && default = 1st CHR - RzList *ret; - if (!(ret = rz_list_new())) { +static RzPVector /**/ *entries(RzBinFile *bf) { // Should be 3 offsets pointed by NMI, RESET, IRQ after mapping && default = 1st CHR + RzPVector *ret; + if (!(ret = rz_pvector_new(NULL))) { return NULL; } /* diff --git a/librz/bin/p/bin_smd.c b/librz/bin/p/bin_smd.c index 5efd00c54b6..6015bcd2269 100644 --- a/librz/bin/p/bin_smd.c +++ b/librz/bin/p/bin_smd.c @@ -293,10 +293,10 @@ static RzPVector /**/ *sections(RzBinFile *bf) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { // Should be 3 offsets pointed by NMI, RESET, IRQ after mapping && default = 1st CHR - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { // Should be 3 offsets pointed by NMI, RESET, IRQ after mapping && default = 1st CHR + RzPVector *ret; RzBinAddr *ptr = NULL; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(NULL))) { return NULL; } if (!(ptr = RZ_NEW0(RzBinAddr))) { @@ -305,12 +305,12 @@ static RzList /**/ *entries(RzBinFile *bf) { // Should be 3 offsets if (bf->size < sizeof(SMD_Vectors)) { eprintf("ERR: binfile too small!\n"); ptr->paddr = ptr->vaddr = 0x100 + sizeof(SMD_Header); - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } else { SMD_Vectors vectors; rz_buf_read_at(bf->buf, 0, (ut8 *)&vectors, sizeof(vectors)); ptr->paddr = ptr->vaddr = rz_read_be32(&vectors.Reset); - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_spc700.c b/librz/bin/p/bin_spc700.c index 472ed0ce4ed..b2dadb93877 100644 --- a/librz/bin/p/bin_spc700.c +++ b/librz/bin/p/bin_spc700.c @@ -66,14 +66,14 @@ static RzPVector /**/ *sections(RzBinFile *bf) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret = rz_list_newf(free); +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret = rz_pvector_new(free); if (ret) { RzBinAddr *ptr = RZ_NEW0(RzBinAddr); if (ptr) { ptr->paddr = RAM_START_ADDRESS; ptr->vaddr = 0; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } } return ret; diff --git a/librz/bin/p/bin_te.c b/librz/bin/p/bin_te.c index e2ac7950e32..324a8281d02 100644 --- a/librz/bin/p/bin_te.c +++ b/librz/bin/p/bin_te.c @@ -54,8 +54,8 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret = rz_list_newf(free); +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret = rz_pvector_new(free); if (ret) { RzBinAddr *entry = rz_bin_te_get_entrypoint(bf->o->bin_obj); if (entry) { @@ -63,7 +63,7 @@ static RzList /**/ *entries(RzBinFile *bf) { if (ptr) { ptr->paddr = entry->paddr; ptr->vaddr = entry->vaddr; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } free(entry); } diff --git a/librz/bin/p/bin_vsf.c b/librz/bin/p/bin_vsf.c index 3cc61c681eb..ac978de5705 100644 --- a/librz/bin/p/bin_vsf.c +++ b/librz/bin/p/bin_vsf.c @@ -500,16 +500,16 @@ static void destroy(RzBinFile *bf) { free(obj); } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { struct rz_bin_vsf_obj *vsf_obj = (struct rz_bin_vsf_obj *)bf->o->bin_obj; if (!vsf_obj) { return NULL; } const int m_idx = vsf_obj->machine_idx; - RzList *ret; + RzPVector *ret; RzBinAddr *ptr = NULL; - if (!(ret = rz_list_new())) { + if (!(ret = rz_pvector_new(NULL))) { return NULL; } int offset = _machines[m_idx].offset_mem; @@ -519,7 +519,7 @@ static RzList /**/ *entries(RzBinFile *bf) { } ptr->paddr = vsf_obj->mem + offset; ptr->vaddr = vsf_obj->maincpu ? vsf_obj->maincpu->pc : 0; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); // IRQ: 0xFFFE or 0x0314 ? // if (!(ptr = RZ_NEW0 (RzBinAddr))) diff --git a/librz/bin/p/bin_wasm.c b/librz/bin/p/bin_wasm.c index 1fc42fd630d..b88c5841ec1 100644 --- a/librz/bin/p/bin_wasm.c +++ b/librz/bin/p/bin_wasm.c @@ -48,14 +48,14 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { static RzPVector /**/ *sections(RzBinFile *bf); -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { RzBinWasmObj *bin = bf && bf->o ? bf->o->bin_obj : NULL; // TODO - RzList *ret = NULL; + RzPVector *ret = NULL; RzBinAddr *ptr = NULL; ut64 addr = 0x0; - if (!(ret = rz_list_newf((RzListFree)free))) { + if (!(ret = rz_pvector_new((RzPVectorFree)free))) { return NULL; } @@ -71,14 +71,14 @@ static RzList /**/ *entries(RzBinFile *bf) { } } if (!addr) { - rz_list_free(ret); + rz_pvector_free(ret); return NULL; } } if ((ptr = RZ_NEW0(RzBinAddr))) { ptr->paddr = addr; ptr->vaddr = addr; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/bin/p/bin_xbe.c b/librz/bin/p/bin_xbe.c index 12e10ca1ee8..1410f3d55bc 100644 --- a/librz/bin/p/bin_xbe.c +++ b/librz/bin/p/bin_xbe.c @@ -124,24 +124,23 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) { return ret; } -static RzList /**/ *entries(RzBinFile *bf) { +static RzPVector /**/ *entries(RzBinFile *bf) { const rz_bin_xbe_obj_t *obj; - RzList *ret; + RzPVector *ret; RzBinAddr *ptr = RZ_NEW0(RzBinAddr); if (!bf || !bf->buf || !bf->o->bin_obj || !ptr) { free(ptr); return NULL; } - ret = rz_list_new(); + ret = rz_pvector_new(free); if (!ret) { free(ptr); return NULL; } - ret->free = free; obj = bf->o->bin_obj; ptr->vaddr = obj->header.ep ^ obj->ep_key; ptr->paddr = ptr->vaddr - obj->header.base; - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); return ret; } diff --git a/librz/bin/p/bin_xnu_kernelcache.c b/librz/bin/p/bin_xnu_kernelcache.c index 999ae51837d..18316228a12 100644 --- a/librz/bin/p/bin_xnu_kernelcache.c +++ b/librz/bin/p/bin_xnu_kernelcache.c @@ -124,8 +124,7 @@ static RKext *rz_kext_index_vget(RKextIndex *index, ut64 vaddr); static void process_kmod_init_term(RzXNUKernelCacheObj *obj, RKext *kext, RzPVector /**/ *ret, ut64 **inits, ut64 **terms); static void create_initterm_syms(RKext *kext, RzPVector /**/ *ret, int type, ut64 *pointers); -static void process_constructors(RzXNUKernelCacheObj *obj, struct MACH0_(obj_t) * mach0, RzList /**/ *ret, ut64 paddr, bool is_first, int mode, const char *prefix); -RZ_DEPRECATE static void process_constructors_vector(RzXNUKernelCacheObj *obj, struct MACH0_(obj_t) * mach0, RzPVector /**/ *ret, ut64 paddr, bool is_first, int mode, const char *prefix); +static void process_constructors(RzXNUKernelCacheObj *obj, struct MACH0_(obj_t) * mach0, RzPVector /**/ *ret, ut64 paddr, bool is_first, int mode, const char *prefix); static RzBinAddr *newEntry(ut64 haddr, ut64 vaddr, int type); static void ensure_kexts_initialized(RzXNUKernelCacheObj *obj); @@ -776,11 +775,11 @@ static struct MACH0_(obj_t) * create_kext_shared_mach0(RzXNUKernelCacheObj *obj, return mach0; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList *ret; +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector *ret; RzBinObject *obj = bf ? bf->o : NULL; - if (!obj || !obj->bin_obj || !(ret = rz_list_newf(free))) { + if (!obj || !obj->bin_obj || !(ret = rz_pvector_new(free))) { return NULL; } @@ -790,7 +789,7 @@ static RzList /**/ *entries(RzBinFile *bf) { ut64 entry_paddr = entry_vaddr - kobj->pa2va_exec; RzBinAddr *ba = newEntry(entry_paddr, entry_vaddr, 0); if (ba) { - rz_list_append(ret, ba); + rz_pvector_push(ret, ba); } } @@ -904,66 +903,7 @@ static void create_initterm_syms(RKext *kext, RzPVector /**/ *ret } } -static void process_constructors(RzXNUKernelCacheObj *obj, struct MACH0_(obj_t) * mach0, RzList /**/ *ret, ut64 paddr, bool is_first, int mode, const char *prefix) { - struct section_t *sections = NULL; - if (!(sections = MACH0_(get_sections)(mach0))) { - return; - } - int i, type; - for (i = 0; !sections[i].last; i++) { - if (sections[i].size == 0) { - continue; - } - - if (strstr(sections[i].name, "_mod_fini_func") || strstr(sections[i].name, "_mod_term_func")) { - type = RZ_BIN_ENTRY_TYPE_FINI; - } else if (strstr(sections[i].name, "_mod_init_func")) { - type = is_first ? 0 : RZ_BIN_ENTRY_TYPE_INIT; - is_first = false; - } else { - continue; - } - - ut8 *buf = calloc(sections[i].size, 1); - if (!buf) { - break; - } - if (rz_buf_read_at(obj->cache_buf, sections[i].offset + paddr, buf, sections[i].size) < sections[i].size) { - free(buf); - break; - } - int j; - int count = 0; - for (j = 0; j < sections[i].size; j += 8) { - ut64 addr64 = K_RPTR(buf + j); - ut64 paddr64 = sections[i].offset + paddr + j; - if (mode == RZ_K_CONSTRUCTOR_TO_ENTRY) { - RzBinAddr *ba = newEntry(paddr64, addr64, type); - rz_list_append(ret, ba); - } else if (mode == RZ_K_CONSTRUCTOR_TO_SYMBOL) { - RzBinSymbol *sym = RZ_NEW0(RzBinSymbol); - if (!sym) { - break; - } - - sym->name = rz_str_newf("%s.%s.%d", prefix, (type == RZ_BIN_ENTRY_TYPE_INIT) ? "init" : "fini", count++); - sym->vaddr = addr64; - sym->paddr = paddr64; - sym->size = 0; - sym->forwarder = "NONE"; - sym->bind = "GLOBAL"; - sym->type = "FUNC"; - - rz_list_append(ret, sym); - } - } - free(buf); - } - free(sections); -} - -// this function will be removed once the transition of entries (RzBinPlugin) from RzList to RzPVector is done -RZ_DEPRECATE static void process_constructors_vector(RzXNUKernelCacheObj *obj, struct MACH0_(obj_t) * mach0, RzPVector /**/ *ret, ut64 paddr, bool is_first, int mode, const char *prefix) { +static void process_constructors(RzXNUKernelCacheObj *obj, struct MACH0_(obj_t) * mach0, RzPVector /**/ *ret, ut64 paddr, bool is_first, int mode, const char *prefix) { struct section_t *sections = NULL; if (!(sections = MACH0_(get_sections)(mach0))) { return; @@ -1292,7 +1232,7 @@ static RzPVector /**/ *symbols(RzBinFile *bf) { case MH_MAGIC_64: symbols_from_mach0(ret, kext->mach0, bf, kext->range.offset, rz_pvector_len(ret)); symbols_from_stubs(ret, kernel_syms_by_addr, obj, bf, kext, rz_pvector_len(ret)); - process_constructors_vector(obj, kext->mach0, ret, kext->range.offset, false, RZ_K_CONSTRUCTOR_TO_SYMBOL, kext_short_name(kext)); + process_constructors(obj, kext->mach0, ret, kext->range.offset, false, RZ_K_CONSTRUCTOR_TO_SYMBOL, kext_short_name(kext)); process_kmod_init_term(obj, kext, ret, &inits, &terms); break; diff --git a/librz/bin/p/bin_z64.c b/librz/bin/p/bin_z64.c index a791247f17b..80d9682d747 100644 --- a/librz/bin/p/bin_z64.c +++ b/librz/bin/p/bin_z64.c @@ -89,8 +89,8 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *b, Sdb *sdb) return false; } -static RzList /**/ *entries(RzBinFile *bf) { - RzList /**/ *ret = rz_list_newf(free); +static RzPVector /**/ *entries(RzBinFile *bf) { + RzPVector /**/ *ret = rz_pvector_new(free); if (!ret) { return NULL; } @@ -98,7 +98,7 @@ static RzList /**/ *entries(RzBinFile *bf) { if (ptr) { ptr->paddr = N64_ROM_START; ptr->vaddr = baddr(bf); - rz_list_append(ret, ptr); + rz_pvector_push(ret, ptr); } return ret; } diff --git a/librz/core/canalysis.c b/librz/core/canalysis.c index 52651503ace..4fa1d1797f6 100644 --- a/librz/core/canalysis.c +++ b/librz/core/canalysis.c @@ -2362,7 +2362,7 @@ static bool isSkippable(RzBinSymbol *s) { } RZ_API int rz_core_analysis_all(RzCore *core) { - RzList *list; + RzPVector *vector; RzListIter *iter; RzFlagItem *item; RzAnalysisFunction *fcni; @@ -2389,10 +2389,9 @@ RZ_API int rz_core_analysis_all(RzCore *core) { RzBinFile *bf = core->bin->cur; RzBinObject *o = bf ? bf->o : NULL; /* Symbols (Imports are already analyzed by rz_bin on init) */ - RzPVector *vec = NULL; void **it; - if (o && (vec = o->symbols) != NULL) { - rz_pvector_foreach (vec, it) { + if (o && (vector = o->symbols) != NULL) { + rz_pvector_foreach (vector, it) { symbol = *it; if (rz_cons_is_breaked()) { break; @@ -2416,8 +2415,11 @@ RZ_API int rz_core_analysis_all(RzCore *core) { } } rz_core_task_yield(&core->tasks); - if ((list = rz_bin_get_entries(core->bin))) { - rz_list_foreach (list, iter, entry) { + RzBinObject *bin = rz_bin_cur_object(core->bin); + vector = bin ? (RzPVector *)rz_bin_object_get_entries(bin) : NULL; + if (vector) { + rz_pvector_foreach (vector, it) { + entry = *it; if (entry->paddr == UT64_MAX) { continue; } diff --git a/librz/core/cbin.c b/librz/core/cbin.c index 83569589ba0..33ebe03f5fd 100644 --- a/librz/core/cbin.c +++ b/librz/core/cbin.c @@ -728,12 +728,13 @@ RZ_API bool rz_core_bin_apply_entry(RzCore *core, RzBinFile *binfile, bool va) { if (!o) { return false; } - RzList *entries = o->entries; - RzListIter *iter; + RzPVector *entries = o->entries; + void **iter; RzBinAddr *entry = NULL; int i = 0, init_i = 0, fini_i = 0, preinit_i = 0; rz_flag_space_push(core->flags, RZ_FLAGS_FS_SYMBOLS); - rz_list_foreach (entries, iter, entry) { + rz_pvector_foreach (entries, iter) { + entry = *iter; ut64 paddr = entry->paddr; ut64 hpaddr = UT64_MAX; ut64 hvaddr = UT64_MAX; @@ -1474,7 +1475,7 @@ RZ_API bool rz_core_bin_apply_symbols(RzCore *core, RzBinFile *binfile, bool va) RzBinObject *obj = rz_bin_cur_object(core->bin); RzPVector *symbols = obj ? (RzPVector *)rz_bin_object_get_symbols(obj) : NULL; - RzListIter *iter; + void **iter; void **it; RzBinSymbol *symbol; rz_pvector_foreach (symbols, it) { @@ -1568,7 +1569,8 @@ RZ_API bool rz_core_bin_apply_symbols(RzCore *core, RzBinFile *binfile, bool va) // handle thumb and arm for entry point since they are not present in symbols if (is_arm) { RzBinAddr *entry; - rz_list_foreach (o->entries, iter, entry) { + rz_pvector_foreach (o->entries, iter) { + entry = *iter; handle_arm_entry(core, o, entry, va); } } @@ -1870,8 +1872,8 @@ static const char *bin_reloc_type_name(RzBinReloc *reloc) { static bool entries_initfini_print(RzCore *core, RzBinFile *bf, RzCmdStateOutput *state, bool initfini) { RzBinObject *o = bf->o; - const RzList *entries = rz_bin_object_get_entries(o); - RzListIter *iter; + const RzPVector *entries = rz_bin_object_get_entries(o); + void **iter; RzBinAddr *entry = NULL; ut64 baddr = rz_bin_get_baddr(core->bin); ut64 laddr = rz_bin_get_laddr(core->bin); @@ -1880,7 +1882,8 @@ static bool entries_initfini_print(RzCore *core, RzBinFile *bf, RzCmdStateOutput rz_cmd_state_output_array_start(state); rz_cmd_state_output_set_columnsf(state, "XXXXs", "vaddr", "paddr", "hvaddr", "haddr", "type"); - rz_list_foreach (entries, iter, entry) { + rz_pvector_foreach (entries, iter) { + entry = *iter; ut64 paddr = entry->paddr; ut64 hpaddr = UT64_MAX; ut64 hvaddr = UT64_MAX; @@ -3065,7 +3068,7 @@ RZ_API bool rz_core_bin_info_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBinFile bool havecode; int bits; - havecode = is_executable(obj) || rz_list_length(obj->entries) > 0; + havecode = is_executable(obj) || rz_pvector_len(obj->entries) > 0; compiled = rz_core_bin_get_compile_time(bf); bits = (plugin && !strcmp(plugin->name, "any")) ? rz_config_get_i(core->config, "asm.bits") : info->bits; const char *endian = info->big_endian ? "BE" : "LE"; diff --git a/librz/core/cesil.c b/librz/core/cesil.c index 71b7808efa5..f2496295ca2 100644 --- a/librz/core/cesil.c +++ b/librz/core/cesil.c @@ -43,14 +43,15 @@ static ut64 initializeEsil(RzCore *core) { } } esil->exectrap = exectrap; - RzList *entries = rz_bin_get_entries(core->bin); + RzBinObject *obj = rz_bin_cur_object(core->bin); + RzPVector *entries = obj ? (RzPVector *)rz_bin_object_get_entries(obj) : NULL; RzBinAddr *entry = NULL; RzBinInfo *info = NULL; - if (entries && !rz_list_empty(entries)) { - entry = (RzBinAddr *)rz_list_pop_head(entries); + if (entries && !rz_pvector_empty(entries)) { + entry = (RzBinAddr *)rz_pvector_pop_front(entries); info = rz_bin_get_info(core->bin); addr = info->has_va ? entry->vaddr : entry->paddr; - rz_list_push(entries, entry); + rz_pvector_push(entries, entry); } else { addr = core->offset; } diff --git a/librz/include/rz_bin.h b/librz/include/rz_bin.h index 1b019a3cee5..b3651cf455a 100644 --- a/librz/include/rz_bin.h +++ b/librz/include/rz_bin.h @@ -277,7 +277,7 @@ typedef struct rz_bin_object_t { * This associates the name of every symbol where is_imported == true to the symbol itself. */ HtPP /**/ *import_name_symbols; // currently only used for imports, but could be extended to all symbols if needed. - RzList /**/ *entries; + RzPVector /**/ *entries; RzPVector /**/ *fields; RzPVector /**/ *libs; RzBinRelocStorage *relocs; @@ -531,7 +531,7 @@ typedef struct rz_bin_plugin_t { RzPVector /**/ *(*virtual_files)(RzBinFile *bf); RzPVector /**/ *(*maps)(RzBinFile *bf); RzBinAddr *(*binsym)(RzBinFile *bf, RzBinSpecialSymbol num); - RzList /**/ *(*entries)(RzBinFile *bf); + RzPVector /**/ *(*entries)(RzBinFile *bf); RzPVector /**/ *(*sections)(RzBinFile *bf); RZ_OWN RzBinSourceLineInfo *(*lines)(RzBinFile *bf); //< only called once on load, ownership is transferred to the caller RzPVector /**/ *(*symbols)(RzBinFile *bf); @@ -922,11 +922,10 @@ RZ_API ut64 rz_bin_get_size(RzBin *bin); RZ_API RZ_OWN RzPVector /**/ *rz_bin_file_strings(RZ_NONNULL RzBinFile *bf, size_t min_length, bool raw_strings); // use RzBinFile instead -RZ_DEPRECATE RZ_API RZ_BORROW RzList /**/ *rz_bin_get_entries(RZ_NONNULL RzBin *bin); RZ_DEPRECATE RZ_API int rz_bin_is_static(RZ_NONNULL RzBin *bin); RZ_API RZ_OWN RzPVector /**/ *rz_bin_file_get_trycatch(RZ_NONNULL RzBinFile *bf); -RZ_API const RzList /**/ *rz_bin_object_get_entries(RZ_NONNULL RzBinObject *obj); +RZ_API const RzPVector /**/ *rz_bin_object_get_entries(RZ_NONNULL RzBinObject *obj); RZ_API const RzPVector /**/ *rz_bin_object_get_fields(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); diff --git a/librz/main/rz-diff.c b/librz/main/rz-diff.c index 02c22f86b06..f29dfa7f6c6 100644 --- a/librz/main/rz-diff.c +++ b/librz/main/rz-diff.c @@ -727,12 +727,6 @@ static void rz_diff_file_close(DiffFile *file) { #define rz_diff_file_get(df, n) ((df)->file->o->n) -/**************************************** rzlists ***************************************/ - -static const void *rz_diff_list_elem_at(const RzList /**/ *array, ut32 index) { - return rz_list_get_n(array, index); -} - /**************************************** rzpvector ***************************************/ static const void *rz_diff_pvector_elem_at(const RzPVector /**/ *array, ut32 index) { @@ -1073,31 +1067,31 @@ static void entry_stringify(const RzBinAddr *elem, RzStrBuf *sb) { } static RzDiff *rz_diff_entries_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, entries); - if (!list_a) { + vec_a = rz_diff_file_get(dfile_a, entries); + if (!vec_a) { rz_diff_error_ret(NULL, "cannot get entries from '%s'\n", dfile_a->dio->filename); } - list_b = rz_diff_file_get(dfile_b, entries); - if (!list_b) { + vec_b = rz_diff_file_get(dfile_b, entries); + if (!vec_b) { rz_diff_error_ret(NULL, "cannot get entries from '%s'\n", dfile_b->dio->filename); } - rz_list_sort(list_a, (RzListComparator)entry_compare); - rz_list_sort(list_b, (RzListComparator)entry_compare); + rz_pvector_sort(vec_a, (RzPVectorComparator)entry_compare, NULL); + rz_pvector_sort(vec_b, (RzPVectorComparator)entry_compare, NULL); RzDiffMethods methods = { - .elem_at = (RzDiffMethodElemAt)rz_diff_list_elem_at, + .elem_at = (RzDiffMethodElemAt)rz_diff_pvector_elem_at, .elem_hash = (RzDiffMethodElemHash)entry_hash, .compare = (RzDiffMethodCompare)entry_compare, .stringify = (RzDiffMethodStringify)entry_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); } /**************************************** libraries ***************************************/ diff --git a/test/integration/test_bin.c b/test/integration/test_bin.c index 0eb054235e6..4013cfa1f8e 100644 --- a/test/integration/test_bin.c +++ b/test/integration/test_bin.c @@ -29,9 +29,9 @@ bool test_rz_bin(void) { mu_assert_eq(rz_pvector_len(segments), 10, "rz_bin_object_get_segments"); rz_pvector_free(segments); - const RzList *entries = rz_bin_object_get_entries(obj); - mu_assert_eq(rz_list_length(entries), 1, "rz_bin_object_get_entries"); - RzBinAddr *entry = rz_list_first(entries); + const RzPVector *entries = rz_bin_object_get_entries(obj); + mu_assert_eq(rz_pvector_len(entries), 1, "rz_bin_object_get_entries"); + RzBinAddr *entry = (RzBinAddr *)rz_pvector_at(entries, 0); mu_assert_eq(entry->vaddr, 0x8048360, "entry virtual address"); mu_assert_eq(entry->paddr, 0x360, "entry file offset");