ole32: COM cleanup for the IEnumSTATSTG iface.

This commit is contained in:
Michael Stefaniuc 2011-01-04 01:58:16 +01:00 committed by Alexandre Julliard
parent 40bf2f0ece
commit 4ff5c02098

View File

@ -296,8 +296,7 @@ extern const IPropertySetStorageVtbl IPropertySetStorage_Vtbl;
*/ */
struct IEnumSTATSTGImpl struct IEnumSTATSTGImpl
{ {
const IEnumSTATSTGVtbl *lpVtbl; /* Needs to be the first item in the struct IEnumSTATSTG IEnumSTATSTG_iface;
* since we want to cast this in an IEnumSTATSTG pointer */
LONG ref; /* Reference count */ LONG ref; /* Reference count */
StorageBaseImpl* parentStorage; /* Reference to the parent storage */ StorageBaseImpl* parentStorage; /* Reference to the parent storage */
@ -306,6 +305,11 @@ struct IEnumSTATSTGImpl
WCHAR name[DIRENTRY_NAME_MAX_LEN]; /* The most recent name visited */ WCHAR name[DIRENTRY_NAME_MAX_LEN]; /* The most recent name visited */
}; };
static inline IEnumSTATSTGImpl *impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
{
return CONTAINING_RECORD(iface, IEnumSTATSTGImpl, IEnumSTATSTG_iface);
}
static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(StorageBaseImpl* This, DirRef storageDirEntry); static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(StorageBaseImpl* This, DirRef storageDirEntry);
static void IEnumSTATSTGImpl_Destroy(IEnumSTATSTGImpl* This); static void IEnumSTATSTGImpl_Destroy(IEnumSTATSTGImpl* This);
@ -711,7 +715,7 @@ static HRESULT WINAPI StorageBaseImpl_EnumElements(
if (newEnum!=0) if (newEnum!=0)
{ {
*ppenum = (IEnumSTATSTG*)newEnum; *ppenum = &newEnum->IEnumSTATSTG_iface;
IEnumSTATSTG_AddRef(*ppenum); IEnumSTATSTG_AddRef(*ppenum);
@ -5292,7 +5296,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
REFIID riid, REFIID riid,
void** ppvObject) void** ppvObject)
{ {
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
if (ppvObject==0) if (ppvObject==0)
return E_INVALIDARG; return E_INVALIDARG;
@ -5303,7 +5307,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
IsEqualGUID(&IID_IEnumSTATSTG, riid)) IsEqualGUID(&IID_IEnumSTATSTG, riid))
{ {
*ppvObject = This; *ppvObject = This;
IEnumSTATSTG_AddRef((IEnumSTATSTG*)This); IEnumSTATSTG_AddRef(&This->IEnumSTATSTG_iface);
return S_OK; return S_OK;
} }
@ -5313,14 +5317,14 @@ static HRESULT WINAPI IEnumSTATSTGImpl_QueryInterface(
static ULONG WINAPI IEnumSTATSTGImpl_AddRef( static ULONG WINAPI IEnumSTATSTGImpl_AddRef(
IEnumSTATSTG* iface) IEnumSTATSTG* iface)
{ {
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI IEnumSTATSTGImpl_Release( static ULONG WINAPI IEnumSTATSTGImpl_Release(
IEnumSTATSTG* iface) IEnumSTATSTG* iface)
{ {
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
ULONG newRef; ULONG newRef;
@ -5385,7 +5389,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Next(
STATSTG* rgelt, STATSTG* rgelt,
ULONG* pceltFetched) ULONG* pceltFetched)
{ {
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
DirEntry currentEntry; DirEntry currentEntry;
STATSTG* currentReturnStruct = rgelt; STATSTG* currentReturnStruct = rgelt;
@ -5452,9 +5456,9 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Skip(
IEnumSTATSTG* iface, IEnumSTATSTG* iface,
ULONG celt) ULONG celt)
{ {
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
ULONG objectFetched = 0; ULONG objectFetched = 0;
DirRef currentSearchNode; DirRef currentSearchNode;
HRESULT hr=S_OK; HRESULT hr=S_OK;
@ -5480,7 +5484,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Skip(
static HRESULT WINAPI IEnumSTATSTGImpl_Reset( static HRESULT WINAPI IEnumSTATSTGImpl_Reset(
IEnumSTATSTG* iface) IEnumSTATSTG* iface)
{ {
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
if (This->parentStorage->reverted) if (This->parentStorage->reverted)
return STG_E_REVERTED; return STG_E_REVERTED;
@ -5494,7 +5498,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Clone(
IEnumSTATSTG* iface, IEnumSTATSTG* iface,
IEnumSTATSTG** ppenum) IEnumSTATSTG** ppenum)
{ {
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface);
IEnumSTATSTGImpl* newClone; IEnumSTATSTGImpl* newClone;
@ -5517,7 +5521,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Clone(
*/ */
memcpy(newClone->name, This->name, sizeof(newClone->name)); memcpy(newClone->name, This->name, sizeof(newClone->name));
*ppenum = (IEnumSTATSTG*)newClone; *ppenum = &newClone->IEnumSTATSTG_iface;
/* /*
* Don't forget to nail down a reference to the clone before * Don't forget to nail down a reference to the clone before
@ -5559,7 +5563,7 @@ static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(
/* /*
* Set-up the virtual function table and reference count. * Set-up the virtual function table and reference count.
*/ */
newEnumeration->lpVtbl = &IEnumSTATSTGImpl_Vtbl; newEnumeration->IEnumSTATSTG_iface.lpVtbl = &IEnumSTATSTGImpl_Vtbl;
newEnumeration->ref = 0; newEnumeration->ref = 0;
/* /*
@ -5574,7 +5578,7 @@ static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct(
/* /*
* Make sure the current node of the iterator is the first one. * Make sure the current node of the iterator is the first one.
*/ */
IEnumSTATSTGImpl_Reset((IEnumSTATSTG*)newEnumeration); IEnumSTATSTGImpl_Reset(&newEnumeration->IEnumSTATSTG_iface);
} }
return newEnumeration; return newEnumeration;