summaryrefslogtreecommitdiff
path: root/rust/src/platform.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-04 19:47:55 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commit788a8b7091bbdde77817030e0836d7a7a786fd99 (patch)
tree40e8f8d3c870788259a5acb5d14995cdc1656979 /rust/src/platform.rs
parenta826c589dfc10c542deba7ca3343a462e02d6bde (diff)
[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.
Diffstat (limited to 'rust/src/platform.rs')
-rw-r--r--rust/src/platform.rs24
1 files changed, 8 insertions, 16 deletions
diff --git a/rust/src/platform.rs b/rust/src/platform.rs
index 19186740..c225392f 100644
--- a/rust/src/platform.rs
+++ b/rust/src/platform.rs
@@ -85,7 +85,7 @@ impl Platform {
pub fn by_name<S: AsCStr>(name: S) -> Option<Ref<Self>> {
let raw_name = name.to_cstr();
unsafe {
- let res = BNGetPlatformByName(raw_name.as_ref().as_ptr() as *mut _);
+ let res = BNGetPlatformByName(raw_name.as_ptr());
if res.is_null() {
None
@@ -118,7 +118,7 @@ impl Platform {
unsafe {
let mut count = 0;
- let handles = BNGetPlatformListByOS(raw_name.as_ref().as_ptr() as *mut _, &mut count);
+ let handles = BNGetPlatformListByOS(raw_name.as_ptr(), &mut count);
Array::new(handles, count, ())
}
@@ -129,11 +129,8 @@ impl Platform {
unsafe {
let mut count = 0;
- let handles = BNGetPlatformListByOSAndArchitecture(
- raw_name.as_ref().as_ptr() as *mut _,
- arch.handle,
- &mut count,
- );
+ let handles =
+ BNGetPlatformListByOSAndArchitecture(raw_name.as_ptr(), arch.handle, &mut count);
Array::new(handles, count, ())
}
@@ -151,7 +148,7 @@ impl Platform {
pub fn new<A: Architecture, S: AsCStr>(arch: &A, name: S) -> Ref<Self> {
let name = name.to_cstr();
unsafe {
- let handle = BNCreatePlatform(arch.as_ref().handle, name.as_ref().as_ptr() as *mut _);
+ let handle = BNCreatePlatform(arch.as_ref().handle, name.as_ptr());
assert!(!handle.is_null());
Ref::new(Self { handle })
}
@@ -179,13 +176,8 @@ impl Platform {
pub fn get_type_libraries_by_name<T: AsCStr>(&self, name: T) -> Array<TypeLibrary> {
let mut count = 0;
let name = name.to_cstr();
- let result = unsafe {
- BNGetPlatformTypeLibrariesByName(
- self.handle,
- name.as_ref().as_ptr() as *mut _,
- &mut count,
- )
- };
+ let result =
+ unsafe { BNGetPlatformTypeLibrariesByName(self.handle, name.as_ptr(), &mut count) };
assert!(!result.is_null());
unsafe { Array::new(result, count, ()) }
}
@@ -194,7 +186,7 @@ impl Platform {
let os = os.to_cstr();
unsafe {
- BNRegisterPlatform(os.as_ref().as_ptr() as *mut _, self.handle);
+ BNRegisterPlatform(os.as_ptr(), self.handle);
}
}