ext/pf2/src/session/ruby_object.rs in pf2-0.5.1 vs ext/pf2/src/session/ruby_object.rs in pf2-0.5.2
- old
+ new
@@ -1,9 +1,9 @@
use std::ffi::{c_int, c_void};
use std::mem;
use std::mem::ManuallyDrop;
-use std::ptr::null_mut;
+use std::ptr::{addr_of, null_mut};
use rb_sys::*;
use crate::util::cstr;
@@ -41,11 +41,11 @@
}
// Extract the SessionRubyObject struct from a Ruby object
unsafe fn get_struct_from(obj: VALUE) -> ManuallyDrop<Box<Self>> {
unsafe {
- let ptr = rb_check_typeddata(obj, &RBDATA);
+ let ptr = rb_check_typeddata(obj, addr_of!(RBDATA));
ManuallyDrop::new(Box::from_raw(ptr as *mut SessionRubyObject))
}
}
#[allow(non_snake_case)]
@@ -53,10 +53,14 @@
let obj = Box::new(SessionRubyObject { session: None });
let rb_mPf2: VALUE = rb_define_module(cstr!("Pf2"));
let rb_cSession = rb_define_class_under(rb_mPf2, cstr!("Session"), rb_cObject);
// Wrap the struct into a Ruby object
- rb_data_typed_object_wrap(rb_cSession, Box::into_raw(obj) as *mut c_void, &RBDATA)
+ rb_data_typed_object_wrap(
+ rb_cSession,
+ Box::into_raw(obj) as *mut c_void,
+ addr_of!(RBDATA),
+ )
}
unsafe extern "C" fn dmark(ptr: *mut c_void) {
let obj = ManuallyDrop::new(Box::from_raw(ptr as *mut SessionRubyObject));
if let Some(session) = &obj.session {