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