Skip to content
Snippets Groups Projects
Verified Commit ea4e5c30 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

fix: clippy unsafe issue

parent 1e7da8a4
No related branches found
No related tags found
No related merge requests found
Pipeline #3158 passed
...@@ -365,14 +365,17 @@ pub extern "C" fn retro_cheat_reset() { ...@@ -365,14 +365,17 @@ pub extern "C" fn retro_cheat_reset() {
emulator.reset_cheats(); emulator.reset_cheats();
} }
/// # Safety
///
/// This function should not be called only within Lib Retro context.
#[no_mangle] #[no_mangle]
pub extern "C" fn retro_cheat_set(_index: c_uint, enabled: bool, code: *const c_char) { pub unsafe extern "C" fn retro_cheat_set(_index: c_uint, enabled: bool, code: *const c_char) {
debugln!("retro_cheat_set()"); debugln!("retro_cheat_set()");
if !enabled { if !enabled {
return; return;
} }
let emulator = unsafe { EMULATOR.as_mut().unwrap() }; let emulator = EMULATOR.as_mut().unwrap();
let code_c = unsafe { CStr::from_ptr(code) }; let code_c = CStr::from_ptr(code);
let code_s = code_c.to_string_lossy().into_owned(); let code_s = code_c.to_string_lossy().into_owned();
emulator.add_cheat_code(&code_s).unwrap(); emulator.add_cheat_code(&code_s).unwrap();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment