From a826c589dfc10c542deba7ca3343a462e02d6bde Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 4 May 2025 19:10:56 -0400 Subject: [Rust] Simplify `BnStrCompatible` trait Followup to https://github.com/Vector35/binaryninja-api/pull/5897/ This simplifies usage of the trait in user code, should just be able to `to_cstr` to get the cstr repr and then call `as_ptr`. Co-authored-by: Michael Krasnitski --- rust/src/disassembly.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'rust/src/disassembly.rs') diff --git a/rust/src/disassembly.rs b/rust/src/disassembly.rs index 6125f623..5964324d 100644 --- a/rust/src/disassembly.rs +++ b/rust/src/disassembly.rs @@ -22,7 +22,7 @@ use crate::function::{Location, NativeBlock}; use crate::high_level_il as hlil; use crate::low_level_il as llil; use crate::medium_level_il as mlil; -use crate::string::BnStrCompatible; +use crate::string::AsCStr; use crate::string::{raw_to_string, strings_to_string_list, BnString}; use crate::rc::*; @@ -1242,7 +1242,7 @@ impl DisassemblyTextRenderer { unsafe { Array::new(tokens, count, ()) } } - pub fn wrap_comment( + pub fn wrap_comment( &self, cur_line: DisassemblyTextLine, comment: S1, @@ -1251,9 +1251,9 @@ impl DisassemblyTextRenderer { indent_spaces: S3, ) -> Array { let cur_line_raw = DisassemblyTextLine::into_raw(cur_line); - let comment_raw = comment.into_bytes_with_nul(); - let leading_spaces_raw = leading_spaces.into_bytes_with_nul(); - let indent_spaces_raw = indent_spaces.into_bytes_with_nul(); + let comment_raw = comment.to_cstr(); + let leading_spaces_raw = leading_spaces.to_cstr(); + let indent_spaces_raw = indent_spaces.to_cstr(); let mut count = 0; let lines = unsafe { BNDisassemblyTextRendererWrapComment( -- cgit v1.3.1