- use Interlocked* functions in AddRef and Release.
- store the result of the Interlocked functions and use only this.
diff --git a/dlls/dmime/graph.c b/dlls/dmime/graph.c
index 0aed58d..8b5f748 100644
--- a/dlls/dmime/graph.c
+++ b/dlls/dmime/graph.c
@@ -54,14 +54,17 @@
ULONG WINAPI IDirectMusicGraphImpl_IUnknown_AddRef (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicGraphImpl, UnknownVtbl, iface);
- TRACE("(%p): AddRef from %ld\n", This, This->ref);
- return ++(This->ref);
+ ULONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p): AddRef from %ld\n", This, ref - 1);
+
+ return ref;
}
ULONG WINAPI IDirectMusicGraphImpl_IUnknown_Release (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicGraphImpl, UnknownVtbl, iface);
- ULONG ref = --This->ref;
- TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
+ ULONG ref = InterlockedDecrement(&This->ref);
+ TRACE("(%p): ReleaseRef to %ld\n", This, ref);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
}