diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-12 16:43:42 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 811fb8543a66705594647fd76cfaf4f3fd02fda4 (patch) | |
| tree | 691a122a128ef18db09748b71239392c3e46872c /rust | |
| parent | 631222aaf4afc218741deb9307edc01ecb26c109 (diff) | |
[Rust] Misc cleanup regarding c strings
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/src/function.rs | 13 | ||||
| -rw-r--r-- | rust/src/interaction/report.rs | 19 |
2 files changed, 16 insertions, 16 deletions
diff --git a/rust/src/function.rs b/rust/src/function.rs index 58b310c7..60c8970c 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -48,10 +48,11 @@ use crate::variable::{ StackVariableReference, Variable, }; use crate::workflow::Workflow; +use std::ffi::CStr; use std::fmt::{Debug, Formatter}; use std::ptr::NonNull; use std::time::Duration; -use std::{ffi::c_char, hash::Hash, ops::Range}; +use std::{hash::Hash, ops::Range}; /// Used to describe a location within a [`Function`]. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -2213,17 +2214,17 @@ impl Function { /// /// * `name` - Name of the debug report pub fn request_debug_report(&self, name: &str) { - const DEBUG_REPORT_ALIAS: &[(&str, &str)] = &[ - ("stack", "stack_adjust_graph\x00"), - ("mlil", "mlil_translator\x00"), - ("hlil", "high_level_il\x00"), + const DEBUG_REPORT_ALIAS: &[(&str, &CStr)] = &[ + ("stack", c"stack_adjust_graph"), + ("mlil", c"mlil_translator"), + ("hlil", c"high_level_il"), ]; if let Some(alias_idx) = DEBUG_REPORT_ALIAS .iter() .position(|(alias, _value)| *alias == name) { - let name = DEBUG_REPORT_ALIAS[alias_idx].1.as_ptr() as *const c_char; + let name = DEBUG_REPORT_ALIAS[alias_idx].1.as_ptr(); unsafe { BNRequestFunctionDebugReport(self.handle, name) } } else { let name = std::ffi::CString::new(name.to_string()).unwrap(); diff --git a/rust/src/interaction/report.rs b/rust/src/interaction/report.rs index 689b815b..415845db 100644 --- a/rust/src/interaction/report.rs +++ b/rust/src/interaction/report.rs @@ -1,4 +1,3 @@ -use std::ffi::c_char; use std::ptr::NonNull; use binaryninjacore_sys::*; @@ -81,8 +80,8 @@ impl ReportCollection { BNAddPlainTextReportToCollection( self.handle.as_ptr(), view.handle, - title.as_ref().as_ptr() as *const c_char, - contents.as_ref().as_ptr() as *const c_char, + title.as_ptr(), + contents.as_ptr(), ) } } @@ -95,9 +94,9 @@ impl ReportCollection { BNAddMarkdownReportToCollection( self.handle.as_ptr(), view.handle, - title.as_ref().as_ptr() as *const c_char, - contents.as_ref().as_ptr() as *const c_char, - plaintext.as_ref().as_ptr() as *const c_char, + title.as_ptr(), + contents.as_ptr(), + plaintext.as_ptr(), ) } } @@ -110,9 +109,9 @@ impl ReportCollection { BNAddHTMLReportToCollection( self.handle.as_ptr(), view.handle, - title.as_ref().as_ptr() as *const c_char, - contents.as_ref().as_ptr() as *const c_char, - plaintext.as_ref().as_ptr() as *const c_char, + title.as_ptr(), + contents.as_ptr(), + plaintext.as_ptr(), ) } } @@ -123,7 +122,7 @@ impl ReportCollection { BNAddGraphReportToCollection( self.handle.as_ptr(), view.handle, - title.as_ref().as_ptr() as *const c_char, + title.as_ptr(), graph.handle, ) } |
