Skip to content

Commit

Permalink
analysis/function: improve API
Browse files Browse the repository at this point in the history
  • Loading branch information
XVilka committed Sep 25, 2024
1 parent 3573148 commit 2486e56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions librz/arch/fcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ RZ_API bool rz_analysis_fcn_add_bb(RzAnalysis *a, RzAnalysisFunction *fcn, ut64
/**
* \brief Returns the amount of loops located in the \p fcn function
*/
RZ_API int rz_analysis_function_loops(RzAnalysisFunction *fcn) {
RZ_API ut32 rz_analysis_function_loops(RzAnalysisFunction *fcn) {
RzAnalysisBlock *bb;
ut32 loops = 0;

Expand Down Expand Up @@ -1804,9 +1804,9 @@ RZ_API int rz_analysis_function_loops(RzAnalysisFunction *fcn) {
* P is the number of connected components (exit nodes).
*
*/
RZ_API int rz_analysis_function_complexity(RzAnalysisFunction *fcn) {
RZ_API ut32 rz_analysis_function_complexity(RzAnalysisFunction *fcn) {
RzAnalysis *analysis = fcn->analysis;
int E = 0, N = 0, P = 0;
ut32 E = 0, N = 0, P = 0;
RzAnalysisBlock *bb;

void **it;
Expand Down Expand Up @@ -1851,7 +1851,7 @@ RZ_API int rz_analysis_function_get_arg_count(RzAnalysis *analysis, RzAnalysisFu
}

// tfj and afsj call this function
RZ_API char *rz_analysis_function_get_json(RzAnalysisFunction *function) {
RZ_API RZ_OWN char *rz_analysis_function_get_json(RzAnalysisFunction *function) {
char *tmp = NULL;
RzAnalysis *a = function->analysis;
PJ *pj = pj_new();
Expand Down Expand Up @@ -2017,8 +2017,8 @@ RZ_API RzAnalysisFunction *rz_analysis_fcn_next(RzAnalysis *analysis, ut64 addr)
return closer;
}

RZ_API int rz_analysis_fcn_count(RzAnalysis *analysis, ut64 from, ut64 to) {
int n = 0;
RZ_API ut32 rz_analysis_fcn_count(RzAnalysis *analysis, ut64 from, ut64 to) {
ut32 n = 0;
RzAnalysisFunction *fcni;
RzListIter *iter;
rz_list_foreach (analysis->fcns, iter, fcni) {
Expand Down Expand Up @@ -2105,10 +2105,10 @@ RZ_API ut32 rz_analysis_function_cost(RzAnalysisFunction *fcn) {
return totalCycles;
}

RZ_API int rz_analysis_function_count_edges(const RzAnalysisFunction *fcn, RZ_NULLABLE int *ebbs) {
RZ_API ut32 rz_analysis_function_count_edges(const RzAnalysisFunction *fcn, RZ_NULLABLE int *ebbs) {
rz_return_val_if_fail(fcn, 0);
RzAnalysisBlock *bb;
int edges = 0;
ut32 edges = 0;
if (ebbs) {
*ebbs = 0;
}
Expand Down
10 changes: 5 additions & 5 deletions librz/include/rz_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ RZ_API bool rz_analysis_add_device_peripheral_map(RzBinObject *o, RzAnalysis *an

/* fcn.c */
RZ_API ut32 rz_analysis_function_cost(RzAnalysisFunction *fcn);
RZ_API int rz_analysis_function_count_edges(const RzAnalysisFunction *fcn, RZ_NULLABLE int *ebbs);
RZ_API ut32 rz_analysis_function_count_edges(const RzAnalysisFunction *fcn, RZ_NULLABLE int *ebbs);

// Use rz_analysis_get_functions_in¿() instead
RZ_DEPRECATE RZ_API RzAnalysisFunction *rz_analysis_get_fcn_in(RzAnalysis *analysis, ut64 addr, int type);
Expand All @@ -1764,16 +1764,16 @@ RZ_API void rz_analysis_function_update_analysis(RzAnalysisFunction *fcn);
RZ_API bool rz_analysis_task_item_new(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzVector /*<RzAnalysisTaskItem>*/ *tasks, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NULLABLE RzAnalysisBlock *block, ut64 address, RzStackAddr sp);
RZ_API int rz_analysis_run_tasks(RZ_NONNULL RzVector /*<RzAnalysisTaskItem>*/ *tasks);

RZ_API int rz_analysis_function_complexity(RzAnalysisFunction *fcn);
RZ_API int rz_analysis_function_loops(RzAnalysisFunction *fcn);
RZ_API ut32 rz_analysis_function_complexity(RzAnalysisFunction *fcn);
RZ_API ut32 rz_analysis_function_loops(RzAnalysisFunction *fcn);
RZ_API void rz_analysis_trim_jmprefs(RzAnalysis *analysis, RzAnalysisFunction *fcn);
RZ_API void rz_analysis_del_jmprefs(RzAnalysis *analysis, RzAnalysisFunction *fcn);
RZ_API char *rz_analysis_function_get_json(RzAnalysisFunction *function);
RZ_API RZ_OWN char *rz_analysis_function_get_json(RzAnalysisFunction *function);
RZ_API RzAnalysisFunction *rz_analysis_fcn_next(RzAnalysis *analysis, ut64 addr);
RZ_API RZ_OWN char *rz_analysis_function_get_signature(RZ_NONNULL RzAnalysisFunction *function);
RZ_API void rz_analysis_function_set_type(RzAnalysis *a, RZ_NONNULL RzAnalysisFunction *f, RZ_NONNULL RzCallable *callable);
RZ_API bool rz_analysis_function_set_type_str(RzAnalysis *a, RZ_NONNULL RzAnalysisFunction *f, RZ_NONNULL const char *sig);
RZ_API int rz_analysis_fcn_count(RzAnalysis *a, ut64 from, ut64 to);
RZ_API ut32 rz_analysis_fcn_count(RzAnalysis *a, ut64 from, ut64 to);
RZ_API RzAnalysisBlock *rz_analysis_fcn_bbget_in(const RzAnalysis *analysis, RzAnalysisFunction *fcn, ut64 addr);
RZ_API RzAnalysisBlock *rz_analysis_fcn_bbget_at(RzAnalysis *analysis, RzAnalysisFunction *fcn, ut64 addr);
RZ_API int rz_analysis_function_resize(RzAnalysisFunction *fcn, int newsize);
Expand Down

0 comments on commit 2486e56

Please sign in to comment.