avifil32: Use an iface instead of an vtbl pointer in IClassFactoryImpl.

This commit is contained in:
Michael Stefaniuc 2010-12-04 22:12:18 +01:00 committed by Alexandre Julliard
parent a92531487b
commit b8ef455d49
1 changed files with 11 additions and 6 deletions

View File

@ -57,12 +57,17 @@ static const IClassFactoryVtbl iclassfact = {
typedef struct typedef struct
{ {
/* IUnknown fields */ /* IUnknown fields */
const IClassFactoryVtbl *lpVtbl; IClassFactory IClassFactory_iface;
DWORD dwRef; DWORD dwRef;
CLSID clsid; CLSID clsid;
} IClassFactoryImpl; } IClassFactoryImpl;
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
}
static HRESULT AVIFILE_CreateClassFactory(const CLSID *pclsid, const IID *riid, static HRESULT AVIFILE_CreateClassFactory(const CLSID *pclsid, const IID *riid,
LPVOID *ppv) LPVOID *ppv)
{ {
@ -75,11 +80,11 @@ static HRESULT AVIFILE_CreateClassFactory(const CLSID *pclsid, const IID *riid,
if (pClassFactory == NULL) if (pClassFactory == NULL)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
pClassFactory->lpVtbl = &iclassfact; pClassFactory->IClassFactory_iface.lpVtbl = &iclassfact;
pClassFactory->dwRef = 0; pClassFactory->dwRef = 0;
pClassFactory->clsid = *pclsid; pClassFactory->clsid = *pclsid;
hr = IClassFactory_QueryInterface((IClassFactory*)pClassFactory, riid, ppv); hr = IClassFactory_QueryInterface(&pClassFactory->IClassFactory_iface, riid, ppv);
if (FAILED(hr)) { if (FAILED(hr)) {
HeapFree(GetProcessHeap(), 0, pClassFactory); HeapFree(GetProcessHeap(), 0, pClassFactory);
*ppv = NULL; *ppv = NULL;
@ -105,7 +110,7 @@ static HRESULT WINAPI IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,
static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface) static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
{ {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p)\n", iface); TRACE("(%p)\n", iface);
@ -114,7 +119,7 @@ static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface) static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
{ {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p)\n", iface); TRACE("(%p)\n", iface);
if ((--(This->dwRef)) > 0) if ((--(This->dwRef)) > 0)
@ -129,7 +134,7 @@ static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,
LPUNKNOWN pOuter, LPUNKNOWN pOuter,
REFIID riid,LPVOID *ppobj) REFIID riid,LPVOID *ppobj)
{ {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = impl_from_IClassFactory(iface);
TRACE("(%p,%p,%s,%p)\n", iface, pOuter, debugstr_guid(riid), TRACE("(%p,%p,%s,%p)\n", iface, pOuter, debugstr_guid(riid),
ppobj); ppobj);