Skip to content

Commit

Permalink
only create FlowGraph with Ref
Browse files Browse the repository at this point in the history
  • Loading branch information
rbran authored and ElykDeer committed May 9, 2024
1 parent fe710ff commit 4e2fbc2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rust/examples/dwarf/dwarfdump/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn dump_dwarf(bv: &BinaryView) {
}
}

view.show_graph_report("DWARF", graph);
view.show_graph_report("DWARF", &graph);
}

struct DWARFDump;
Expand Down
2 changes: 1 addition & 1 deletion rust/examples/flowgraph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn test_graph(view: &BinaryView) {
&EdgeStyle::default(),
);

view.show_graph_report("Rust Graph Title", graph);
view.show_graph_report("Rust Graph Title", &graph);
}

#[no_mangle]
Expand Down
2 changes: 1 addition & 1 deletion rust/src/binaryview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ pub trait BinaryViewExt: BinaryViewBase {
unsafe { BNApplyDebugInfo(self.as_ref().handle, debug_info.handle) }
}

fn show_graph_report<S: BnStrCompatible>(&self, raw_name: S, graph: FlowGraph) {
fn show_graph_report<S: BnStrCompatible>(&self, raw_name: S, graph: &FlowGraph) {
let raw_name = raw_name.into_bytes_with_nul();
unsafe {
BNShowGraphReport(
Expand Down
6 changes: 2 additions & 4 deletions rust/src/flowgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ impl<'a> ToOwned for FlowGraphNode<'a> {
}
}

// TODO : FlowGraph are RefCounted objects, this needs to be changed to only return Refs to FlowGraph

#[derive(PartialEq, Eq, Hash)]
pub struct FlowGraph {
pub(crate) handle: *mut BNFlowGraph,
Expand All @@ -126,8 +124,8 @@ impl FlowGraph {
Self { handle: raw }
}

pub fn new() -> Self {
unsafe { FlowGraph::from_raw(BNCreateFlowGraph()) }
pub fn new() -> Ref<Self> {
unsafe { Ref::new(FlowGraph::from_raw(BNCreateFlowGraph())) }
}

pub fn append(&self, node: &FlowGraphNode) -> usize {
Expand Down

0 comments on commit 4e2fbc2

Please sign in to comment.