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/section.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'rust/src/section.rs') diff --git a/rust/src/section.rs b/rust/src/section.rs index d1098e67..53afffb3 100644 --- a/rust/src/section.rs +++ b/rust/src/section.rs @@ -14,7 +14,6 @@ //! Sections are [crate::segment::Segment]s that are loaded into memory at run time -use std::ffi::c_char; use std::fmt; use std::ops::Range; @@ -282,29 +281,29 @@ impl SectionBuilder { if self.is_auto { BNAddAutoSection( view.handle, - name.as_ptr() as *const c_char, + name.as_ptr(), start, len, self.semantics.into(), - ty.as_ptr() as *const c_char, + ty.as_ptr(), self.align, self.entry_size, - linked_section.as_ptr() as *const c_char, - info_section.as_ptr() as *const c_char, + linked_section.as_ptr(), + info_section.as_ptr(), self.info_data, ); } else { BNAddUserSection( view.handle, - name.as_ptr() as *const c_char, + name.as_ptr(), start, len, self.semantics.into(), - ty.as_ptr() as *const c_char, + ty.as_ptr(), self.align, self.entry_size, - linked_section.as_ptr() as *const c_char, - info_section.as_ptr() as *const c_char, + linked_section.as_ptr(), + info_section.as_ptr(), self.info_data, ); } -- cgit v1.3.1