diff --git a/librz/arch/analysis.c b/librz/arch/analysis.c index dc9d312c2ee..ecb90e58e53 100644 --- a/librz/arch/analysis.c +++ b/librz/arch/analysis.c @@ -160,7 +160,7 @@ RZ_API RzAnalysis *rz_analysis_free(RzAnalysis *a) { rz_list_free(a->fcns); ht_up_free(a->ht_addr_fun); ht_sp_free(a->ht_name_fun); - set_u_free(a->visited); + rz_set_u_free(a->visited); rz_analysis_hint_storage_fini(a); rz_interval_tree_fini(&a->meta); free(a->cpu); diff --git a/librz/arch/dwarf_process.c b/librz/arch/dwarf_process.c index f5e16a79133..01d5223cc7e 100644 --- a/librz/arch/dwarf_process.c +++ b/librz/arch/dwarf_process.c @@ -32,7 +32,7 @@ static RZ_OWN RzType *type_parse_from_offset_internal( RZ_BORROW RZ_IN RZ_NONNULL DwContext *ctx, ut64 offset, RZ_BORROW RZ_OUT RZ_NULLABLE ut64 *size, - RZ_BORROW RZ_IN RZ_NONNULL SetU *visited); + RZ_BORROW RZ_IN RZ_NONNULL RzSetU *visited); static RZ_OWN RzType *type_parse_from_offset( RZ_BORROW RZ_IN RZ_NONNULL DwContext *ctx, @@ -824,7 +824,7 @@ static RzType *type_parse_from_die_internal( RzBinDwarfDie *die, bool allow_void, RZ_NULLABLE ut64 *size, - RZ_NONNULL SetU *visited) { + RZ_NONNULL RzSetU *visited) { RzBinDwarfAttr *attr = rz_bin_dwarf_die_get_attr(die, DW_AT_type); if (!attr) { if (!allow_void) { @@ -869,16 +869,16 @@ static RZ_OWN RzType *type_parse_from_offset_internal( RZ_BORROW RZ_IN RZ_NONNULL DwContext *ctx, ut64 offset, RZ_BORROW RZ_OUT RZ_NULLABLE ut64 *size, - RZ_BORROW RZ_IN RZ_NONNULL SetU *visited) { + RZ_BORROW RZ_IN RZ_NONNULL RzSetU *visited) { RzType *type = ht_up_find(ctx->analysis->debug_info->type_by_offset, offset, NULL); if (type) { return rz_type_clone(type); } - if (set_u_contains(visited, offset)) { + if (rz_set_u_contains(visited, offset)) { return NULL; } - set_u_add(visited, offset); + rz_set_u_add(visited, offset); RzBinDwarfDie *die = ht_up_find(ctx->dw->info->die_by_offset, offset, NULL); if (!die) { @@ -1020,7 +1020,7 @@ static RZ_OWN RzType *type_parse_from_offset_internal( } end: - set_u_delete(visited, offset); + rz_set_u_delete(visited, offset); return type; } @@ -1028,12 +1028,12 @@ static RZ_OWN RzType *type_parse_from_offset( RZ_BORROW RZ_IN RZ_NONNULL DwContext *ctx, ut64 offset, RZ_BORROW RZ_OUT RZ_NULLABLE ut64 *size) { - SetU *visited = set_u_new(); + RzSetU *visited = rz_set_u_new(); if (!visited) { return NULL; } RzType *type = type_parse_from_offset_internal(ctx, offset, size, visited); - set_u_free(visited); + rz_set_u_free(visited); if (!type) { RZ_LOG_VERBOSE("DWARF Type failed at 0x%" PFMT64x "\n", offset); } @@ -1683,10 +1683,10 @@ static bool variable_from_die( } static void die_parse(DwContext *ctx, RzBinDwarfDie *die) { - if (set_u_contains(ctx->analysis->debug_info->visited, die->offset)) { + if (rz_set_u_contains(ctx->analysis->debug_info->visited, die->offset)) { return; } - set_u_add(ctx->analysis->debug_info->visited, die->offset); + rz_set_u_add(ctx->analysis->debug_info->visited, die->offset); switch (die->tag) { case DW_TAG_structure_type: case DW_TAG_union_type: @@ -2076,7 +2076,7 @@ RZ_API RzAnalysisDebugInfo *rz_analysis_debug_info_new() { debug_info->callable_by_offset = ht_up_new(NULL, (HtUPFreeValue)rz_type_callable_free); debug_info->base_type_by_offset = ht_up_new(NULL, (HtUPFreeValue)rz_type_base_type_free); debug_info->base_types_by_name = ht_sp_new(HT_STR_DUP, NULL, (HtSPFreeValue)rz_pvector_free); - debug_info->visited = set_u_new(); + debug_info->visited = rz_set_u_new(); return debug_info; } @@ -2096,6 +2096,6 @@ RZ_API void rz_analysis_debug_info_free(RzAnalysisDebugInfo *debuginfo) { ht_up_free(debuginfo->base_type_by_offset); ht_sp_free(debuginfo->base_types_by_name); rz_bin_dwarf_free(debuginfo->dw); - set_u_free(debuginfo->visited); + rz_set_u_free(debuginfo->visited); free(debuginfo); } diff --git a/librz/arch/fcn.c b/librz/arch/fcn.c index 544c9ee9cb9..21e211d55b7 100644 --- a/librz/arch/fcn.c +++ b/librz/arch/fcn.c @@ -1627,16 +1627,16 @@ RZ_API int rz_analysis_fcn(RzAnalysis *analysis, RzAnalysisFunction *fcn, ut64 a rz_pvector_free(metas); if (analysis->opt.norevisit) { if (!analysis->visited) { - analysis->visited = set_u_new(); + analysis->visited = rz_set_u_new(); } - if (set_u_contains(analysis->visited, addr)) { + if (rz_set_u_contains(analysis->visited, addr)) { RZ_LOG_DEBUG("rz_analysis_fcn: analysis.norevisit at 0x%08" PFMT64x " %c\n", addr, reftype); return RZ_ANALYSIS_RET_END; } - set_u_add(analysis->visited, addr); + rz_set_u_add(analysis->visited, addr); } else { if (analysis->visited) { - set_u_free(analysis->visited); + rz_set_u_free(analysis->visited); analysis->visited = NULL; } } diff --git a/librz/arch/rtti_itanium.c b/librz/arch/rtti_itanium.c index 6165deed34c..c03f108e90e 100644 --- a/librz/arch/rtti_itanium.c +++ b/librz/arch/rtti_itanium.c @@ -857,7 +857,7 @@ RZ_API void rz_analysis_rtti_itanium_recover_all(RVTableContext *context, RzList RzList /**/ *rtti_list = rz_list_new(); rtti_list->free = rtti_itanium_type_info_free; // to escape multiple same infos from multiple inheritance - SetU *unique_rttis = set_u_new(); + RzSetU *unique_rttis = rz_set_u_new(); RzListIter *iter; RVTableInfo *vtable; @@ -874,10 +874,10 @@ RZ_API void rz_analysis_rtti_itanium_recover_all(RVTableContext *context, RzList detect_constructor_destructor(context->analysis, cti); // we only need one of a kind - if (set_u_contains(unique_rttis, cti->typeinfo_addr)) { + if (rz_set_u_contains(unique_rttis, cti->typeinfo_addr)) { rtti_itanium_type_info_free(cti); } else { - set_u_add(unique_rttis, cti->typeinfo_addr); + rz_set_u_add(unique_rttis, cti->typeinfo_addr); rz_list_append(rtti_list, cti); } } @@ -887,6 +887,6 @@ RZ_API void rz_analysis_rtti_itanium_recover_all(RVTableContext *context, RzList add_class_bases(context, cti); } - set_u_free(unique_rttis); + rz_set_u_free(unique_rttis); rz_list_free(rtti_list); } diff --git a/librz/bin/format/mach0/dyldcache.c b/librz/bin/format/mach0/dyldcache.c index 8b1ec43ef1f..be1511a1385 100644 --- a/librz/bin/format/mach0/dyldcache.c +++ b/librz/bin/format/mach0/dyldcache.c @@ -1279,7 +1279,7 @@ RZ_API ut64 rz_dyldcache_get_slide(RzDyldCache *cache) { return 0; } -RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage *bin, RzPVector /**/ *symbols, SetU *hash) { +RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage *bin, RzPVector /**/ *symbols, RzSetU *hash) { RzDyldLocSym *locsym = cache->locsym; if (!locsym) { return; @@ -1306,10 +1306,10 @@ RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage ut32 j; for (j = 0; j != bin->nlist_count; j++) { struct MACH0_(nlist) *nlist = &nlists[j]; - if (set_u_contains(hash, (ut64)nlist->n_value)) { + if (rz_set_u_contains(hash, (ut64)nlist->n_value)) { continue; } - set_u_add(hash, (ut64)nlist->n_value); + rz_set_u_add(hash, (ut64)nlist->n_value); if (nlist->n_strx >= locsym->strings_size) { continue; } diff --git a/librz/bin/format/mach0/dyldcache.h b/librz/bin/format/mach0/dyldcache.h index 5f2cee448ec..cb4555cdcae 100644 --- a/librz/bin/format/mach0/dyldcache.h +++ b/librz/bin/format/mach0/dyldcache.h @@ -6,7 +6,7 @@ #define RZ_BIN_FORMAT_DYLDCACHE_H #include -#include +#include #define RZ_BIN_MACH064 1 @@ -244,7 +244,7 @@ RZ_API RZ_NONNULL const char *rz_dyldcache_get_type_str(RzDyldCache *cache); RZ_API ut64 rz_dyldcache_va2pa(RzDyldCache *cache, uint64_t vaddr, ut32 *offset, ut32 *left); RZ_API ut64 rz_dyldcache_get_slide(RzDyldCache *cache); RZ_API objc_cache_opt_info *rz_dyldcache_get_objc_opt_info(RzBinFile *bf, RzDyldCache *cache); -RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage *bin, RzPVector /**/ *symbols, SetU *hash); +RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage *bin, RzPVector /**/ *symbols, RzSetU *hash); RZ_API RzBuffer *rz_dyldcache_new_rebasing_buf(RzDyldCache *cache); RZ_API bool rz_dyldcache_needs_rebasing(RzDyldCache *cache); diff --git a/librz/bin/format/pe/pe_info.c b/librz/bin/format/pe/pe_info.c index a4b1ac4c236..ee34d7d3419 100644 --- a/librz/bin/format/pe/pe_info.c +++ b/librz/bin/format/pe/pe_info.c @@ -3,7 +3,7 @@ // SPDX-FileCopyrightText: 2008-2019 inisider // SPDX-License-Identifier: LGPL-3.0-only -#include +#include #include "pe.h" static inline int is_thumb(RzBinPEObj *bin) { @@ -412,7 +412,7 @@ RzPVector /**/ *PE_(rz_bin_pe_get_libs)(RzBinPEObj *bin) { PE_(image_delay_import_directory) curr_delay_import_dir; - SetS *libs = set_s_new(HT_STR_DUP); + RzSetS *libs = rz_set_s_new(HT_STR_DUP); if (!libs) { return NULL; } @@ -434,7 +434,7 @@ RzPVector /**/ *PE_(rz_bin_pe_get_libs)(RzBinPEObj *bin) { } lib_name[len - 1] = '\0'; rz_str_case(lib_name, 0); - set_s_add(libs, lib_name); + rz_set_s_add(libs, lib_name); } } dir_off = bin->delay_import_directory_offset; @@ -453,10 +453,10 @@ RzPVector /**/ *PE_(rz_bin_pe_get_libs)(RzBinPEObj *bin) { } lib_name[len - 1] = '\0'; rz_str_case(lib_name, 0); - set_s_add(libs, lib_name); + rz_set_s_add(libs, lib_name); } } - RzPVector *vec = set_s_to_vector(libs); + RzPVector *vec = rz_set_s_to_vector(libs); set_s_free(libs); return vec; } diff --git a/librz/bin/p/bin_dyldcache.c b/librz/bin/p/bin_dyldcache.c index c66657d93fd..794e47b4f19 100644 --- a/librz/bin/p/bin_dyldcache.c +++ b/librz/bin/p/bin_dyldcache.c @@ -134,7 +134,7 @@ static ut64 baddr(RzBinFile *bf) { return 0x180000000; } -void symbols_from_bin(RzDyldCache *cache, RzPVector /**/ *ret, RzBinFile *bf, RzDyldBinImage *bin, SetU *hash) { +void symbols_from_bin(RzDyldCache *cache, RzPVector /**/ *ret, RzBinFile *bf, RzDyldBinImage *bin, RzSetU *hash) { struct MACH0_(obj_t) *mach0 = bin_to_mach0(bf, bin); if (!mach0) { return; @@ -165,7 +165,7 @@ void symbols_from_bin(RzDyldCache *cache, RzPVector /**/ *ret, Rz sym->size = symbols[i].size; sym->ordinal = i; - set_u_add(hash, sym->vaddr); + rz_set_u_add(hash, sym->vaddr); rz_pvector_push(ret, sym); } MACH0_(mach0_free) @@ -341,14 +341,14 @@ static RzPVector /**/ *symbols(RzBinFile *bf) { RzListIter *iter; RzDyldBinImage *bin; rz_list_foreach (cache->bins, iter, bin) { - SetU *hash = set_u_new(); + RzSetU *hash = rz_set_u_new(); if (!hash) { rz_pvector_free(ret); return NULL; } symbols_from_bin(cache, ret, bf, bin, hash); rz_dyldcache_symbols_from_locsym(cache, bin, ret, hash); - set_u_free(hash); + rz_set_u_free(hash); } ut64 slide = rz_dyldcache_get_slide(cache); diff --git a/librz/bin/p/bin_mach0.c b/librz/bin/p/bin_mach0.c index a8d4a3b5d6a..f4737f66168 100644 --- a/librz/bin/p/bin_mach0.c +++ b/librz/bin/p/bin_mach0.c @@ -208,7 +208,7 @@ static RzPVector /**/ *symbols(RzBinFile *bf) { if (!(syms = MACH0_(get_symbols)(obj->bin_obj))) { return ret; } - SetU *symcache = set_u_new(); + RzSetU *symcache = rz_set_u_new(); bin = (struct MACH0_(obj_t) *)obj->bin_obj; for (i = 0; !syms[i].last; i++) { if (syms[i].name == NULL || syms[i].name[0] == '\0' || syms[i].addr < 100) { @@ -231,7 +231,7 @@ static RzPVector /**/ *symbols(RzBinFile *bf) { } ptr->ordinal = i; bin->dbg_info = strncmp(ptr->name, "radr://", 7) ? 0 : 1; - set_u_add(symcache, ptr->vaddr); + rz_set_u_add(symcache, ptr->vaddr); rz_pvector_push(ret, ptr); } // functions from LC_FUNCTION_STARTS @@ -260,7 +260,7 @@ static RzPVector /**/ *symbols(RzBinFile *bf) { rz_pvector_push(ret, ptr); // if any func is not found in syms then we can consider it is stripped if (!isStripped) { - if (!set_u_contains(symcache, ptr->vaddr)) { + if (!rz_set_u_contains(symcache, ptr->vaddr)) { isStripped = true; } } @@ -269,7 +269,7 @@ static RzPVector /**/ *symbols(RzBinFile *bf) { if (isStripped) { bin->dbg_info |= RZ_BIN_DBG_STRIPPED; } - set_u_free(symcache); + rz_set_u_free(symcache); return ret; } diff --git a/librz/core/agraph.c b/librz/core/agraph.c index 5a5f60111ba..669a1e7765f 100644 --- a/librz/core/agraph.c +++ b/librz/core/agraph.c @@ -1135,7 +1135,7 @@ static int place_nodes_sel_p(int newval, int oldval, int is_first, int is_left) } /* places left/right the nodes of a class */ -static void place_nodes(const RzAGraph *g, const RzGraphNode *gn, int is_left, HtPP *v_nodes, HtPU *res, SetU *placed) { +static void place_nodes(const RzAGraph *g, const RzGraphNode *gn, int is_left, HtPP *v_nodes, HtPU *res, RzSetU *placed) { const RzList *lv = ht_pp_find(v_nodes, gn, NULL); int p = 0, v, is_first = true; const RzGraphNode *gk; @@ -1155,7 +1155,7 @@ static void place_nodes(const RzAGraph *g, const RzGraphNode *gn, int is_left, H } sibl_anode = get_anode(sibling); if (ak->klass == sibl_anode->klass) { - if (!set_u_contains(placed, (ut64)sibling)) { + if (!rz_set_u_contains(placed, (ut64)sibling)) { place_nodes(g, sibling, is_left, v_nodes, res, placed); } @@ -1174,7 +1174,7 @@ static void place_nodes(const RzAGraph *g, const RzGraphNode *gn, int is_left, H break; } ht_pu_update(res, gk, (ut64)(size_t)p); - set_u_add(placed, (ut64)gk); + rz_set_u_add(placed, (ut64)gk); } } @@ -1189,10 +1189,10 @@ static HtPU *compute_pos(const RzAGraph *g, int is_left, HtPP *v_nodes) { HtPUOptions pu_opt = { 0 }; HtPU *res = ht_pu_new_opt(&pu_opt); - SetU *placed = set_u_new(); + RzSetU *placed = rz_set_u_new(); if (!res || !placed) { ht_pu_free(res); - set_u_free(placed); + rz_set_u_free(placed); return NULL; } for (i = 0; i < n_classes; i++) { @@ -1200,7 +1200,7 @@ static HtPU *compute_pos(const RzAGraph *g, int is_left, HtPP *v_nodes) { const RzListIter *it; rz_list_foreach (classes[i], it, gn) { - if (!set_u_contains(placed, (ut64)gn)) { + if (!rz_set_u_contains(placed, (ut64)gn)) { place_nodes(g, gn, is_left, v_nodes, res, placed); } } @@ -1208,7 +1208,7 @@ static HtPU *compute_pos(const RzAGraph *g, int is_left, HtPP *v_nodes) { adjust_class(g, is_left, classes, res, i); } - set_u_free(placed); + rz_set_u_free(placed); for (i = 0; i < n_classes; i++) { if (classes[i]) { rz_list_free(classes[i]); diff --git a/librz/core/canalysis.c b/librz/core/canalysis.c index dc6821832b9..d5ac5e7a912 100644 --- a/librz/core/canalysis.c +++ b/librz/core/canalysis.c @@ -3585,7 +3585,7 @@ static RzAnalysisBlock *find_block_at_xref_addr(RzCore *core, ut64 addr) { return block; } -static void relocation_function_process_noreturn(RzCore *core, RzAnalysisBlock *b, SetU *todo, ut64 opsize, ut64 reladdr, ut64 addr) { +static void relocation_function_process_noreturn(RzCore *core, RzAnalysisBlock *b, RzSetU *todo, ut64 opsize, ut64 reladdr, ut64 addr) { rz_analysis_noreturn_add(core->analysis, NULL, reladdr); // Add all functions that might have become noreturn by this to the todo list to reanalyze them later. @@ -3593,14 +3593,14 @@ static void relocation_function_process_noreturn(RzCore *core, RzAnalysisBlock * RzListIter *it; RzAnalysisFunction *fcn; rz_list_foreach (b->fcns, it, fcn) { - set_u_add(todo, (ut64)(size_t)fcn); + rz_set_u_add(todo, (ut64)(size_t)fcn); } // Chop the block rz_analysis_block_chop_noreturn(b, addr + opsize); } -static void relocation_noreturn_process(RzCore *core, RzList /**/ *noretl, SetU *todo, RzAnalysisBlock *b, RzBinReloc *rel, ut64 opsize, ut64 addr) { +static void relocation_noreturn_process(RzCore *core, RzList /**/ *noretl, RzSetU *todo, RzAnalysisBlock *b, RzBinReloc *rel, ut64 opsize, ut64 addr) { RzListIter *iter3; char *noret; if (rel->import) { @@ -3623,13 +3623,13 @@ static void relocation_noreturn_process(RzCore *core, RzList /**/ *noret struct core_noretl { RzCore *core; RzList /**/ *noretl; - SetU *todo; + RzSetU *todo; }; static bool process_reference_noreturn_cb(void *u, const ut64 k, const void *v) { RzCore *core = ((struct core_noretl *)u)->core; RzList *noretl = ((struct core_noretl *)u)->noretl; - SetU *todo = ((struct core_noretl *)u)->todo; + RzSetU *todo = ((struct core_noretl *)u)->todo; RzAnalysisXRef *xref = (RzAnalysisXRef *)v; if (xref->type == RZ_ANALYSIS_XREF_TYPE_CALL || xref->type == RZ_ANALYSIS_XREF_TYPE_CODE) { // At first we check if there are any relocations that override the call address @@ -3684,7 +3684,7 @@ RZ_API void rz_core_analysis_propagate_noreturn_relocs(RzCore *core, ut64 addr) // find known noreturn functions to propagate RzList *noretl = rz_analysis_noreturn_functions(core->analysis); // List of the potentially noreturn functions - SetU *todo = set_u_new(); + RzSetU *todo = rz_set_u_new(); struct core_noretl u = { core, noretl, todo }; ht_up_foreach(core->analysis->ht_xrefs_to, process_refs_cb, &u); rz_list_free(noretl); @@ -3692,7 +3692,7 @@ RZ_API void rz_core_analysis_propagate_noreturn_relocs(RzCore *core, ut64 addr) core->rasm->bits = bits2; // For every function in todo list analyze if it's potentially become noreturn ht_up_foreach(todo, reanalyze_fcns_cb, core); - set_u_free(todo); + rz_set_u_free(todo); } RZ_API void rz_core_analysis_propagate_noreturn(RzCore *core, ut64 addr) { diff --git a/librz/core/cmd/cmd_eval.c b/librz/core/cmd/cmd_eval.c index 29800be3827..eba19441809 100644 --- a/librz/core/cmd/cmd_eval.c +++ b/librz/core/cmd/cmd_eval.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "../core_private.h" static bool load_theme(RzCore *core, const char *path) { @@ -75,13 +75,13 @@ RZ_API bool rz_core_theme_load(RzCore *core, const char *name) { return !failed; } -static void list_themes_in_path(SetS *themes, const char *path) { +static void list_themes_in_path(RzSetS *themes, const char *path) { RzListIter *iter; const char *fn; RzList *files = rz_sys_dir(path); rz_list_foreach (files, iter, fn) { if (*fn && *fn != '.') { - set_s_add(themes, fn); + rz_set_s_add(themes, fn); } } rz_list_free(files); @@ -104,7 +104,7 @@ static int compare_strings(const char *s1, const char *s2, RZ_UNUSED void *user) RZ_API RZ_OWN RzPVector /**/ *rz_core_get_themes(RZ_NONNULL RzCore *core) { rz_return_val_if_fail(core, NULL); - SetS *themes = set_s_new(HT_STR_DUP); + RzSetS *themes = rz_set_s_new(HT_STR_DUP); if (!themes) { return NULL; } @@ -127,7 +127,7 @@ RZ_API RZ_OWN RzPVector /**/ *rz_core_get_themes(RZ_NONNULL RzCore *core RZ_FREE(path); } - RzPVector *vec = set_s_to_vector(themes); + RzPVector *vec = rz_set_s_to_vector(themes); if (!vec) { set_s_free(themes); return NULL; diff --git a/librz/include/meson.build b/librz/include/meson.build index 77fd0bc9417..686641c8e2c 100644 --- a/librz/include/meson.build +++ b/librz/include/meson.build @@ -128,7 +128,7 @@ rz_util_files = [ 'rz_util/ht_sp.h', 'rz_util/ht_ss.h', 'rz_util/ht_su.h', - 'rz_util/set.h', + 'rz_util/rz_set.h', ] install_headers(rz_util_files, install_dir: join_paths(rizin_incdir, 'rz_util')) diff --git a/librz/include/rz_analysis.h b/librz/include/rz_analysis.h index d8a47669d3a..006dc555e99 100644 --- a/librz/include/rz_analysis.h +++ b/librz/include/rz_analysis.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -457,7 +457,7 @@ typedef struct { HtSP /*>*/ *base_types_by_name; ///< Store all RzBaseType parsed from DWARF by DIE offset DWARF_RegisterMapping dwarf_register_mapping; ///< Store the mapping function between DWARF registers number and register name in current architecture RzBinDWARF *dw; ///< Holds ownership of RzBinDwarf, avoid releasing it prematurely - SetU *visited; + RzSetU *visited; } RzAnalysisDebugInfo; typedef struct rz_analysis_t { @@ -522,7 +522,7 @@ typedef struct rz_analysis_t { RzFlagGetAtAddr flag_get; RzEvent *ev; RzList /**/ *imports; // global imports - SetU *visited; + RzSetU *visited; RzStrConstPool constpool; RzList /**/ *leaddrs; RzPlatformTarget *arch_target; diff --git a/librz/include/rz_util/rz_set.h b/librz/include/rz_util/rz_set.h new file mode 100644 index 00000000000..dcfe779f3ce --- /dev/null +++ b/librz/include/rz_util/rz_set.h @@ -0,0 +1,37 @@ +// SPDX-FileCopyrightText: pancake +// SPDX-FileCopyrightText: 2024 pelijah +// SPDX-License-Identifier: MIT + +#ifndef SDB_SET_H +#define SDB_SET_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef HtSP RzSetS; + +RZ_API RZ_OWN RzSetS *rz_set_s_new(HtStrOption opt); +RZ_API void set_s_free(RZ_NULLABLE RzSetS *set); +RZ_API void rz_set_s_add(RZ_NONNULL RzSetS *set, const char *str); +RZ_API bool rz_set_s_contains(RZ_NONNULL RzSetS *set, const char *str); +RZ_API void rz_set_s_delete(RZ_NONNULL RzSetS *set, const char *str); +RZ_API RZ_OWN RzPVector /**/ *rz_set_s_to_vector(RZ_NONNULL RzSetS *set); + +typedef HtUP RzSetU; + +RZ_API RZ_OWN RzSetU *rz_set_u_new(void); +RZ_API void rz_set_u_free(RZ_NULLABLE RzSetU *set); +RZ_API void rz_set_u_add(RZ_NONNULL RzSetU *set, ut64 u); +RZ_API bool rz_set_u_contains(RZ_NONNULL RzSetU *set, ut64 u); +RZ_API void rz_set_u_delete(RZ_NONNULL RzSetU *set, ut64 u); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/librz/include/rz_util/set.h b/librz/include/rz_util/set.h deleted file mode 100644 index 3d4197d72de..00000000000 --- a/librz/include/rz_util/set.h +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-FileCopyrightText: pancake -// SPDX-FileCopyrightText: 2024 pelijah -// SPDX-License-Identifier: MIT - -#ifndef SDB_SET_H -#define SDB_SET_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef HtSP SetS; - -RZ_API RZ_OWN SetS *set_s_new(HtStrOption opt); -RZ_API void set_s_add(RZ_NONNULL SetS *set, const char *str); -RZ_API bool set_s_contains(RZ_NONNULL SetS *set, const char *str); -RZ_API void set_s_delete(RZ_NONNULL SetS *set, const char *str); -RZ_API void set_s_free(RZ_NULLABLE SetS *set); -RZ_API RZ_OWN RzPVector /**/ *set_s_to_vector(RZ_NONNULL SetS *set); - -typedef HtUP SetU; - -RZ_API RZ_OWN SetU *set_u_new(void); -RZ_API void set_u_add(RZ_NONNULL SetU *set, ut64 u); -RZ_API bool set_u_contains(RZ_NONNULL SetU *set, ut64 u); -RZ_API void set_u_delete(RZ_NONNULL SetU *set, ut64 u); -RZ_API void set_u_free(RZ_NULLABLE SetU *set); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/librz/util/set.c b/librz/util/set.c index 3f217b9bee6..3338325cc12 100644 --- a/librz/util/set.c +++ b/librz/util/set.c @@ -2,21 +2,21 @@ // SPDX-FileCopyrightText: 2024 pelijah // SPDX-License-Identifier: MIT -#include +#include #include /** * \brief Create a new hash set with C-string as elements. * \param opt Defines how elements are stored */ -RZ_API RZ_OWN SetS *set_s_new(HtStrOption opt) { +RZ_API RZ_OWN RzSetS *rz_set_s_new(HtStrOption opt) { return ht_sp_new(opt, NULL, NULL); } /** * \brief Add element \p str to hash set \p set. */ -RZ_API void set_s_add(RZ_NONNULL SetS *set, const char *str) { +RZ_API void rz_set_s_add(RZ_NONNULL RzSetS *set, const char *str) { rz_return_if_fail(set); ht_sp_insert(set, str, (void *)1); } @@ -24,7 +24,7 @@ RZ_API void set_s_add(RZ_NONNULL SetS *set, const char *str) { /** * \brief Check if hash set \p set contains element \p str. */ -RZ_API bool set_s_contains(RZ_NONNULL SetS *set, const char *str) { +RZ_API bool rz_set_s_contains(RZ_NONNULL RzSetS *set, const char *str) { rz_return_val_if_fail(set, false); return ht_sp_find(set, str, NULL) != NULL; } @@ -32,7 +32,7 @@ RZ_API bool set_s_contains(RZ_NONNULL SetS *set, const char *str) { /** * \brief Add element \p str from hash set \p set. */ -RZ_API void set_s_delete(RZ_NONNULL SetS *set, const char *str) { +RZ_API void rz_set_s_delete(RZ_NONNULL RzSetS *set, const char *str) { rz_return_if_fail(set); ht_sp_delete(set, str); } @@ -47,7 +47,7 @@ static bool push_to_pvector(void *user, const char *k, RZ_UNUSED const void *v) * * If a hash set owns stored strings the ownership will be transferred. */ -RZ_API RZ_OWN RzPVector /**/ *set_s_to_vector(RZ_NONNULL SetS *set) { +RZ_API RZ_OWN RzPVector /**/ *rz_set_s_to_vector(RZ_NONNULL RzSetS *set) { rz_return_val_if_fail(set, NULL); RzPVector *vec = rz_pvector_new(set->opt.finiKV ? free : NULL); @@ -61,21 +61,21 @@ RZ_API RZ_OWN RzPVector /**/ *set_s_to_vector(RZ_NONNULL SetS *set) { return vec; } -RZ_API void set_s_free(RZ_NULLABLE SetS *set) { +RZ_API void set_s_free(RZ_NULLABLE RzSetS *set) { ht_sp_free((HtSP *)set); } /** * \brief Create a new hash set with ut64 as elements. */ -RZ_API RZ_OWN SetU *set_u_new(void) { - return (SetU *)ht_up_new(NULL, NULL); +RZ_API RZ_OWN RzSetU *rz_set_u_new(void) { + return (RzSetU *)ht_up_new(NULL, NULL); } /** * \brief Add element \p u to hash set \p set. */ -RZ_API void set_u_add(RZ_NONNULL SetU *set, ut64 u) { +RZ_API void rz_set_u_add(RZ_NONNULL RzSetU *set, ut64 u) { rz_return_if_fail(set); ht_up_insert(set, u, (void *)1); } @@ -83,7 +83,7 @@ RZ_API void set_u_add(RZ_NONNULL SetU *set, ut64 u) { /** * \brief Check if hash set \p set contains element \p u. */ -RZ_API bool set_u_contains(RZ_NONNULL SetU *set, ut64 u) { +RZ_API bool rz_set_u_contains(RZ_NONNULL RzSetU *set, ut64 u) { rz_return_val_if_fail(set, false); return ht_up_find(set, u, NULL) != NULL; } @@ -91,11 +91,11 @@ RZ_API bool set_u_contains(RZ_NONNULL SetU *set, ut64 u) { /** * \brief Delete element \p u from hash set \p set. */ -RZ_API void set_u_delete(RZ_NONNULL SetU *set, ut64 u) { +RZ_API void rz_set_u_delete(RZ_NONNULL RzSetU *set, ut64 u) { rz_return_if_fail(set); ht_up_delete(set, u); } -RZ_API void set_u_free(RZ_NULLABLE SetU *set) { +RZ_API void rz_set_u_free(RZ_NULLABLE RzSetU *set) { ht_up_free((HtUP *)set); }