@@ -27,7 +27,7 @@ use crate::{
2727 platform:: Platform ,
2828 rc:: * ,
2929 relocation:: CoreRelocationHandler ,
30- string:: BnStrCompatible ,
30+ string:: AsCStr ,
3131 string:: * ,
3232 types:: { NameAndType , Type } ,
3333 Endianness ,
@@ -1397,8 +1397,7 @@ impl CoreArchitecture {
13971397 }
13981398
13991399 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 ( ) ) } ;
14021401 match handle. is_null ( ) {
14031402 false => Some ( CoreArchitecture { handle } ) ,
14041403 true => None ,
@@ -1928,11 +1927,9 @@ macro_rules! cc_func {
19281927
19291928/// Contains helper methods for all types implementing 'Architecture'
19301929pub 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 > {
19341931 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 ( ) )
19361933 } {
19371934 0xffff_ffff => None ,
19381935 reg => self . register_from_id ( reg. into ( ) ) ,
@@ -2008,7 +2005,7 @@ pub trait ArchitectureExt: Architecture {
20082005
20092006 fn register_relocation_handler < S , R , F > ( & self , name : S , func : F )
20102007 where
2011- S : BnStrCompatible ,
2008+ S : AsCStr ,
20122009 R : ' static
20132010 + RelocationHandler < Handle = CustomRelocationHandlerHandle < R > >
20142011 + Send
@@ -2031,7 +2028,7 @@ impl<T: Architecture> ArchitectureExt for T {}
20312028
20322029pub fn register_architecture < S , A , F > ( name : S , func : F ) -> & ' static A
20332030where
2034- S : BnStrCompatible ,
2031+ S : AsCStr ,
20352032 A : ' static + Architecture < Handle = CustomArchitectureHandle < A > > + Send + Sync + Sized ,
20362033 F : FnOnce ( CustomArchitectureHandle < A > , CoreArchitecture ) -> A ,
20372034{
@@ -3114,8 +3111,6 @@ where
31143111 custom_arch. skip_and_return_value ( data, addr, val)
31153112 }
31163113
3117- let name = name. into_bytes_with_nul ( ) ;
3118-
31193114 let uninit_arch = ArchitectureBuilder {
31203115 arch : MaybeUninit :: zeroed ( ) ,
31213116 func : Some ( func) ,
@@ -3205,8 +3200,7 @@ where
32053200 } ;
32063201
32073202 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 _ ) ;
32103204
32113205 assert ! ( !res. is_null( ) ) ;
32123206
0 commit comments