@@ -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 ,
@@ -1928,11 +1927,9 @@ macro_rules! cc_func {
1928
1927
1929
1928
/// Contains helper methods for all types implementing 'Architecture'
1930
1929
pub trait ArchitectureExt : Architecture {
1931
- fn register_by_name < S : BnStrCompatible > ( & self , name : S ) -> Option < Self :: Register > {
1932
- let name = name. into_bytes_with_nul ( ) ;
1933
-
1930
+ fn register_by_name < S : AsCStr > ( & self , name : S ) -> Option < Self :: Register > {
1934
1931
match unsafe {
1935
- BNGetArchitectureRegisterByName ( self . as_ref ( ) . handle , name. as_ref ( ) . as_ptr ( ) as * mut _ )
1932
+ BNGetArchitectureRegisterByName ( self . as_ref ( ) . handle , name. as_cstr ( ) . as_ptr ( ) )
1936
1933
} {
1937
1934
0xffff_ffff => None ,
1938
1935
reg => self . register_from_id ( reg. into ( ) ) ,
@@ -2008,7 +2005,7 @@ pub trait ArchitectureExt: Architecture {
2008
2005
2009
2006
fn register_relocation_handler < S , R , F > ( & self , name : S , func : F )
2010
2007
where
2011
- S : BnStrCompatible ,
2008
+ S : AsCStr ,
2012
2009
R : ' static
2013
2010
+ RelocationHandler < Handle = CustomRelocationHandlerHandle < R > >
2014
2011
+ Send
@@ -2031,7 +2028,7 @@ impl<T: Architecture> ArchitectureExt for T {}
2031
2028
2032
2029
pub fn register_architecture < S , A , F > ( name : S , func : F ) -> & ' static A
2033
2030
where
2034
- S : BnStrCompatible ,
2031
+ S : AsCStr ,
2035
2032
A : ' static + Architecture < Handle = CustomArchitectureHandle < A > > + Send + Sync + Sized ,
2036
2033
F : FnOnce ( CustomArchitectureHandle < A > , CoreArchitecture ) -> A ,
2037
2034
{
@@ -3114,8 +3111,6 @@ where
3114
3111
custom_arch. skip_and_return_value ( data, addr, val)
3115
3112
}
3116
3113
3117
- let name = name. into_bytes_with_nul ( ) ;
3118
-
3119
3114
let uninit_arch = ArchitectureBuilder {
3120
3115
arch : MaybeUninit :: zeroed ( ) ,
3121
3116
func : Some ( func) ,
@@ -3205,8 +3200,7 @@ where
3205
3200
} ;
3206
3201
3207
3202
unsafe {
3208
- let res =
3209
- BNRegisterArchitecture ( name. as_ref ( ) . as_ptr ( ) as * mut _ , & mut custom_arch as * mut _ ) ;
3203
+ let res = BNRegisterArchitecture ( name. as_cstr ( ) . as_ptr ( ) , & mut custom_arch as * mut _ ) ;
3210
3204
3211
3205
assert ! ( !res. is_null( ) ) ;
3212
3206
0 commit comments