Skip to content

Commit

Permalink
FiX alignment checks
Browse files Browse the repository at this point in the history
rust-lang/rust#98112
alignment checks for pointer dereferences when debug assertions are enabled, so use std::mem::transmute instead
  • Loading branch information
tsailin-bit committed Mar 4, 2024
1 parent b66cb9e commit 0897e5f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rsbinder/src/binder_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ impl From<&SIBinder> for flat_binder_object {

impl From<(*const u8, usize)> for &flat_binder_object {
fn from(pointer: (*const u8, usize)) -> Self {
unsafe { & *(pointer.0.add(pointer.1) as *const flat_binder_object) }
unsafe { std::mem::transmute::<*const u8, &flat_binder_object>(&*(pointer.0.add(pointer.1))) }
}
}

impl From<(*mut u8, usize)> for &mut flat_binder_object {
fn from(pointer: (*mut u8, usize)) -> Self {
unsafe { &mut *(pointer.0.add(pointer.1) as *mut flat_binder_object) }
unsafe { std::mem::transmute::<*const u8, &mut flat_binder_object>(&*(pointer.0.add(pointer.1))) }
}
}

Expand Down

0 comments on commit 0897e5f

Please sign in to comment.