shell32: COM cleanup for IEnumIDList.

This commit is contained in:
Michael Stefaniuc 2014-03-25 23:40:52 +01:00 committed by Alexandre Julliard
parent 0aff99771d
commit c13e106e73
1 changed files with 25 additions and 24 deletions

View File

@ -170,9 +170,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
#if !defined(__MINGW32__) && !defined(_MSC_VER) #if !defined(__MINGW32__) && !defined(_MSC_VER)
#define ADJUST_THIS(c,m,p) ((c*)(((long)p)-(long)&(((c*)0)->lp##m##Vtbl)))
#define STATIC_CAST(i,p) ((i*)&p->lp##i##Vtbl)
#define LEN_SHITEMID_FIXED_PART ((USHORT) \ #define LEN_SHITEMID_FIXED_PART ((USHORT) \
( sizeof(USHORT) /* SHITEMID's cb field. */ \ ( sizeof(USHORT) /* SHITEMID's cb field. */ \
+ sizeof(PIDLTYPE) /* PIDLDATA's type field. */ \ + sizeof(PIDLTYPE) /* PIDLDATA's type field. */ \
@ -2368,13 +2365,18 @@ HRESULT WINAPI MyDocuments_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID
/* UnixSubFolderIterator object layout and typedef. /* UnixSubFolderIterator object layout and typedef.
*/ */
typedef struct _UnixSubFolderIterator { typedef struct _UnixSubFolderIterator {
const IEnumIDListVtbl *lpIEnumIDListVtbl; IEnumIDList IEnumIDList_iface;
LONG m_cRef; LONG ref;
SHCONTF m_fFilter; SHCONTF m_fFilter;
DIR *m_dirFolder; DIR *m_dirFolder;
char m_szFolder[FILENAME_MAX]; char m_szFolder[FILENAME_MAX];
} UnixSubFolderIterator; } UnixSubFolderIterator;
static inline UnixSubFolderIterator *impl_from_IEnumIDList(IEnumIDList *iface)
{
return CONTAINING_RECORD(iface, UnixSubFolderIterator, IEnumIDList_iface);
}
static void UnixSubFolderIterator_Destroy(UnixSubFolderIterator *iterator) { static void UnixSubFolderIterator_Destroy(UnixSubFolderIterator *iterator) {
TRACE("(iterator=%p)\n", iterator); TRACE("(iterator=%p)\n", iterator);
@ -2400,35 +2402,34 @@ static HRESULT WINAPI UnixSubFolderIterator_IEnumIDList_QueryInterface(IEnumIDLi
IEnumIDList_AddRef(iface); IEnumIDList_AddRef(iface);
return S_OK; return S_OK;
} }
static ULONG WINAPI UnixSubFolderIterator_IEnumIDList_AddRef(IEnumIDList* iface) static ULONG WINAPI UnixSubFolderIterator_IEnumIDList_AddRef(IEnumIDList* iface)
{ {
UnixSubFolderIterator *This = ADJUST_THIS(UnixSubFolderIterator, IEnumIDList, iface); UnixSubFolderIterator *This = impl_from_IEnumIDList(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(iface=%p)\n", iface); TRACE("(%p) ref=%d\n", This, ref);
return InterlockedIncrement(&This->m_cRef); return ref;
} }
static ULONG WINAPI UnixSubFolderIterator_IEnumIDList_Release(IEnumIDList* iface) static ULONG WINAPI UnixSubFolderIterator_IEnumIDList_Release(IEnumIDList* iface)
{ {
UnixSubFolderIterator *This = ADJUST_THIS(UnixSubFolderIterator, IEnumIDList, iface); UnixSubFolderIterator *This = impl_from_IEnumIDList(iface);
ULONG cRef; ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(iface=%p)\n", iface);
cRef = InterlockedDecrement(&This->m_cRef); TRACE("(%p) ref=%d\n", This, ref);
if (!cRef) if (!ref)
UnixSubFolderIterator_Destroy(This); UnixSubFolderIterator_Destroy(This);
return cRef; return ref;
} }
static HRESULT WINAPI UnixSubFolderIterator_IEnumIDList_Next(IEnumIDList* iface, ULONG celt, static HRESULT WINAPI UnixSubFolderIterator_IEnumIDList_Next(IEnumIDList* iface, ULONG celt,
LPITEMIDLIST* rgelt, ULONG* pceltFetched) LPITEMIDLIST* rgelt, ULONG* pceltFetched)
{ {
UnixSubFolderIterator *This = ADJUST_THIS(UnixSubFolderIterator, IEnumIDList, iface); UnixSubFolderIterator *This = impl_from_IEnumIDList(iface);
ULONG i = 0; ULONG i = 0;
/* This->m_dirFolder will be NULL if the user doesn't have access rights for the dir. */ /* This->m_dirFolder will be NULL if the user doesn't have access rights for the dir. */
@ -2487,8 +2488,8 @@ static HRESULT WINAPI UnixSubFolderIterator_IEnumIDList_Skip(IEnumIDList* iface,
static HRESULT WINAPI UnixSubFolderIterator_IEnumIDList_Reset(IEnumIDList* iface) static HRESULT WINAPI UnixSubFolderIterator_IEnumIDList_Reset(IEnumIDList* iface)
{ {
UnixSubFolderIterator *This = ADJUST_THIS(UnixSubFolderIterator, IEnumIDList, iface); UnixSubFolderIterator *This = impl_from_IEnumIDList(iface);
TRACE("(iface=%p)\n", iface); TRACE("(iface=%p)\n", iface);
if (This->m_dirFolder) if (This->m_dirFolder)
@ -2523,13 +2524,13 @@ static IEnumIDList *UnixSubFolderIterator_Constructor(UnixFolder *pUnixFolder, S
TRACE("(pUnixFolder=%p)\n", pUnixFolder); TRACE("(pUnixFolder=%p)\n", pUnixFolder);
iterator = SHAlloc(sizeof(*iterator)); iterator = SHAlloc(sizeof(*iterator));
iterator->lpIEnumIDListVtbl = &UnixSubFolderIterator_IEnumIDList_Vtbl; iterator->IEnumIDList_iface.lpVtbl = &UnixSubFolderIterator_IEnumIDList_Vtbl;
iterator->m_cRef = 1; iterator->ref = 1;
iterator->m_fFilter = fFilter; iterator->m_fFilter = fFilter;
iterator->m_dirFolder = opendir(pUnixFolder->m_pszPath); iterator->m_dirFolder = opendir(pUnixFolder->m_pszPath);
lstrcpyA(iterator->m_szFolder, pUnixFolder->m_pszPath); lstrcpyA(iterator->m_szFolder, pUnixFolder->m_pszPath);
return (IEnumIDList*)iterator; return &iterator->IEnumIDList_iface;
} }
#else /* __MINGW32__ || _MSC_VER */ #else /* __MINGW32__ || _MSC_VER */