Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Jan 6, 2025
1 parent 986d722 commit 18c0de5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ unsafe impl Send for crate::gameboy::Gameboy {}
#[cfg(target_vendor = "apple")]
unsafe impl Sync for crate::gameboy::Gameboy {}

/// # Safety
///
/// This function is not safe due to from_raw_parts.
#[no_mangle]
pub extern "C" fn load_rom(bytes: *const std::ffi::c_uchar, bytes_length: usize) {
let bytes = unsafe { std::slice::from_raw_parts(bytes, bytes_length) };
pub unsafe extern "C" fn load_rom(bytes: *const std::ffi::c_uchar, bytes_length: usize) {
let bytes = std::slice::from_raw_parts(bytes, bytes_length);
let bytes: Vec<u8> = Vec::from(bytes);
GAMEBOY
.get_or_init(|| Some(crate::gameboy::Gameboy::new(bytes.to_vec(), None)).into());
Expand Down

0 comments on commit 18c0de5

Please sign in to comment.