Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropped IWbemClassWrapper scenario #99

Open
theKidOfArcrania opened this issue Aug 27, 2024 · 1 comment
Open

Dropped IWbemClassWrapper scenario #99

theKidOfArcrania opened this issue Aug 27, 2024 · 1 comment

Comments

@theKidOfArcrania
Copy link

theKidOfArcrania commented Aug 27, 2024

The comments for IWbemClassWrapper mentions something about it taking care of releasing the object when dropped. Can you elaborate on this if this is true? I don't see anywhere where this suggest that this code releases any resources when this object is dropped.

Specific comments:

/// A wrapper around a raw pointer to IWbemClassObject, which also takes care of releasing
/// the object when dropped.
@ohadravid
Copy link
Owner

Hi @theKidOfArcrania ,

It's a good question: It used be clearer in perv. versions of this struct.

Currently, IWbemClassWrapper is a wrapper around windows::Win32::System::Wmi::IWbemClassObject, which is defined like this:

#[repr(transparent)]
#[derive(...)]
pub struct IWbemClassObject(::windows_core::IUnknown);

And IUnknown, as documented here, has a drop impl which calls Release:

impl Drop for IUnknown {
    fn drop(&mut self) {
        unsafe {
            (self.vtable().Release)(std::mem::transmute_copy(self));
        }
    }
}

So at least AFIK, everything should be released as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants