Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only create FlowGraph with Ref #5307

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1056,7 +1056,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
Loading