Skip to content

Commit

Permalink
Add rz prefix to set types/APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
pelijah committed May 17, 2024
1 parent 9c34738 commit 49860c4
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 112 deletions.
2 changes: 1 addition & 1 deletion librz/arch/analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 12 additions & 12 deletions librz/arch/dwarf_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1020,20 +1020,20 @@ static RZ_OWN RzType *type_parse_from_offset_internal(
}

end:
set_u_delete(visited, offset);
rz_set_u_delete(visited, offset);
return type;
}

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);
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
}
8 changes: 4 additions & 4 deletions librz/arch/fcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions librz/arch/rtti_itanium.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ RZ_API void rz_analysis_rtti_itanium_recover_all(RVTableContext *context, RzList
RzList /*<class_type_info>*/ *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;
Expand All @@ -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);
}
}
Expand All @@ -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);
}
6 changes: 3 additions & 3 deletions librz/bin/format/mach0/dyldcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 /*<RzBinSymbol *>*/ *symbols, SetU *hash) {
RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage *bin, RzPVector /*<RzBinSymbol *>*/ *symbols, RzSetU *hash) {
RzDyldLocSym *locsym = cache->locsym;
if (!locsym) {
return;
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions librz/bin/format/mach0/dyldcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define RZ_BIN_FORMAT_DYLDCACHE_H

#include <rz_util.h>
#include <rz_util/set.h>
#include <rz_util/rz_set.h>

#define RZ_BIN_MACH064 1

Expand Down Expand Up @@ -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 /*<RzBinSymbol *>*/ *symbols, SetU *hash);
RZ_API void rz_dyldcache_symbols_from_locsym(RzDyldCache *cache, RzDyldBinImage *bin, RzPVector /*<RzBinSymbol *>*/ *symbols, RzSetU *hash);

RZ_API RzBuffer *rz_dyldcache_new_rebasing_buf(RzDyldCache *cache);
RZ_API bool rz_dyldcache_needs_rebasing(RzDyldCache *cache);
Expand Down
10 changes: 5 additions & 5 deletions librz/bin/format/pe/pe_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-FileCopyrightText: 2008-2019 inisider <[email protected]>
// SPDX-License-Identifier: LGPL-3.0-only

#include <rz_util/set.h>
#include <rz_util/rz_set.h>
#include "pe.h"

static inline int is_thumb(RzBinPEObj *bin) {
Expand Down Expand Up @@ -412,7 +412,7 @@ RzPVector /*<char *>*/ *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;
}
Expand All @@ -434,7 +434,7 @@ RzPVector /*<char *>*/ *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;
Expand All @@ -453,10 +453,10 @@ RzPVector /*<char *>*/ *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;
}
Expand Down
8 changes: 4 additions & 4 deletions librz/bin/p/bin_dyldcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static ut64 baddr(RzBinFile *bf) {
return 0x180000000;
}

void symbols_from_bin(RzDyldCache *cache, RzPVector /*<RzBinSymbol *>*/ *ret, RzBinFile *bf, RzDyldBinImage *bin, SetU *hash) {
void symbols_from_bin(RzDyldCache *cache, RzPVector /*<RzBinSymbol *>*/ *ret, RzBinFile *bf, RzDyldBinImage *bin, RzSetU *hash) {
struct MACH0_(obj_t) *mach0 = bin_to_mach0(bf, bin);
if (!mach0) {
return;
Expand Down Expand Up @@ -165,7 +165,7 @@ void symbols_from_bin(RzDyldCache *cache, RzPVector /*<RzBinSymbol *>*/ *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)
Expand Down Expand Up @@ -341,14 +341,14 @@ static RzPVector /*<RzBinSymbol *>*/ *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);
Expand Down
8 changes: 4 additions & 4 deletions librz/bin/p/bin_mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static RzPVector /*<RzBinSymbol *>*/ *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) {
Expand All @@ -231,7 +231,7 @@ static RzPVector /*<RzBinSymbol *>*/ *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
Expand Down Expand Up @@ -260,7 +260,7 @@ static RzPVector /*<RzBinSymbol *>*/ *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;
}
}
Expand All @@ -269,7 +269,7 @@ static RzPVector /*<RzBinSymbol *>*/ *symbols(RzBinFile *bf) {
if (isStripped) {
bin->dbg_info |= RZ_BIN_DBG_STRIPPED;
}
set_u_free(symcache);
rz_set_u_free(symcache);
return ret;
}

Expand Down
14 changes: 7 additions & 7 deletions librz/core/agraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand All @@ -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);
}
}

Expand All @@ -1189,26 +1189,26 @@ 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++) {
const RzGraphNode *gn;
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);
}
}

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]);
Expand Down
Loading

0 comments on commit 49860c4

Please sign in to comment.