Commit 0994b850 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

Properly implement DllCanUnload ref counting.

parent 1727eb48
......@@ -170,6 +170,12 @@ extern HRESULT WINAPI IDirectMusicScriptTrack_IPersistStream_Load (LPPERSISTSTRE
extern HRESULT WINAPI IDirectMusicScriptTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty);
extern HRESULT WINAPI IDirectMusicScriptTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize);
/**********************************************************************
* Dll lifetime tracking declaration for dmscript.dll
*/
extern LONG DMSCRIPT_refCount;
static inline void DMSCRIPT_LockModule() { InterlockedIncrement( &DMSCRIPT_refCount ); }
static inline void DMSCRIPT_UnlockModule() { InterlockedDecrement( &DMSCRIPT_refCount ); }
/*****************************************************************************
* Misc.
......
......@@ -67,6 +67,8 @@ ULONG WINAPI IDirectMusicScriptImpl_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSCRIPT_LockModule();
return ref;
}
......@@ -83,6 +85,9 @@ ULONG WINAPI IDirectMusicScriptImpl_IUnknown_Release (LPUNKNOWN iface) {
HeapFree(GetProcessHeap(), 0, This->pwzSource);
HeapFree(GetProcessHeap(), 0, This);
}
DMSCRIPT_UnlockModule();
return ref;
}
......
......@@ -55,6 +55,8 @@ ULONG WINAPI IDirectMusicScriptTrack_IUnknown_AddRef (LPUNKNOWN iface) {
TRACE("(%p): AddRef from %ld\n", This, ref - 1);
DMSCRIPT_LockModule();
return ref;
}
......@@ -67,6 +69,9 @@ ULONG WINAPI IDirectMusicScriptTrack_IUnknown_Release (LPUNKNOWN iface) {
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
}
DMSCRIPT_UnlockModule();
return ref;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment