[PATCH 2/3] dmloader: Display new ref in AddRef and Release.

Christian Costa titan.costa at gmail.com
Tue Nov 6 11:47:57 CST 2012


---
 dlls/dmloader/dmloader_private.h |    4 +---
 dlls/dmloader/loader.c           |   34 +++++++++++++++++++---------------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/dlls/dmloader/dmloader_private.h b/dlls/dmloader/dmloader_private.h
index 913f3a6..e393080 100644
--- a/dlls/dmloader/dmloader_private.h
+++ b/dlls/dmloader/dmloader_private.h
@@ -91,10 +91,8 @@ typedef struct _WINE_LOADER_OPTION {
  * IDirectMusicLoaderImpl implementation structure
  */
 struct IDirectMusicLoaderImpl {
-    /* VTABLEs */
     IDirectMusicLoader8 IDirectMusicLoader8_iface;
-    /* reference counter */
-    LONG dwRef;
+    LONG ref;
     /* simple cache (linked list) */
     struct list *pObjects;
     /* settings for certain object classes */
diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c
index 54108c7..3ef010e 100644
--- a/dlls/dmloader/loader.c
+++ b/dlls/dmloader/loader.c
@@ -93,26 +93,30 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_QueryInterface(L
 
 static ULONG WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_AddRef(LPDIRECTMUSICLOADER8 iface)
 {
-	IDirectMusicLoaderImpl *This = impl_from_IDirectMusicLoader8(iface);
-	TRACE("(%p): AddRef from %d\n", This, This->dwRef);
-	return InterlockedIncrement (&This->dwRef);
+    IDirectMusicLoaderImpl *This = impl_from_IDirectMusicLoader8(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p)->(): new ref = %u\n", This, ref);
+
+    return ref;
 }
 
 static ULONG WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_Release(LPDIRECTMUSICLOADER8 iface)
 {
-	IDirectMusicLoaderImpl *This = impl_from_IDirectMusicLoader8(iface);
+    IDirectMusicLoaderImpl *This = impl_from_IDirectMusicLoader8(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
 
-	DWORD dwRef = InterlockedDecrement (&This->dwRef);
-	TRACE("(%p): ReleaseRef to %d\n", This, This->dwRef);
-	if (dwRef == 0) {
-            /* firstly, release the cache */
-            IDirectMusicLoader8_ClearCache (iface, &GUID_DirectMusicAllTypes);
-            /* FIXME: release all allocated entries */
-            HeapFree (GetProcessHeap(), 0, This);
-            unlock_module();
-	}
+    TRACE("(%p)->(): new ref = %u\n", This, ref);
+
+    if (!ref) {
+        /* Firstly, release the cache */
+        IDirectMusicLoader8_ClearCache(iface, &GUID_DirectMusicAllTypes);
+        /* FIXME: Release all allocated entries */
+        HeapFree(GetProcessHeap(), 0, This);
+        unlock_module();
+    }
 
-	return dwRef;
+    return ref;
 }
 
 static HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_GetObject(LPDIRECTMUSICLOADER8 iface, LPDMUS_OBJECTDESC pDesc, REFIID riid, LPVOID* ppv)
@@ -880,7 +884,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderImpl (LPCGUID lpcGUID, LPVOID *ppob
 		return E_OUTOFMEMORY;
 	}
 	obj->IDirectMusicLoader8_iface.lpVtbl = &DirectMusicLoader_Loader_Vtbl;
-	obj->dwRef = 0; /* will be inited with QueryInterface */
+	obj->ref = 0; /* Will be inited with QueryInterface */
 	/* init cache/alias list */
 	obj->pObjects = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(struct list));
 	list_init (obj->pObjects);




More information about the wine-patches mailing list