From b2bb57a484023a7bc22416e0d301462c30c788e3 Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Wed, 12 Jan 2005 19:26:42 +0000 Subject: [PATCH] - use Interlocked* functions in AddRef and Release. - store the result of the Interlocked functions and use only this. --- dlls/dmcompos/chordmap.c | 11 +++++++---- dlls/dmcompos/chordmaptrack.c | 11 +++++++---- dlls/dmcompos/composer.c | 11 +++++++---- dlls/dmcompos/signposttrack.c | 11 +++++++---- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/dlls/dmcompos/chordmap.c b/dlls/dmcompos/chordmap.c index 7510fa739a6..aef51cdee80 100644 --- a/dlls/dmcompos/chordmap.c +++ b/dlls/dmcompos/chordmap.c @@ -54,17 +54,20 @@ HRESULT WINAPI IDirectMusicChordMapImpl_IUnknown_QueryInterface (LPUNKNOWN iface ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_AddRef (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface); - TRACE("(%p): AddRef from %ld\n", This, This->ref); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p): AddRef from %ld\n", This, ref - 1); DMCOMPOS_LockModule(); - return ++(This->ref); + return ref; } ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicChordMapImpl, 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); diff --git a/dlls/dmcompos/chordmaptrack.c b/dlls/dmcompos/chordmaptrack.c index 8fe1c63ab34..4b1123030c2 100644 --- a/dlls/dmcompos/chordmaptrack.c +++ b/dlls/dmcompos/chordmaptrack.c @@ -51,17 +51,20 @@ HRESULT WINAPI IDirectMusicChordMapTrack_IUnknown_QueryInterface (LPUNKNOWN ifac ULONG WINAPI IDirectMusicChordMapTrack_IUnknown_AddRef (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicChordMapTrack, UnknownVtbl, iface); - TRACE("(%p): AddRef from %ld\n", This, This->ref); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p): AddRef from %ld\n", This, ref - 1); DMCOMPOS_LockModule(); - return ++(This->ref); + return ref; } ULONG WINAPI IDirectMusicChordMapTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicChordMapTrack, 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); diff --git a/dlls/dmcompos/composer.c b/dlls/dmcompos/composer.c index 30dfb072cc8..5c066fc686f 100644 --- a/dlls/dmcompos/composer.c +++ b/dlls/dmcompos/composer.c @@ -38,17 +38,20 @@ HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface (LPDIRECTMUSICCOMPOSER if ULONG WINAPI IDirectMusicComposerImpl_AddRef (LPDIRECTMUSICCOMPOSER iface) { IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p): AddRef from %ld\n", This, ref - 1); DMCOMPOS_LockModule(); - return ++(This->ref); + return ref; } ULONG WINAPI IDirectMusicComposerImpl_Release (LPDIRECTMUSICCOMPOSER iface) { IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)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); diff --git a/dlls/dmcompos/signposttrack.c b/dlls/dmcompos/signposttrack.c index 104cef18e6b..b88cd373a37 100644 --- a/dlls/dmcompos/signposttrack.c +++ b/dlls/dmcompos/signposttrack.c @@ -51,17 +51,20 @@ HRESULT WINAPI IDirectMusicSignPostTrack_IUnknown_QueryInterface (LPUNKNOWN ifac ULONG WINAPI IDirectMusicSignPostTrack_IUnknown_AddRef (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicSignPostTrack, UnknownVtbl, iface); - TRACE("(%p): AddRef from %ld\n", This, This->ref); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p): AddRef from %ld\n", This, ref - 1); DMCOMPOS_LockModule(); - return ++(This->ref); + return ref; } ULONG WINAPI IDirectMusicSignPostTrack_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicSignPostTrack, 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);