summaryrefslogtreecommitdiff
path: root/rust/src/architecture.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/architecture.rs')
-rw-r--r--rust/src/architecture.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/rust/src/architecture.rs b/rust/src/architecture.rs
index ee8033a2..74a8dfa4 100644
--- a/rust/src/architecture.rs
+++ b/rust/src/architecture.rs
@@ -27,7 +27,7 @@ use crate::{
platform::Platform,
rc::*,
relocation::CoreRelocationHandler,
- string::BnStrCompatible,
+ string::AsCStr,
string::*,
types::{NameAndType, Type},
Endianness,
@@ -1404,8 +1404,7 @@ impl CoreArchitecture {
}
pub fn by_name(name: &str) -> Option<Self> {
- let handle =
- unsafe { BNGetArchitectureByName(name.into_bytes_with_nul().as_ptr() as *mut _) };
+ let handle = unsafe { BNGetArchitectureByName(name.to_cstr().as_ptr() as *mut _) };
match handle.is_null() {
false => Some(CoreArchitecture { handle }),
true => None,
@@ -1953,8 +1952,8 @@ macro_rules! cc_func {
/// Contains helper methods for all types implementing 'Architecture'
pub trait ArchitectureExt: Architecture {
- fn register_by_name<S: BnStrCompatible>(&self, name: S) -> Option<Self::Register> {
- let name = name.into_bytes_with_nul();
+ fn register_by_name<S: AsCStr>(&self, name: S) -> Option<Self::Register> {
+ let name = name.to_cstr();
match unsafe {
BNGetArchitectureRegisterByName(self.as_ref().handle, name.as_ref().as_ptr() as *mut _)
@@ -2033,7 +2032,7 @@ pub trait ArchitectureExt: Architecture {
fn register_relocation_handler<S, R, F>(&self, name: S, func: F)
where
- S: BnStrCompatible,
+ S: AsCStr,
R: 'static
+ RelocationHandler<Handle = CustomRelocationHandlerHandle<R>>
+ Send
@@ -2056,7 +2055,7 @@ impl<T: Architecture> ArchitectureExt for T {}
pub fn register_architecture<S, A, F>(name: S, func: F) -> &'static A
where
- S: BnStrCompatible,
+ S: AsCStr,
A: 'static + Architecture<Handle = CustomArchitectureHandle<A>> + Send + Sync + Sized,
F: FnOnce(CustomArchitectureHandle<A>, CoreArchitecture) -> A,
{
@@ -3130,7 +3129,7 @@ where
custom_arch.skip_and_return_value(data, addr, val)
}
- let name = name.into_bytes_with_nul();
+ let name = name.to_cstr();
let uninit_arch = ArchitectureBuilder {
arch: MaybeUninit::zeroed(),