File tree Expand file tree Collapse file tree 1 file changed +1
-21
lines changed
Expand file tree Collapse file tree 1 file changed +1
-21
lines changed Original file line number Diff line number Diff line change @@ -12,33 +12,13 @@ use std::time::Duration;
1212use std:: { env, ffi:: CStr } ;
1313use std:: { fs, thread} ;
1414
15- #[ macro_export]
16- macro_rules! cast_ptr {
17- ( $ptr: expr) => { {
18- #[ cfg( all( target_arch = "aarch64" , target_os = "macos" ) ) ]
19- {
20- $ptr as * const i8
21- }
22-
23- #[ cfg( all( target_arch = "aarch64" , target_os = "linux" ) ) ]
24- {
25- $ptr as * const u8
26- }
27-
28- #[ cfg( not( target_arch = "aarch64" ) ) ]
29- {
30- $ptr as * const i8
31- }
32- } } ;
33- }
34-
3515#[ no_mangle]
3616pub extern "C" fn parse_args ( argc : usize , argv : * const * const u8 ) -> i32 {
3717 let string_array = unsafe { std:: slice:: from_raw_parts ( argv, argc) } ;
3818 let args: Vec < & str > = string_array
3919 . iter ( )
4020 . map ( |& ptr| {
41- let c_str = unsafe { CStr :: from_ptr ( cast_ptr ! ( ptr) ) } ;
21+ let c_str = unsafe { CStr :: from_ptr ( ptr as * const std :: ffi :: c_char ) } ;
4222 c_str
4323 . to_str ( )
4424 . unwrap_or ( "[Invalid UTF-8 or Non Null-Terminated String]" )
You can’t perform that action at this time.
0 commit comments