@@ -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 ,
@@ -1931,11 +1930,9 @@ macro_rules! cc_func {
19311930
19321931/// Contains helper methods for all types implementing 'Architecture'
19331932pub 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 > {
19371934 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 ( ) )
19391936 } {
19401937 0xffff_ffff => None ,
19411938 reg => self . register_from_id ( reg. into ( ) ) ,
@@ -2011,7 +2008,7 @@ pub trait ArchitectureExt: Architecture {
20112008
20122009 fn register_relocation_handler < S , R , F > ( & self , name : S , func : F )
20132010 where
2014- S : BnStrCompatible ,
2011+ S : AsCStr ,
20152012 R : ' static
20162013 + RelocationHandler < Handle = CustomRelocationHandlerHandle < R > >
20172014 + Send
@@ -2034,7 +2031,7 @@ impl<T: Architecture> ArchitectureExt for T {}
20342031
20352032pub fn register_architecture < S , A , F > ( name : S , func : F ) -> & ' static A
20362033where
2037- S : BnStrCompatible ,
2034+ S : AsCStr ,
20382035 A : ' static + Architecture < Handle = CustomArchitectureHandle < A > > + Send + Sync + Sized ,
20392036 F : FnOnce ( CustomArchitectureHandle < A > , CoreArchitecture ) -> A ,
20402037{
@@ -3117,8 +3114,6 @@ where
31173114 custom_arch. skip_and_return_value ( data, addr, val)
31183115 }
31193116
3120- let name = name. into_bytes_with_nul ( ) ;
3121-
31223117 let uninit_arch = ArchitectureBuilder {
31233118 arch : MaybeUninit :: zeroed ( ) ,
31243119 func : Some ( func) ,
@@ -3208,8 +3203,7 @@ where
32083203 } ;
32093204
32103205 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 _ ) ;
32133207
32143208 assert ! ( !res. is_null( ) ) ;
32153209
0 commit comments