Skip to content

Commit 4e2fbc2

Browse files
rbranElykDeer
authored andcommitted
only create FlowGraph with Ref
1 parent fe710ff commit 4e2fbc2

4 files changed

Lines changed: 5 additions & 7 deletions

File tree

‎rust/examples/dwarf/dwarfdump/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ fn dump_dwarf(bv: &BinaryView) {
281281
}
282282
}
283283

284-
view.show_graph_report("DWARF", graph);
284+
view.show_graph_report("DWARF", &graph);
285285
}
286286

287287
struct DWARFDump;

‎rust/examples/flowgraph/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn test_graph(view: &BinaryView) {
3636
&EdgeStyle::default(),
3737
);
3838

39-
view.show_graph_report("Rust Graph Title", graph);
39+
view.show_graph_report("Rust Graph Title", &graph);
4040
}
4141

4242
#[no_mangle]

‎rust/src/binaryview.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ pub trait BinaryViewExt: BinaryViewBase {
10641064
unsafe { BNApplyDebugInfo(self.as_ref().handle, debug_info.handle) }
10651065
}
10661066

1067-
fn show_graph_report<S: BnStrCompatible>(&self, raw_name: S, graph: FlowGraph) {
1067+
fn show_graph_report<S: BnStrCompatible>(&self, raw_name: S, graph: &FlowGraph) {
10681068
let raw_name = raw_name.into_bytes_with_nul();
10691069
unsafe {
10701070
BNShowGraphReport(

‎rust/src/flowgraph.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ impl<'a> ToOwned for FlowGraphNode<'a> {
114114
}
115115
}
116116

117-
// TODO : FlowGraph are RefCounted objects, this needs to be changed to only return Refs to FlowGraph
118-
119117
#[derive(PartialEq, Eq, Hash)]
120118
pub struct FlowGraph {
121119
pub(crate) handle: *mut BNFlowGraph,
@@ -126,8 +124,8 @@ impl FlowGraph {
126124
Self { handle: raw }
127125
}
128126

129-
pub fn new() -> Self {
130-
unsafe { FlowGraph::from_raw(BNCreateFlowGraph()) }
127+
pub fn new() -> Ref<Self> {
128+
unsafe { Ref::new(FlowGraph::from_raw(BNCreateFlowGraph())) }
131129
}
132130

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

0 commit comments

Comments
 (0)