diff --git a/dlls/shlwapi/thread.c b/dlls/shlwapi/thread.c index 00d26f78eb7..c18d5a4cbee 100644 --- a/dlls/shlwapi/thread.c +++ b/dlls/shlwapi/thread.c @@ -122,13 +122,18 @@ typedef struct tagSHLWAPI_THREAD_INFO typedef struct { - const IUnknownVtbl* lpVtbl; + IUnknown IUnknown_iface; LONG *ref; } threadref; +static inline threadref *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, threadref, IUnknown_iface); +} + static HRESULT WINAPI threadref_QueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj) { - threadref * This = (threadref *)iface; + threadref * This = impl_from_IUnknown(iface); TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObj); @@ -149,7 +154,7 @@ static HRESULT WINAPI threadref_QueryInterface(IUnknown *iface, REFIID riid, LPV static ULONG WINAPI threadref_AddRef(IUnknown *iface) { - threadref * This = (threadref *)iface; + threadref * This = impl_from_IUnknown(iface); TRACE("(%p)\n", This); return InterlockedIncrement(This->ref); @@ -158,7 +163,7 @@ static ULONG WINAPI threadref_AddRef(IUnknown *iface) static ULONG WINAPI threadref_Release(IUnknown *iface) { LONG refcount; - threadref * This = (threadref *)iface; + threadref * This = impl_from_IUnknown(iface); TRACE("(%p)\n", This); @@ -199,11 +204,11 @@ HRESULT WINAPI SHCreateThreadRef(LONG *lprefcount, IUnknown **lppUnknown) return E_INVALIDARG; This = HeapAlloc(GetProcessHeap(), 0, sizeof(threadref)); - This->lpVtbl = &threadref_vt; + This->IUnknown_iface.lpVtbl = &threadref_vt; This->ref = lprefcount; *lprefcount = 1; - *lppUnknown = (IUnknown *) This; + *lppUnknown = &This->IUnknown_iface; TRACE("=> returning S_OK with %p\n", This); return S_OK; }