@@ -27,7 +27,7 @@ use crate::{
27
27
platform:: Platform ,
28
28
rc:: * ,
29
29
relocation:: CoreRelocationHandler ,
30
- string:: BnStrCompatible ,
30
+ string:: AsCStr ,
31
31
string:: * ,
32
32
types:: { NameAndType , Type } ,
33
33
Endianness ,
@@ -1397,8 +1397,7 @@ impl CoreArchitecture {
1397
1397
}
1398
1398
1399
1399
pub fn by_name ( name : & str ) -> Option < Self > {
1400
- let handle =
1401
- unsafe { BNGetArchitectureByName ( name. into_bytes_with_nul ( ) . as_ptr ( ) as * mut _ ) } ;
1400
+ let handle = unsafe { BNGetArchitectureByName ( name. as_cstr ( ) . as_ptr ( ) ) } ;
1402
1401
match handle. is_null ( ) {
1403
1402
false => Some ( CoreArchitecture { handle } ) ,
1404
1403
true => None ,
@@ -1945,11 +1944,9 @@ macro_rules! cc_func {
1945
1944
1946
1945
/// Contains helper methods for all types implementing 'Architecture'
1947
1946
pub trait ArchitectureExt : Architecture {
1948
- fn register_by_name < S : BnStrCompatible > ( & self , name : S ) -> Option < Self :: Register > {
1949
- let name = name. into_bytes_with_nul ( ) ;
1950
-
1947
+ fn register_by_name < S : AsCStr > ( & self , name : S ) -> Option < Self :: Register > {
1951
1948
match unsafe {
1952
- BNGetArchitectureRegisterByName ( self . as_ref ( ) . handle , name. as_ref ( ) . as_ptr ( ) as * mut _ )
1949
+ BNGetArchitectureRegisterByName ( self . as_ref ( ) . handle , name. as_cstr ( ) . as_ptr ( ) )
1953
1950
} {
1954
1951
0xffff_ffff => None ,
1955
1952
reg => self . register_from_id ( reg. into ( ) ) ,
@@ -2025,7 +2022,7 @@ pub trait ArchitectureExt: Architecture {
2025
2022
2026
2023
fn register_relocation_handler < S , R , F > ( & self , name : S , func : F )
2027
2024
where
2028
- S : BnStrCompatible ,
2025
+ S : AsCStr ,
2029
2026
R : ' static
2030
2027
+ RelocationHandler < Handle = CustomRelocationHandlerHandle < R > >
2031
2028
+ Send
@@ -2048,7 +2045,7 @@ impl<T: Architecture> ArchitectureExt for T {}
2048
2045
2049
2046
pub fn register_architecture < S , A , F > ( name : S , func : F ) -> & ' static A
2050
2047
where
2051
- S : BnStrCompatible ,
2048
+ S : AsCStr ,
2052
2049
A : ' static + Architecture < Handle = CustomArchitectureHandle < A > > + Send + Sync + Sized ,
2053
2050
F : FnOnce ( CustomArchitectureHandle < A > , CoreArchitecture ) -> A ,
2054
2051
{
@@ -3131,8 +3128,6 @@ where
3131
3128
custom_arch. skip_and_return_value ( data, addr, val)
3132
3129
}
3133
3130
3134
- let name = name. into_bytes_with_nul ( ) ;
3135
-
3136
3131
let uninit_arch = ArchitectureBuilder {
3137
3132
arch : MaybeUninit :: zeroed ( ) ,
3138
3133
func : Some ( func) ,
@@ -3222,8 +3217,7 @@ where
3222
3217
} ;
3223
3218
3224
3219
unsafe {
3225
- let res =
3226
- BNRegisterArchitecture ( name. as_ref ( ) . as_ptr ( ) as * mut _ , & mut custom_arch as * mut _ ) ;
3220
+ let res = BNRegisterArchitecture ( name. as_cstr ( ) . as_ptr ( ) , & mut custom_arch as * mut _ ) ;
3227
3221
3228
3222
assert ! ( !res. is_null( ) ) ;
3229
3223
0 commit comments