@@ -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 ,
@@ -1945,11 +1944,9 @@ macro_rules! cc_func {
19451944
19461945/// Contains helper methods for all types implementing 'Architecture'
19471946pub 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 > {
19511948 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 ( ) )
19531950 } {
19541951 0xffff_ffff => None ,
19551952 reg => self . register_from_id ( reg. into ( ) ) ,
@@ -2025,7 +2022,7 @@ pub trait ArchitectureExt: Architecture {
20252022
20262023 fn register_relocation_handler < S , R , F > ( & self , name : S , func : F )
20272024 where
2028- S : BnStrCompatible ,
2025+ S : AsCStr ,
20292026 R : ' static
20302027 + RelocationHandler < Handle = CustomRelocationHandlerHandle < R > >
20312028 + Send
@@ -2048,7 +2045,7 @@ impl<T: Architecture> ArchitectureExt for T {}
20482045
20492046pub fn register_architecture < S , A , F > ( name : S , func : F ) -> & ' static A
20502047where
2051- S : BnStrCompatible ,
2048+ S : AsCStr ,
20522049 A : ' static + Architecture < Handle = CustomArchitectureHandle < A > > + Send + Sync + Sized ,
20532050 F : FnOnce ( CustomArchitectureHandle < A > , CoreArchitecture ) -> A ,
20542051{
@@ -3131,8 +3128,6 @@ where
31313128 custom_arch. skip_and_return_value ( data, addr, val)
31323129 }
31333130
3134- let name = name. into_bytes_with_nul ( ) ;
3135-
31363131 let uninit_arch = ArchitectureBuilder {
31373132 arch : MaybeUninit :: zeroed ( ) ,
31383133 func : Some ( func) ,
@@ -3222,8 +3217,7 @@ where
32223217 } ;
32233218
32243219 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 _ ) ;
32273221
32283222 assert ! ( !res. is_null( ) ) ;
32293223
0 commit comments