From 162b3350e13a0b861a5a1ae770247fd49cd38e6c Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Sat, 23 Dec 2006 23:51:55 +0100 Subject: [PATCH] itss: DllCanUnloadNow code clean up. --- dlls/itss/itss.c | 12 ++++++------ dlls/itss/itsstor.h | 5 +++++ dlls/itss/moniker.c | 10 ++++------ dlls/itss/storage.c | 17 ++++++++--------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/dlls/itss/itss.c b/dlls/itss/itss.c index 742465d37fe..683b02efccb 100644 --- a/dlls/itss/itss.c +++ b/dlls/itss/itss.c @@ -93,13 +93,13 @@ ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface) { - InterlockedIncrement(&dll_count); + ITSS_LockModule(); return 2; } static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface) { - InterlockedDecrement(&dll_count); + ITSS_UnlockModule(); return 1; } @@ -127,9 +127,9 @@ static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock) TRACE("(%p)->(%d)\n", iface, dolock); if (dolock) - InterlockedIncrement(&dll_count); + ITSS_LockModule(); else - InterlockedDecrement(&dll_count); + ITSS_UnlockModule(); return S_OK; } @@ -210,7 +210,7 @@ static ULONG WINAPI ITStorageImpl_Release( if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); - InterlockedDecrement(&dll_count); + ITSS_UnlockModule(); } return ref; @@ -364,8 +364,8 @@ static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj) TRACE("-> %p\n", its); *ppObj = (LPVOID) its; - InterlockedIncrement(&dll_count); + ITSS_LockModule(); return S_OK; } diff --git a/dlls/itss/itsstor.h b/dlls/itss/itsstor.h index af9fec4a909..736dd88ab4a 100644 --- a/dlls/itss/itsstor.h +++ b/dlls/itss/itsstor.h @@ -35,4 +35,9 @@ extern HRESULT ITS_IParseDisplayName_create( IUnknown *pUnkOuter, LPVOID *ppObj); +extern LONG dll_count; +static inline void ITSS_LockModule(void) { InterlockedIncrement(&dll_count); } +static inline void ITSS_UnlockModule(void) { InterlockedDecrement(&dll_count); } + + #endif /* __WINE_ITS_STORAGE_PRIVATE__ */ diff --git a/dlls/itss/moniker.c b/dlls/itss/moniker.c index 1a9401ca5d8..5149a148424 100644 --- a/dlls/itss/moniker.c +++ b/dlls/itss/moniker.c @@ -44,8 +44,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(itss); -extern LONG dll_count; - /*****************************************************************************/ typedef struct { @@ -91,7 +89,7 @@ static ULONG WINAPI ITS_IMonikerImpl_Release( if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); - InterlockedDecrement(&dll_count); + ITSS_UnlockModule(); } return ref; @@ -369,8 +367,8 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPWSTR name, DWORD n ) TRACE("-> %p %s %s\n", itsmon, debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) ); *ppObj = (IMoniker*) itsmon; - InterlockedIncrement(&dll_count); + ITSS_LockModule(); return S_OK; } @@ -416,7 +414,7 @@ static ULONG WINAPI ITS_IParseDisplayNameImpl_Release( if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); - InterlockedDecrement(&dll_count); + ITSS_UnlockModule(); } return ref; @@ -480,7 +478,7 @@ HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj) TRACE("-> %p\n", its); *ppObj = (LPVOID) its; - InterlockedIncrement(&dll_count); + ITSS_LockModule(); return S_OK; } diff --git a/dlls/itss/storage.c b/dlls/itss/storage.c index 127580864d3..d2e346c30bf 100644 --- a/dlls/itss/storage.c +++ b/dlls/itss/storage.c @@ -45,8 +45,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(itss); -extern LONG dll_count; - /************************************************************************/ typedef struct _ITSS_IStorageImpl @@ -128,7 +126,7 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_Release( This->first = t; } HeapFree(GetProcessHeap(), 0, This); - InterlockedDecrement(&dll_count); + ITSS_UnlockModule(); } return ref; @@ -254,8 +252,8 @@ static IEnumSTATSTG_Impl *ITSS_create_enum( void ) stgenum->first = NULL; stgenum->last = NULL; stgenum->current = NULL; - InterlockedIncrement(&dll_count); + ITSS_LockModule(); TRACE(" -> %p\n", stgenum ); return stgenum; @@ -299,7 +297,7 @@ static ULONG WINAPI ITSS_IStorageImpl_Release( if (ref == 0) { HeapFree(GetProcessHeap(), 0, This); - InterlockedDecrement(&dll_count); + ITSS_UnlockModule(); } return ref; @@ -574,8 +572,8 @@ static HRESULT ITSS_create_chm_storage( strcpyW( stg->dir, dir ); *ppstgOpen = (IStorage*) stg; - InterlockedIncrement(&dll_count); + ITSS_LockModule(); return S_OK; } @@ -638,8 +636,8 @@ static ULONG WINAPI ITSS_IStream_Release( if (ref == 0) { IStorage_Release( (IStorage*) This->stg ); - HeapFree(GetProcessHeap(), 0, This); - InterlockedDecrement(&dll_count); + HeapFree(GetProcessHeap(), 0, This); + ITSS_UnlockModule(); } return ref; @@ -825,7 +823,8 @@ static IStream_Impl *ITSS_create_stream( memcpy( &stm->ui, ui, sizeof stm->ui ); stm->stg = stg; IStorage_AddRef( (IStorage*) stg ); - InterlockedIncrement(&dll_count); + + ITSS_LockModule(); TRACE(" -> %p\n", stm );