summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2021-06-08 17:23:28 -0400
committerKyleMiles <krm504@nyu.edu>2021-07-07 23:27:28 -0400
commit8785e9d1a931d7562053fd6045b660a6211fbc1d (patch)
tree4506696e861fcffa3e321bd32e00621a90a42693
parent013945b3efa885101db16990311093912775d1c6 (diff)
Rust API : Replace Platform::from_raw with Platform::ref_from_raw
-rw-r--r--rust/src/architecture.rs2
-rw-r--r--rust/src/binaryview.rs2
-rw-r--r--rust/src/function.rs2
-rw-r--r--rust/src/platform.rs7
4 files changed, 7 insertions, 6 deletions
diff --git a/rust/src/architecture.rs b/rust/src/architecture.rs
index 960dc740..0d1bd501 100644
--- a/rust/src/architecture.rs
+++ b/rust/src/architecture.rs
@@ -1233,7 +1233,7 @@ pub trait ArchitectureExt: Architecture {
return None;
}
- Some(Ref::new(Platform::from_raw(handle)))
+ Some(Platform::ref_from_raw(handle))
}
}
}
diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs
index b2b3dca6..21239fc2 100644
--- a/rust/src/binaryview.rs
+++ b/rust/src/binaryview.rs
@@ -247,7 +247,7 @@ pub trait BinaryViewExt: BinaryViewBase {
return None;
}
- Some(Ref::new(Platform::from_raw(raw)))
+ Some(Platform::ref_from_raw(raw))
}
}
diff --git a/rust/src/function.rs b/rust/src/function.rs
index 4230900f..51c9e634 100644
--- a/rust/src/function.rs
+++ b/rust/src/function.rs
@@ -133,7 +133,7 @@ impl Function {
pub fn platform(&self) -> Ref<Platform> {
unsafe {
let plat = BNGetFunctionPlatform(self.handle);
- Ref::new(Platform::from_raw(plat))
+ Platform::ref_from_raw(plat)
}
}
diff --git a/rust/src/platform.rs b/rust/src/platform.rs
index bc5cb9f1..b79b9611 100644
--- a/rust/src/platform.rs
+++ b/rust/src/platform.rs
@@ -64,10 +64,10 @@ macro_rules! cc_func {
}
impl Platform {
- pub(crate) unsafe fn from_raw(handle: *mut BNPlatform) -> Self {
+ pub(crate) unsafe fn ref_from_raw(handle: *mut BNPlatform) -> Ref<Self> {
debug_assert!(!handle.is_null());
- Self { handle }
+ Ref::new(Self { handle })
}
pub fn by_name<S: BnStrCompatible>(name: S) -> Option<Ref<Self>> {
@@ -360,6 +360,7 @@ unsafe impl<'a> CoreOwnedArrayWrapper<'a> for Platform {
type Wrapped = Guard<'a, Platform>;
unsafe fn wrap_raw(raw: &'a *mut BNPlatform, context: &'a ()) -> Guard<'a, Platform> {
- Guard::new(Platform::from_raw(*raw), context)
+ debug_assert!(!raw.is_null());
+ Guard::new(Platform { handle: *raw }, context)
}
}