Skip to content

Commit

Permalink
Add docs and assert
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Sep 25, 2024
1 parent 00509a8 commit eeed837
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions librz/core/cgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ static void extend_icfg(const RzAnalysis *analysis, RZ_BORROW RzGraph /*<RzGraph
continue;
}
RzGraphNode *to_node = get_graph_node_of_fcn(icfg, graph_idx, called_fcn);
assert(to_node && from_node);
if (rz_graph_adjacent(icfg, from_node, to_node)) {
// Edge already added and walked. Don't recurse.
continue;
Expand Down
15 changes: 14 additions & 1 deletion librz/util/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,20 @@ RZ_API const RzList *rz_graph_get_nodes(const RzGraph *g) {
return g ? g->nodes : NULL;
}

/* true if there is an edge from the node `from` to the node `to` */
/**
* \brief Checks if the edge \p from -> \p to exists in the graph.
* For this it checks the neighbors of \p from.
*
* \param g The graph to check.
* \param from The pointer to the source node of the edge. The pointer must be a node in the graph.
* \param to The destination node of the edge. The pointer must be a node in the graph.
*
* NOTE: It only compares the pointer of \p to against the neighbor list of \p from.
* If the pointer doesn't match it returns false. Even if the node content is the same.
*
* \returns true If there is an edge from the node `from` to the node `to`
* \return false Otherwise
*/
RZ_API bool rz_graph_adjacent(const RzGraph *g, const RzGraphNode *from, const RzGraphNode *to) {
if (!g || !from) {
return false;
Expand Down

0 comments on commit eeed837

Please sign in to comment.