diff --git a/frontends/libretro/src/lib.rs b/frontends/libretro/src/lib.rs index 408b95e477b597e24f87224db5557777e422c48e..1b1336300154307c49e94d1402f9defae55bf0ff 100644 --- a/frontends/libretro/src/lib.rs +++ b/frontends/libretro/src/lib.rs @@ -365,14 +365,17 @@ pub extern "C" fn retro_cheat_reset() { emulator.reset_cheats(); } +/// # Safety +/// +/// This function should not be called only within Lib Retro context. #[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()"); if !enabled { return; } - let emulator = unsafe { EMULATOR.as_mut().unwrap() }; - let code_c = unsafe { CStr::from_ptr(code) }; + let emulator = EMULATOR.as_mut().unwrap(); + let code_c = CStr::from_ptr(code); let code_s = code_c.to_string_lossy().into_owned(); emulator.add_cheat_code(&code_s).unwrap(); }