@@ -267,12 +267,8 @@ pub trait BinaryViewExt: BinaryViewBase {
267267 }
268268
269269 fn add_analysis_option ( & self , name : impl AsCStr ) {
270- unsafe {
271- BNAddAnalysisOption (
272- self . as_ref ( ) . handle ,
273- name. to_cstr ( ) . as_ref ( ) . as_ptr ( ) as * mut _ ,
274- )
275- }
270+ let name = name. to_cstr ( ) ;
271+ unsafe { BNAddAnalysisOption ( self . as_ref ( ) . handle , name. as_ptr ( ) ) }
276272 }
277273
278274 fn has_initial_analysis ( & self ) -> bool {
@@ -409,7 +405,7 @@ pub trait BinaryViewExt: BinaryViewBase {
409405 unsafe {
410406 let raw_sym_ptr = BNGetSymbolByRawName (
411407 self . as_ref ( ) . handle ,
412- raw_name. as_ref ( ) . as_ptr ( ) as * mut _ ,
408+ raw_name. as_ptr ( ) ,
413409 std:: ptr:: null_mut ( ) ,
414410 ) ;
415411 match raw_sym_ptr. is_null ( ) {
@@ -435,7 +431,7 @@ pub trait BinaryViewExt: BinaryViewBase {
435431 let mut count = 0 ;
436432 let handles = BNGetSymbolsByName (
437433 self . as_ref ( ) . handle ,
438- raw_name. as_ref ( ) . as_ptr ( ) as * mut _ ,
434+ raw_name. as_ptr ( ) ,
439435 & mut count,
440436 std:: ptr:: null_mut ( ) ,
441437 ) ;
@@ -768,10 +764,9 @@ pub trait BinaryViewExt: BinaryViewBase {
768764 }
769765
770766 fn type_by_id < S : AsCStr > ( & self , id : S ) -> Option < Ref < Type > > {
767+ let id_str = id. to_cstr ( ) ;
771768 unsafe {
772- let id_str = id. to_cstr ( ) ;
773- let type_handle =
774- BNGetAnalysisTypeById ( self . as_ref ( ) . handle , id_str. as_ref ( ) . as_ptr ( ) as * mut _ ) ;
769+ let type_handle = BNGetAnalysisTypeById ( self . as_ref ( ) . handle , id_str. as_ptr ( ) ) ;
775770 if type_handle. is_null ( ) {
776771 return None ;
777772 }
@@ -780,10 +775,9 @@ pub trait BinaryViewExt: BinaryViewBase {
780775 }
781776
782777 fn type_name_by_id < S : AsCStr > ( & self , id : S ) -> Option < QualifiedName > {
778+ let id_str = id. to_cstr ( ) ;
783779 unsafe {
784- let id_str = id. to_cstr ( ) ;
785- let name_handle =
786- BNGetAnalysisTypeNameById ( self . as_ref ( ) . handle , id_str. as_ref ( ) . as_ptr ( ) as * mut _ ) ;
780+ let name_handle = BNGetAnalysisTypeNameById ( self . as_ref ( ) . handle , id_str. as_ptr ( ) ) ;
787781 let name = QualifiedName :: from_owned_raw ( name_handle) ;
788782 // The core will return an empty qualified name if no type name was found.
789783 match name. items . is_empty ( ) {
@@ -879,15 +873,15 @@ pub trait BinaryViewExt: BinaryViewBase {
879873
880874 fn remove_auto_section < S : AsCStr > ( & self , name : S ) {
881875 let raw_name = name. to_cstr ( ) ;
882- let raw_name_ptr = raw_name. as_ref ( ) . as_ptr ( ) as * mut _ ;
876+ let raw_name_ptr = raw_name. as_ptr ( ) ;
883877 unsafe {
884878 BNRemoveAutoSection ( self . as_ref ( ) . handle , raw_name_ptr) ;
885879 }
886880 }
887881
888882 fn remove_user_section < S : AsCStr > ( & self , name : S ) {
889883 let raw_name = name. to_cstr ( ) ;
890- let raw_name_ptr = raw_name. as_ref ( ) . as_ptr ( ) as * mut _ ;
884+ let raw_name_ptr = raw_name. as_ptr ( ) ;
891885 unsafe {
892886 BNRemoveUserSection ( self . as_ref ( ) . handle , raw_name_ptr) ;
893887 }
@@ -896,7 +890,7 @@ pub trait BinaryViewExt: BinaryViewBase {
896890 fn section_by_name < S : AsCStr > ( & self , name : S ) -> Option < Ref < Section > > {
897891 unsafe {
898892 let raw_name = name. to_cstr ( ) ;
899- let name_ptr = raw_name. as_ref ( ) . as_ptr ( ) as * mut _ ;
893+ let name_ptr = raw_name. as_ptr ( ) ;
900894 let raw_section_ptr = BNGetSectionByName ( self . as_ref ( ) . handle , name_ptr) ;
901895 match raw_section_ptr. is_null ( ) {
902896 false => Some ( Section :: ref_from_raw ( raw_section_ptr) ) ,
@@ -1112,22 +1106,14 @@ pub trait BinaryViewExt: BinaryViewBase {
11121106 fn show_graph_report < S : AsCStr > ( & self , raw_name : S , graph : & FlowGraph ) {
11131107 let raw_name = raw_name. to_cstr ( ) ;
11141108 unsafe {
1115- BNShowGraphReport (
1116- self . as_ref ( ) . handle ,
1117- raw_name. as_ref ( ) . as_ptr ( ) as * mut _ ,
1118- graph. handle ,
1119- ) ;
1109+ BNShowGraphReport ( self . as_ref ( ) . handle , raw_name. as_ptr ( ) , graph. handle ) ;
11201110 }
11211111 }
11221112
11231113 fn load_settings < S : AsCStr > ( & self , view_type_name : S ) -> Result < Ref < Settings > > {
11241114 let view_type_name = view_type_name. to_cstr ( ) ;
1125- let settings_handle = unsafe {
1126- BNBinaryViewGetLoadSettings (
1127- self . as_ref ( ) . handle ,
1128- view_type_name. as_ref ( ) . as_ptr ( ) as * mut _ ,
1129- )
1130- } ;
1115+ let settings_handle =
1116+ unsafe { BNBinaryViewGetLoadSettings ( self . as_ref ( ) . handle , view_type_name. as_ptr ( ) ) } ;
11311117
11321118 if settings_handle. is_null ( ) {
11331119 Err ( ( ) )
@@ -1142,7 +1128,7 @@ pub trait BinaryViewExt: BinaryViewBase {
11421128 unsafe {
11431129 BNBinaryViewSetLoadSettings (
11441130 self . as_ref ( ) . handle ,
1145- view_type_name. as_ref ( ) . as_ptr ( ) as * mut _ ,
1131+ view_type_name. as_ptr ( ) ,
11461132 settings. handle ,
11471133 )
11481134 } ;
@@ -1170,7 +1156,7 @@ pub trait BinaryViewExt: BinaryViewBase {
11701156 fn tag_type_by_name < S : AsCStr > ( & self , name : S ) -> Option < Ref < TagType > > {
11711157 let name = name. to_cstr ( ) ;
11721158 unsafe {
1173- let handle = BNGetTagType ( self . as_ref ( ) . handle , name. as_ref ( ) . as_ptr ( ) as * mut _ ) ;
1159+ let handle = BNGetTagType ( self . as_ref ( ) . handle , name. as_ptr ( ) ) ;
11741160 if handle. is_null ( ) {
11751161 return None ;
11761162 }
@@ -1184,7 +1170,7 @@ pub trait BinaryViewExt: BinaryViewBase {
11841170 fn tag_by_id < S : AsCStr > ( & self , id : S ) -> Option < Ref < Tag > > {
11851171 let id = id. to_cstr ( ) ;
11861172 unsafe {
1187- let handle = BNGetTag ( self . as_ref ( ) . handle , id. as_ref ( ) . as_ptr ( ) as * mut _ ) ;
1173+ let handle = BNGetTag ( self . as_ref ( ) . handle , id. as_ptr ( ) ) ;
11881174 if handle. is_null ( ) {
11891175 return None ;
11901176 }
@@ -1234,13 +1220,7 @@ pub trait BinaryViewExt: BinaryViewBase {
12341220 /// function use [`Function::set_comment_at`]
12351221 fn set_comment_at ( & self , addr : u64 , comment : impl AsCStr ) {
12361222 let comment_raw = comment. to_cstr ( ) ;
1237- unsafe {
1238- BNSetGlobalCommentForAddress (
1239- self . as_ref ( ) . handle ,
1240- addr,
1241- comment_raw. as_ref ( ) . as_ptr ( ) as * const c_char ,
1242- )
1243- }
1223+ unsafe { BNSetGlobalCommentForAddress ( self . as_ref ( ) . handle , addr, comment_raw. as_ptr ( ) ) }
12441224 }
12451225
12461226 /// Retrieves a list of the next disassembly lines.
@@ -1292,12 +1272,9 @@ pub trait BinaryViewExt: BinaryViewBase {
12921272 }
12931273
12941274 fn query_metadata < S : AsCStr > ( & self , key : S ) -> Option < Ref < Metadata > > {
1295- let value: * mut BNMetadata = unsafe {
1296- BNBinaryViewQueryMetadata (
1297- self . as_ref ( ) . handle ,
1298- key. to_cstr ( ) . as_ref ( ) . as_ptr ( ) as * const c_char ,
1299- )
1300- } ;
1275+ let key = key. to_cstr ( ) ;
1276+ let value: * mut BNMetadata =
1277+ unsafe { BNBinaryViewQueryMetadata ( self . as_ref ( ) . handle , key. as_ptr ( ) ) } ;
13011278 if value. is_null ( ) {
13021279 None
13031280 } else {
@@ -1318,23 +1295,20 @@ pub trait BinaryViewExt: BinaryViewBase {
13181295 V : Into < Ref < Metadata > > ,
13191296 {
13201297 let md = value. into ( ) ;
1298+ let key = key. to_cstr ( ) ;
13211299 unsafe {
13221300 BNBinaryViewStoreMetadata (
13231301 self . as_ref ( ) . handle ,
1324- key. to_cstr ( ) . as_ref ( ) . as_ptr ( ) as * const c_char ,
1302+ key. as_ptr ( ) ,
13251303 md. as_ref ( ) . handle ,
13261304 is_auto,
13271305 )
13281306 } ;
13291307 }
13301308
13311309 fn remove_metadata < S : AsCStr > ( & self , key : S ) {
1332- unsafe {
1333- BNBinaryViewRemoveMetadata (
1334- self . as_ref ( ) . handle ,
1335- key. to_cstr ( ) . as_ref ( ) . as_ptr ( ) as * const c_char ,
1336- )
1337- } ;
1310+ let key = key. to_cstr ( ) ;
1311+ unsafe { BNBinaryViewRemoveMetadata ( self . as_ref ( ) . handle , key. as_ptr ( ) ) } ;
13381312 }
13391313
13401314 /// Retrieves a list of [CodeReference]s pointing to a given address.
@@ -1460,12 +1434,7 @@ pub trait BinaryViewExt: BinaryViewBase {
14601434
14611435 fn component_by_guid < S : AsCStr > ( & self , guid : S ) -> Option < Ref < Component > > {
14621436 let name = guid. to_cstr ( ) ;
1463- let result = unsafe {
1464- BNGetComponentByGuid (
1465- self . as_ref ( ) . handle ,
1466- name. as_ref ( ) . as_ptr ( ) as * const c_char ,
1467- )
1468- } ;
1437+ let result = unsafe { BNGetComponentByGuid ( self . as_ref ( ) . handle , name. as_ptr ( ) ) } ;
14691438 NonNull :: new ( result) . map ( |h| unsafe { Component :: ref_from_raw ( h) } )
14701439 }
14711440
@@ -1476,12 +1445,7 @@ pub trait BinaryViewExt: BinaryViewBase {
14761445
14771446 fn component_by_path < P : AsCStr > ( & self , path : P ) -> Option < Ref < Component > > {
14781447 let path = path. to_cstr ( ) ;
1479- let result = unsafe {
1480- BNGetComponentByPath (
1481- self . as_ref ( ) . handle ,
1482- path. as_ref ( ) . as_ptr ( ) as * const c_char ,
1483- )
1484- } ;
1448+ let result = unsafe { BNGetComponentByPath ( self . as_ref ( ) . handle , path. as_ptr ( ) ) } ;
14851449 NonNull :: new ( result) . map ( |h| unsafe { Component :: ref_from_raw ( h) } )
14861450 }
14871451
@@ -1491,12 +1455,7 @@ pub trait BinaryViewExt: BinaryViewBase {
14911455
14921456 fn remove_component_by_guid < P : AsCStr > ( & self , guid : P ) -> bool {
14931457 let path = guid. to_cstr ( ) ;
1494- unsafe {
1495- BNRemoveComponentByGuid (
1496- self . as_ref ( ) . handle ,
1497- path. as_ref ( ) . as_ptr ( ) as * const c_char ,
1498- )
1499- }
1458+ unsafe { BNRemoveComponentByGuid ( self . as_ref ( ) . handle , path. as_ptr ( ) ) }
15001459 }
15011460
15021461 fn data_variable_parent_components ( & self , data_variable : & DataVariable ) -> Array < Component > {
@@ -1519,24 +1478,15 @@ pub trait BinaryViewExt: BinaryViewBase {
15191478
15201479 fn external_library < S : AsCStr > ( & self , name : S ) -> Option < Ref < ExternalLibrary > > {
15211480 let name_ptr = name. to_cstr ( ) ;
1522- let result = unsafe {
1523- BNBinaryViewGetExternalLibrary (
1524- self . as_ref ( ) . handle ,
1525- name_ptr. as_ref ( ) . as_ptr ( ) as * const c_char ,
1526- )
1527- } ;
1481+ let result =
1482+ unsafe { BNBinaryViewGetExternalLibrary ( self . as_ref ( ) . handle , name_ptr. as_ptr ( ) ) } ;
15281483 let result_ptr = NonNull :: new ( result) ?;
15291484 Some ( unsafe { ExternalLibrary :: ref_from_raw ( result_ptr) } )
15301485 }
15311486
15321487 fn remove_external_library < S : AsCStr > ( & self , name : S ) {
15331488 let name_ptr = name. to_cstr ( ) ;
1534- unsafe {
1535- BNBinaryViewRemoveExternalLibrary (
1536- self . as_ref ( ) . handle ,
1537- name_ptr. as_ref ( ) . as_ptr ( ) as * const c_char ,
1538- )
1539- } ;
1489+ unsafe { BNBinaryViewRemoveExternalLibrary ( self . as_ref ( ) . handle , name_ptr. as_ptr ( ) ) } ;
15401490 }
15411491
15421492 fn add_external_library < S : AsCStr > (
@@ -1549,7 +1499,7 @@ pub trait BinaryViewExt: BinaryViewBase {
15491499 let result = unsafe {
15501500 BNBinaryViewAddExternalLibrary (
15511501 self . as_ref ( ) . handle ,
1552- name_ptr. as_ref ( ) . as_ptr ( ) as * const c_char ,
1502+ name_ptr. as_ptr ( ) ,
15531503 backing_file
15541504 . map ( |b| b. handle . as_ptr ( ) )
15551505 . unwrap_or ( std:: ptr:: null_mut ( ) ) ,
@@ -1598,7 +1548,7 @@ pub trait BinaryViewExt: BinaryViewBase {
15981548 self . as_ref ( ) . handle ,
15991549 symbol. handle ,
16001550 library. handle . as_ptr ( ) ,
1601- target_symbol_name. as_ref ( ) . as_ptr ( ) as * const c_char ,
1551+ target_symbol_name. as_ptr ( ) ,
16021552 target_address_ptr,
16031553 target_is_auto,
16041554 )
@@ -1641,12 +1591,7 @@ pub trait BinaryViewExt: BinaryViewBase {
16411591
16421592 fn type_library_by_name < S : AsCStr > ( & self , name : S ) -> Option < TypeLibrary > {
16431593 let name = name. to_cstr ( ) ;
1644- let result = unsafe {
1645- BNGetBinaryViewTypeLibrary (
1646- self . as_ref ( ) . handle ,
1647- name. as_ref ( ) . as_ptr ( ) as * const c_char ,
1648- )
1649- } ;
1594+ let result = unsafe { BNGetBinaryViewTypeLibrary ( self . as_ref ( ) . handle , name. as_ptr ( ) ) } ;
16501595 NonNull :: new ( result) . map ( |h| unsafe { TypeLibrary :: from_raw ( h) } )
16511596 }
16521597
@@ -1739,12 +1684,8 @@ pub trait BinaryViewExt: BinaryViewBase {
17391684 /// Dict[string_guid, Tuple[string_type_name, type_library_name]]
17401685 fn import_type_by_guid < S : AsCStr > ( & self , guid : S ) -> Option < Ref < Type > > {
17411686 let guid = guid. to_cstr ( ) ;
1742- let result = unsafe {
1743- BNBinaryViewImportTypeLibraryTypeByGuid (
1744- self . as_ref ( ) . handle ,
1745- guid. as_ref ( ) . as_ptr ( ) as * const c_char ,
1746- )
1747- } ;
1687+ let result =
1688+ unsafe { BNBinaryViewImportTypeLibraryTypeByGuid ( self . as_ref ( ) . handle , guid. as_ptr ( ) ) } ;
17481689 ( !result. is_null ( ) ) . then ( || unsafe { Type :: ref_from_raw ( result) } )
17491690 }
17501691
0 commit comments