diff --git a/crates/libs/core/src/com_object.rs b/crates/libs/core/src/com_object.rs index 36da08ae53..c26d64c727 100644 --- a/crates/libs/core/src/com_object.rs +++ b/crates/libs/core/src/com_object.rs @@ -74,7 +74,7 @@ impl ComObject { /// Gets a reference to the shared object's heap box. #[inline(always)] - pub fn get_box(&self) -> &T::Outer { + fn get_box(&self) -> &T::Outer { unsafe { self.ptr.as_ref() } } @@ -98,12 +98,6 @@ impl ComObject { } } - /// Returns `true` if this reference is the only reference to the `ComObject`. - #[inline(always)] - pub fn is_exclusive_reference(&self) -> bool { - self.get_box().is_reference_count_one() - } - /// If this object has only a single object reference (i.e. this [`ComObject`] is the only /// reference to the heap allocation), then this method will extract the inner `T` /// (and return it in an `Ok`) and then free the heap allocation. @@ -111,7 +105,7 @@ impl ComObject { /// If there is more than one reference to this object, then this returns `Err(self)`. #[inline(always)] pub fn take(self) -> Result { - if self.is_exclusive_reference() { + if self.is_reference_count_one() { let outer_box: Box = unsafe { core::mem::transmute(self) }; Ok(outer_box.into_inner()) } else { diff --git a/crates/libs/core/src/unknown.rs b/crates/libs/core/src/unknown.rs index d8029e33ef..8817b57f8d 100644 --- a/crates/libs/core/src/unknown.rs +++ b/crates/libs/core/src/unknown.rs @@ -102,8 +102,6 @@ pub trait IUnknownImpl { /// Taking `&self` would violate Rust's rules on reference lifetime. unsafe fn Release(self_: *mut Self) -> u32; - unsafe fn destroy(self_: *mut Self); - /// Returns `true` if the reference count of the box is equal to 1. fn is_reference_count_one(&self) -> bool; diff --git a/crates/libs/implement/src/lib.rs b/crates/libs/implement/src/lib.rs index e1ae3b09c4..3f6ec0c102 100644 --- a/crates/libs/implement/src/lib.rs +++ b/crates/libs/implement/src/lib.rs @@ -221,16 +221,11 @@ pub fn implement(attributes: proc_macro::TokenStream, original_type: proc_macro: unsafe fn Release(self_: *mut Self) -> u32 { let remaining = (*self_).count.release(); if remaining == 0 { - Self::destroy(self_); + _ = ::windows_core::imp::Box::from_raw(self_ as *const Self as *mut Self); } remaining } - #[inline(never)] - unsafe fn destroy(self_: *mut Self) { - _ = ::windows_core::imp::Box::from_raw(self_ as *const Self as *mut Self); - } - unsafe fn GetTrustLevel(&self, value: *mut i32) -> ::windows_core::HRESULT { if value.is_null() { return ::windows_core::imp::E_POINTER;