From 788a8b7091bbdde77817030e0836d7a7a786fd99 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 4 May 2025 19:47:55 -0400 Subject: [Rust] Simplify usage surrounding c strings `cstring.as_ref().as_ptr() as *const c_char` -> `cstring.as_ptr()` `cstring.as_ref().as_ptr() as *mut _` -> `cstring.as_ptr()` `cstring.as_ptr() as *const c_char` -> `cstring.as_ptr()` With a few fixes for cstrings that might be dropped prematurely. --- rust/src/function.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'rust/src/function.rs') diff --git a/rust/src/function.rs b/rust/src/function.rs index dcefaa35..36bd1d56 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -376,7 +376,7 @@ impl Function { let raw = comment.to_cstr(); unsafe { - BNSetFunctionComment(self.handle, raw.as_ref().as_ptr() as *mut _); + BNSetFunctionComment(self.handle, raw.as_ptr()); } } @@ -398,7 +398,7 @@ impl Function { let raw = comment.to_cstr(); unsafe { - BNSetCommentForAddress(self.handle, addr, raw.as_ref().as_ptr() as *mut _); + BNSetCommentForAddress(self.handle, addr, raw.as_ptr()); } } @@ -1712,7 +1712,7 @@ impl Function { let arch = arch.unwrap_or_else(|| self.arch()); let enum_display_typeid = enum_display_typeid.map(AsCStr::to_cstr); let enum_display_typeid_ptr = enum_display_typeid - .map(|x| x.as_ref().as_ptr() as *const c_char) + .map(|x| x.as_ptr()) .unwrap_or(std::ptr::null()); unsafe { BNSetIntegerConstantDisplayType( -- cgit v1.3.1