Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

cli: fix pointer issue

+16 -1
+16 -1
crates/cli/src/lib.rs
··· 2 2 use owo_colors::OwoColorize; 3 3 use std::ffi::CStr; 4 4 5 + #[macro_export] 6 + macro_rules! cast_ptr { 7 + ($ptr:expr) => {{ 8 + #[cfg(target_arch = "aarch64")] 9 + { 10 + $ptr as *const u8 11 + } 12 + 13 + #[cfg(not(target_arch = "aarch64"))] 14 + { 15 + $ptr as *const i8 16 + } 17 + }}; 18 + } 19 + 5 20 #[no_mangle] 6 21 pub extern "C" fn parse_args(argc: usize, argv: *const *const u8) -> i32 { 7 22 let string_array = unsafe { std::slice::from_raw_parts(argv, argc) }; 8 23 let args: Vec<&str> = string_array 9 24 .iter() 10 25 .map(|&ptr| { 11 - let c_str = unsafe { CStr::from_ptr(ptr as *const i8) }; 26 + let c_str = unsafe { CStr::from_ptr(cast_ptr!(ptr)) }; 12 27 c_str 13 28 .to_str() 14 29 .unwrap_or("[Invalid UTF-8 or Non Null-Terminated String]")