Michael Stefaniuc : qmgr: COM cleanup for the IEnumBackgroundCopyFiles iface.
Alexandre Julliard
julliard at winehq.org
Thu Dec 6 16:25:09 CST 2012
Module: wine
Branch: master
Commit: 49e6d411b07c922a0324026c05bc03e4ad6c80f4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=49e6d411b07c922a0324026c05bc03e4ad6c80f4
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Wed Dec 5 23:53:15 2012 +0100
qmgr: COM cleanup for the IEnumBackgroundCopyFiles iface.
---
dlls/qmgr/enum_files.c | 84 +++++++++++++++++++++++++-----------------------
dlls/qmgr/qmgr.h | 10 ------
2 files changed, 44 insertions(+), 50 deletions(-)
diff --git a/dlls/qmgr/enum_files.c b/dlls/qmgr/enum_files.c
index d7f36cd..05659cf 100644
--- a/dlls/qmgr/enum_files.c
+++ b/dlls/qmgr/enum_files.c
@@ -23,6 +23,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
+typedef struct
+{
+ IEnumBackgroundCopyFiles IEnumBackgroundCopyFiles_iface;
+ LONG ref;
+ IBackgroundCopyFile **files;
+ ULONG numFiles;
+ ULONG indexFiles;
+} EnumBackgroundCopyFilesImpl;
+
static void EnumBackgroundCopyFilesDestructor(EnumBackgroundCopyFilesImpl *This)
{
ULONG i;
@@ -34,37 +43,39 @@ static void EnumBackgroundCopyFilesDestructor(EnumBackgroundCopyFilesImpl *This)
HeapFree(GetProcessHeap(), 0, This);
}
-static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_AddRef(
- IEnumBackgroundCopyFiles* iface)
+static inline EnumBackgroundCopyFilesImpl *impl_from_IEnumBackgroundCopyFiles(IEnumBackgroundCopyFiles *iface)
{
- EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
- return InterlockedIncrement(&This->ref);
+ return CONTAINING_RECORD(iface, EnumBackgroundCopyFilesImpl, IEnumBackgroundCopyFiles_iface);
}
-static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_QueryInterface(
- IEnumBackgroundCopyFiles* iface,
- REFIID riid,
- void **ppvObject)
+static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_QueryInterface(IEnumBackgroundCopyFiles *iface,
+ REFIID riid, void **ppv)
{
- EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
- TRACE("IID: %s\n", debugstr_guid(riid));
+ TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppv);
- if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IEnumBackgroundCopyFiles))
+ if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumBackgroundCopyFiles))
{
- *ppvObject = &This->lpVtbl;
- BITS_IEnumBackgroundCopyFiles_AddRef(iface);
+ *ppv = iface;
+ IEnumBackgroundCopyFiles_AddRef(iface);
return S_OK;
}
- *ppvObject = NULL;
+ *ppv = NULL;
return E_NOINTERFACE;
}
-static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(
- IEnumBackgroundCopyFiles* iface)
+static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_AddRef(IEnumBackgroundCopyFiles *iface)
+{
+ EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) ref=%d\n", This, ref);
+ return ref;
+}
+
+static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(IEnumBackgroundCopyFiles *iface)
{
- EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
+ EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
@@ -74,13 +85,10 @@ static ULONG WINAPI BITS_IEnumBackgroundCopyFiles_Release(
}
/* Return reference to one or more files in the file enumerator */
-static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(
- IEnumBackgroundCopyFiles* iface,
- ULONG celt,
- IBackgroundCopyFile **rgelt,
- ULONG *pceltFetched)
+static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(IEnumBackgroundCopyFiles *iface,
+ ULONG celt, IBackgroundCopyFile **rgelt, ULONG *pceltFetched)
{
- EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
+ EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
ULONG fetched;
ULONG i;
IBackgroundCopyFile *file;
@@ -115,11 +123,10 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Next(
}
/* Skip over one or more files in the file enumerator */
-static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(
- IEnumBackgroundCopyFiles* iface,
- ULONG celt)
+static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(IEnumBackgroundCopyFiles *iface,
+ ULONG celt)
{
- EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
+ EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
if (celt > This->numFiles - This->indexFiles)
{
@@ -131,27 +138,24 @@ static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Skip(
return S_OK;
}
-static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Reset(
- IEnumBackgroundCopyFiles* iface)
+static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Reset(IEnumBackgroundCopyFiles *iface)
{
- EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
+ EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
This->indexFiles = 0;
return S_OK;
}
-static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Clone(
- IEnumBackgroundCopyFiles* iface,
- IEnumBackgroundCopyFiles **ppenum)
+static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_Clone(IEnumBackgroundCopyFiles *iface,
+ IEnumBackgroundCopyFiles **ppenum)
{
FIXME("Not implemented\n");
return E_NOTIMPL;
}
-static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_GetCount(
- IEnumBackgroundCopyFiles* iface,
- ULONG *puCount)
+static HRESULT WINAPI BITS_IEnumBackgroundCopyFiles_GetCount(IEnumBackgroundCopyFiles *iface,
+ ULONG *puCount)
{
- EnumBackgroundCopyFilesImpl *This = (EnumBackgroundCopyFilesImpl *) iface;
+ EnumBackgroundCopyFilesImpl *This = impl_from_IEnumBackgroundCopyFiles(iface);
*puCount = This->numFiles;
return S_OK;
}
@@ -181,7 +185,7 @@ HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, IBackgroundCopyJob2 *i
if (!This)
return E_OUTOFMEMORY;
- This->lpVtbl = &BITS_IEnumBackgroundCopyFiles_Vtbl;
+ This->IEnumBackgroundCopyFiles_iface.lpVtbl = &BITS_IEnumBackgroundCopyFiles_Vtbl;
This->ref = 1;
/* Create array of files */
@@ -210,6 +214,6 @@ HRESULT EnumBackgroundCopyFilesConstructor(LPVOID *ppObj, IBackgroundCopyJob2 *i
}
LeaveCriticalSection(&job->cs);
- *ppObj = &This->lpVtbl;
+ *ppObj = &This->IEnumBackgroundCopyFiles_iface;
return S_OK;
}
diff --git a/dlls/qmgr/qmgr.h b/dlls/qmgr/qmgr.h
index 4bd1e34..93fcd0e 100644
--- a/dlls/qmgr/qmgr.h
+++ b/dlls/qmgr/qmgr.h
@@ -46,16 +46,6 @@ typedef struct
struct list entryFromQmgr;
} BackgroundCopyJobImpl;
-/* Enum background copy files vtbl and related data */
-typedef struct
-{
- const IEnumBackgroundCopyFilesVtbl *lpVtbl;
- LONG ref;
- IBackgroundCopyFile **files;
- ULONG numFiles;
- ULONG indexFiles;
-} EnumBackgroundCopyFilesImpl;
-
/* Background copy file vtbl and related data */
typedef struct
{
More information about the wine-cvs
mailing list