From ba92d2924a286aee91f531ec6a9375d49563aac7 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Fri, 14 Jan 2005 16:02:20 +0000 Subject: [PATCH] - Use Interlocked* instead of ++/-- in AddRef/Release. - Use only stored result of Interlocked* in AddRef/Release. - Expand TRACEs to display the ref count. --- dlls/dmsynth/dmsynth_main.c | 8 +++--- dlls/dmsynth/synth.c | 17 +++++++----- dlls/dmsynth/synthsink.c | 17 +++++++----- dlls/dmusic/buffer.c | 17 +++++++----- dlls/dmusic/clock.c | 17 +++++++----- dlls/dmusic/collection.c | 17 +++++++----- dlls/dmusic/dmusic.c | 17 +++++++----- dlls/dmusic/dmusic_main.c | 8 +++--- dlls/dmusic/download.c | 17 +++++++----- dlls/dmusic/downloadedinstrument.c | 17 +++++++----- dlls/dmusic/instrument.c | 17 +++++++----- dlls/dmusic/port.c | 17 +++++++----- dlls/dmusic/portdownload.c | 17 +++++++----- dlls/dmusic/thru.c | 17 +++++++----- dlls/dpnet/address.c | 17 +++++++----- dlls/dpnet/client.c | 17 +++++++----- dlls/dswave/dswave.c | 17 +++++++----- dlls/dswave/dswave_main.c | 4 +-- dlls/dxdiagn/container.c | 17 +++++++----- dlls/dxdiagn/provider.c | 17 +++++++----- dlls/msdmo/dmoreg.c | 9 +++---- dlls/oleaut32/connpt.c | 42 ++++++++++++++---------------- dlls/oleaut32/dispatch.c | 15 ++++++----- dlls/oleaut32/olepicture.c | 19 +++++++------- dlls/oleaut32/tmarshal.c | 28 ++++++++++---------- dlls/shdocvw/classinfo.c | 24 +++++++++++------ dlls/shdocvw/events.c | 24 +++++++++++------ dlls/shdocvw/factory.c | 12 ++++++--- dlls/shdocvw/misc.c | 12 ++++++--- dlls/shdocvw/oleobject.c | 36 ++++++++++++++++--------- dlls/shdocvw/persist.c | 24 +++++++++++------ dlls/shdocvw/webbrowser.c | 12 ++++++--- dlls/shell32/autocomplete.c | 14 +++++----- dlls/shell32/cpanelfolder.c | 13 ++++----- dlls/shell32/dataobject.c | 31 ++++++++++++++-------- dlls/shell32/dragdrophelper.c | 12 +++++---- dlls/shell32/enumidlist.c | 15 ++++++----- dlls/shell32/folders.c | 12 +++++---- dlls/shell32/memorystream.c | 12 +++++---- dlls/shell32/shelllink.c | 12 +++++---- dlls/shell32/shellole.c | 14 ++++++---- dlls/shell32/shfldr_desktop.c | 12 +++++---- dlls/shell32/shfldr_fs.c | 13 ++++----- dlls/shell32/shfldr_mycomp.c | 13 ++++----- dlls/shell32/shlfsbind.c | 16 +++++++----- dlls/shell32/shlview.c | 13 ++++----- dlls/shell32/shv_bg_cmenu.c | 14 +++++----- dlls/shell32/shv_item_cmenu.c | 13 ++++----- 48 files changed, 480 insertions(+), 315 deletions(-) diff --git a/dlls/dmsynth/dmsynth_main.c b/dlls/dmsynth/dmsynth_main.c index cb7afb60bdf..852bb9ac910 100644 --- a/dlls/dmsynth/dmsynth_main.c +++ b/dlls/dmsynth/dmsynth_main.c @@ -40,13 +40,13 @@ static HRESULT WINAPI SynthCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LP static ULONG WINAPI SynthCF_AddRef(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return ++(This->ref); + return InterlockedIncrement(&This->ref); } static ULONG WINAPI SynthCF_Release(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; /* static class, won't be freed */ - return --(This->ref); + return InterlockedDecrement(&This->ref); } static HRESULT WINAPI SynthCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { @@ -82,13 +82,13 @@ static HRESULT WINAPI SynthSinkCF_QueryInterface(LPCLASSFACTORY iface,REFIID rii static ULONG WINAPI SynthSinkCF_AddRef(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return ++(This->ref); + return InterlockedIncrement(&This->ref); } static ULONG WINAPI SynthSinkCF_Release(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; /* static class, won't be freed */ - return --(This->ref); + return InterlockedDecrement(&This->ref); } static HRESULT WINAPI SynthSinkCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 97e6bf2cc7d..20fdd10b380 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -39,18 +39,23 @@ HRESULT WINAPI IDirectMusicSynth8Impl_QueryInterface (LPDIRECTMUSICSYNTH8 iface, ULONG WINAPI IDirectMusicSynth8Impl_AddRef (LPDIRECTMUSICSYNTH8 iface) { IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicSynth8Impl_Release (LPDIRECTMUSICSYNTH8 iface) { IDirectMusicSynth8Impl *This = (IDirectMusicSynth8Impl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusicSynth8Impl IDirectMusicSynth part: */ diff --git a/dlls/dmsynth/synthsink.c b/dlls/dmsynth/synthsink.c index 2523936dca0..d190da5f8e5 100644 --- a/dlls/dmsynth/synthsink.c +++ b/dlls/dmsynth/synthsink.c @@ -38,18 +38,23 @@ HRESULT WINAPI IDirectMusicSynthSinkImpl_QueryInterface (LPDIRECTMUSICSYNTHSINK ULONG WINAPI IDirectMusicSynthSinkImpl_AddRef (LPDIRECTMUSICSYNTHSINK iface) { IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicSynthSinkImpl_Release (LPDIRECTMUSICSYNTHSINK iface) { IDirectMusicSynthSinkImpl *This = (IDirectMusicSynthSinkImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusicSynthSinkImpl IDirectMusicSynthSink part: */ diff --git a/dlls/dmusic/buffer.c b/dlls/dmusic/buffer.c index a19ebbe516b..b60248435a8 100644 --- a/dlls/dmusic/buffer.c +++ b/dlls/dmusic/buffer.c @@ -37,18 +37,23 @@ HRESULT WINAPI IDirectMusicBufferImpl_QueryInterface (LPDIRECTMUSICBUFFER iface, ULONG WINAPI IDirectMusicBufferImpl_AddRef (LPDIRECTMUSICBUFFER iface) { IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface) { IDirectMusicBufferImpl *This = (IDirectMusicBufferImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusicBufferImpl IDirectMusicBuffer part: */ diff --git a/dlls/dmusic/clock.c b/dlls/dmusic/clock.c index ccd6c5ad2d3..ab7789f7370 100644 --- a/dlls/dmusic/clock.c +++ b/dlls/dmusic/clock.c @@ -38,18 +38,23 @@ HRESULT WINAPI IReferenceClockImpl_QueryInterface (IReferenceClock *iface, REFII ULONG WINAPI IReferenceClockImpl_AddRef (IReferenceClock *iface) { IReferenceClockImpl *This = (IReferenceClockImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IReferenceClockImpl_Release (IReferenceClock *iface) { IReferenceClockImpl *This = (IReferenceClockImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IReferenceClockImpl IReferenceClock part: */ diff --git a/dlls/dmusic/collection.c b/dlls/dmusic/collection.c index 8297a885020..d4989a1319b 100644 --- a/dlls/dmusic/collection.c +++ b/dlls/dmusic/collection.c @@ -54,18 +54,23 @@ HRESULT WINAPI IDirectMusicCollectionImpl_IUnknown_QueryInterface (LPUNKNOWN ifa ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_AddRef (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicCollectionImpl, UnknownVtbl, iface); - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicCollectionImpl_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicCollectionImpl, UnknownVtbl, iface); - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } IUnknownVtbl DirectMusicCollection_Unknown_Vtbl = { diff --git a/dlls/dmusic/dmusic.c b/dlls/dmusic/dmusic.c index f08a8b67faa..9cdde015426 100644 --- a/dlls/dmusic/dmusic.c +++ b/dlls/dmusic/dmusic.c @@ -40,18 +40,23 @@ HRESULT WINAPI IDirectMusic8Impl_QueryInterface (LPDIRECTMUSIC8 iface, REFIID ri ULONG WINAPI IDirectMusic8Impl_AddRef (LPDIRECTMUSIC8 iface) { IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusic8Impl_Release (LPDIRECTMUSIC8 iface) { IDirectMusic8Impl *This = (IDirectMusic8Impl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusic8Impl IDirectMusic part: */ diff --git a/dlls/dmusic/dmusic_main.c b/dlls/dmusic/dmusic_main.c index 088114dfaa7..b06f9608a07 100644 --- a/dlls/dmusic/dmusic_main.c +++ b/dlls/dmusic/dmusic_main.c @@ -40,13 +40,13 @@ static HRESULT WINAPI DirectMusicCF_QueryInterface(LPCLASSFACTORY iface,REFIID r static ULONG WINAPI DirectMusicCF_AddRef(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return ++(This->ref); + return InterlockedIncrement(&This->ref); } static ULONG WINAPI DirectMusicCF_Release(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; /* static class, won't be freed */ - return --(This->ref); + return InterlockedDecrement(&This->ref); } static HRESULT WINAPI DirectMusicCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { @@ -82,13 +82,13 @@ static HRESULT WINAPI CollectionCF_QueryInterface(LPCLASSFACTORY iface,REFIID ri static ULONG WINAPI CollectionCF_AddRef(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return ++(This->ref); + return InterlockedIncrement(&This->ref); } static ULONG WINAPI CollectionCF_Release(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; /* static class, won't be freed */ - return --(This->ref); + return InterlockedDecrement(&This->ref); } static HRESULT WINAPI CollectionCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { diff --git a/dlls/dmusic/download.c b/dlls/dmusic/download.c index 1c06c2f2c7b..3d67b778826 100644 --- a/dlls/dmusic/download.c +++ b/dlls/dmusic/download.c @@ -38,18 +38,23 @@ HRESULT WINAPI IDirectMusicDownloadImpl_QueryInterface (LPDIRECTMUSICDOWNLOAD if ULONG WINAPI IDirectMusicDownloadImpl_AddRef (LPDIRECTMUSICDOWNLOAD iface) { IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicDownloadImpl_Release (LPDIRECTMUSICDOWNLOAD iface) { IDirectMusicDownloadImpl *This = (IDirectMusicDownloadImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusicDownloadImpl IDirectMusicDownload part: */ diff --git a/dlls/dmusic/downloadedinstrument.c b/dlls/dmusic/downloadedinstrument.c index ccf86fa4250..0cfa0acac3a 100644 --- a/dlls/dmusic/downloadedinstrument.c +++ b/dlls/dmusic/downloadedinstrument.c @@ -38,18 +38,23 @@ HRESULT WINAPI IDirectMusicDownloadedInstrumentImpl_QueryInterface (LPDIRECTMUSI ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface) { IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release (LPDIRECTMUSICDOWNLOADEDINSTRUMENT iface) { IDirectMusicDownloadedInstrumentImpl *This = (IDirectMusicDownloadedInstrumentImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstrument part: */ diff --git a/dlls/dmusic/instrument.c b/dlls/dmusic/instrument.c index c7cfe3a4ee0..37f4c7c54ef 100644 --- a/dlls/dmusic/instrument.c +++ b/dlls/dmusic/instrument.c @@ -54,18 +54,23 @@ HRESULT WINAPI IDirectMusicInstrumentImpl_IUnknown_QueryInterface (LPUNKNOWN ifa ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_AddRef (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface); - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicInstrumentImpl_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicInstrumentImpl, UnknownVtbl, iface); - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } IUnknownVtbl DirectMusicInstrument_Unknown_Vtbl = { diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c index d7ef380445a..8d0e503de33 100644 --- a/dlls/dmusic/port.c +++ b/dlls/dmusic/port.c @@ -37,18 +37,23 @@ HRESULT WINAPI IDirectMusicPortImpl_QueryInterface (LPDIRECTMUSICPORT iface, REF ULONG WINAPI IDirectMusicPortImpl_AddRef (LPDIRECTMUSICPORT iface) { IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicPortImpl_Release (LPDIRECTMUSICPORT iface) { IDirectMusicPortImpl *This = (IDirectMusicPortImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusicPortImpl IDirectMusicPort part: */ diff --git a/dlls/dmusic/portdownload.c b/dlls/dmusic/portdownload.c index 0c47b06855b..2778c397807 100644 --- a/dlls/dmusic/portdownload.c +++ b/dlls/dmusic/portdownload.c @@ -37,18 +37,23 @@ HRESULT WINAPI IDirectMusicPortDownloadImpl_QueryInterface (LPDIRECTMUSICPORTDOW ULONG WINAPI IDirectMusicPortDownloadImpl_AddRef (LPDIRECTMUSICPORTDOWNLOAD iface) { IDirectMusicPortDownloadImpl *This = (IDirectMusicPortDownloadImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicPortDownloadImpl_Release (LPDIRECTMUSICPORTDOWNLOAD iface) { IDirectMusicPortDownloadImpl *This = (IDirectMusicPortDownloadImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusicPortDownload Interface follow: */ diff --git a/dlls/dmusic/thru.c b/dlls/dmusic/thru.c index 4886e86a6d2..a07403ebd27 100644 --- a/dlls/dmusic/thru.c +++ b/dlls/dmusic/thru.c @@ -38,18 +38,23 @@ HRESULT WINAPI IDirectMusicThruImpl_QueryInterface (LPDIRECTMUSICTHRU iface, REF ULONG WINAPI IDirectMusicThruImpl_AddRef (LPDIRECTMUSICTHRU iface) { IDirectMusicThruImpl *This = (IDirectMusicThruImpl *)iface; - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicThruImpl_Release (LPDIRECTMUSICTHRU iface) { IDirectMusicThruImpl *This = (IDirectMusicThruImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectMusicThru Interface follow: */ diff --git a/dlls/dpnet/address.c b/dlls/dpnet/address.c index a162209dabd..1b5706bf076 100644 --- a/dlls/dpnet/address.c +++ b/dlls/dpnet/address.c @@ -54,18 +54,23 @@ HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(PDIRECTPLAY8ADDRESS iface, ULONG WINAPI IDirectPlay8AddressImpl_AddRef(PDIRECTPLAY8ADDRESS iface) { IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface; - TRACE("(%p) : AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectPlay8AddressImpl_Release(PDIRECTPLAY8ADDRESS iface) { IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectPlay8Address Interface follow: */ diff --git a/dlls/dpnet/client.c b/dlls/dpnet/client.c index 4596f9554a4..88fefcb7d0e 100644 --- a/dlls/dpnet/client.c +++ b/dlls/dpnet/client.c @@ -54,18 +54,23 @@ HRESULT WINAPI IDirectPlay8ClientImpl_QueryInterface(PDIRECTPLAY8CLIENT iface, R ULONG WINAPI IDirectPlay8ClientImpl_AddRef(PDIRECTPLAY8CLIENT iface) { IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface; - TRACE("(%p) : AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectPlay8ClientImpl_Release(PDIRECTPLAY8CLIENT iface) { IDirectPlay8ClientImpl *This = (IDirectPlay8ClientImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDirectPlay8Client Interface follow: */ diff --git a/dlls/dswave/dswave.c b/dlls/dswave/dswave.c index 1e5cb3597a9..de9a8bb20c8 100644 --- a/dlls/dswave/dswave.c +++ b/dlls/dswave/dswave.c @@ -64,18 +64,23 @@ HRESULT WINAPI IDirectMusicWaveImpl_IUnknown_QueryInterface (LPUNKNOWN iface, RE ULONG WINAPI IDirectMusicWaveImpl_IUnknown_AddRef (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicWaveImpl, UnknownVtbl, iface); - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDirectMusicWaveImpl_IUnknown_Release (LPUNKNOWN iface) { ICOM_THIS_MULTI(IDirectMusicWaveImpl, UnknownVtbl, iface); - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } IUnknownVtbl DirectMusicWave_Unknown_Vtbl = { diff --git a/dlls/dswave/dswave_main.c b/dlls/dswave/dswave_main.c index e4427e1f6f4..3c7c1a2f5e4 100644 --- a/dlls/dswave/dswave_main.c +++ b/dlls/dswave/dswave_main.c @@ -40,13 +40,13 @@ static HRESULT WINAPI WaveCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPV static ULONG WINAPI WaveCF_AddRef(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - return ++(This->ref); + return InterlockedIncrement(&This->ref); } static ULONG WINAPI WaveCF_Release(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; /* static class, won't be freed */ - return --(This->ref); + return InterlockedDecrement(&This->ref); } static HRESULT WINAPI WaveCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) { diff --git a/dlls/dxdiagn/container.c b/dlls/dxdiagn/container.c index 04348c0d39a..0b502eab4fb 100644 --- a/dlls/dxdiagn/container.c +++ b/dlls/dxdiagn/container.c @@ -44,18 +44,23 @@ HRESULT WINAPI IDxDiagContainerImpl_QueryInterface(PDXDIAGCONTAINER iface, REFII ULONG WINAPI IDxDiagContainerImpl_AddRef(PDXDIAGCONTAINER iface) { IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; - TRACE("(%p) : AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDxDiagContainerImpl_Release(PDXDIAGCONTAINER iface) { IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDxDiagContainer Interface follow: */ diff --git a/dlls/dxdiagn/provider.c b/dlls/dxdiagn/provider.c index 3e6511948ca..b6f93232e26 100644 --- a/dlls/dxdiagn/provider.c +++ b/dlls/dxdiagn/provider.c @@ -43,18 +43,23 @@ HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface, REFIID ULONG WINAPI IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface) { IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface; - TRACE("(%p) : AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } ULONG WINAPI IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface) { IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface; - ULONG ref = --This->ref; - TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + if (!refCount) { HeapFree(GetProcessHeap(), 0, This); } - return ref; + return refCount; } /* IDxDiagProvider Interface follow: */ diff --git a/dlls/msdmo/dmoreg.c b/dlls/msdmo/dmoreg.c index 51d8430b59e..0004eb2ec23 100644 --- a/dlls/msdmo/dmoreg.c +++ b/dlls/msdmo/dmoreg.c @@ -383,7 +383,7 @@ lerr: static ULONG WINAPI IEnumDMO_fnAddRef(IEnumDMO * iface) { IEnumDMOImpl *This = (IEnumDMOImpl *)iface; - return ++(This->ref); + return InterlockedIncrement(&This->ref); } @@ -420,15 +420,14 @@ static HRESULT WINAPI IEnumDMO_fnQueryInterface( static ULONG WINAPI IEnumDMO_fnRelease(IEnumDMO * iface) { IEnumDMOImpl *This = (IEnumDMOImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - if (!--(This->ref)) + if (!refCount) { IEnumDMO_Destructor((IEnumDMO*)This); HeapFree(GetProcessHeap(),0,This); - return 0; } - - return This->ref; + return refCount; } diff --git a/dlls/oleaut32/connpt.c b/dlls/oleaut32/connpt.c index 5cc49c57984..b2afb6a872c 100644 --- a/dlls/oleaut32/connpt.c +++ b/dlls/oleaut32/connpt.c @@ -196,8 +196,11 @@ static HRESULT WINAPI ConnectionPointImpl_QueryInterface( static ULONG WINAPI ConnectionPointImpl_AddRef(IConnectionPoint* iface) { ConnectionPointImpl *This = (ConnectionPointImpl *)iface; - TRACE("(%p)->(ref=%ld)\n", This, This->ref); - return InterlockedIncrement(&This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%ld)\n", This, refCount - 1); + + return refCount; } /************************************************************************ @@ -209,20 +212,16 @@ static ULONG WINAPI ConnectionPointImpl_Release( IConnectionPoint* iface) { ConnectionPointImpl *This = (ConnectionPointImpl *)iface; - ULONG ref; - TRACE("(%p)->(ref=%ld)\n", This, This->ref); + ULONG refCount = InterlockedDecrement(&This->ref); - /* - * Decrease the reference count on this object. - */ - ref = InterlockedDecrement(&This->ref); + TRACE("(%p)->(ref before=%ld)\n", This, refCount + 1); /* * If the reference count goes down to 0, perform suicide. */ - if (ref == 0) ConnectionPointImpl_Destroy(This); + if (!refCount) ConnectionPointImpl_Destroy(This); - return ref; + return refCount; } /************************************************************************ @@ -470,11 +469,12 @@ static HRESULT WINAPI EnumConnectionsImpl_QueryInterface( static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface) { EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; - ULONG ref; - TRACE("(%p)->(ref=%ld)\n", This, This->ref); - ref = InterlockedIncrement(&This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%ld)\n", This, refCount - 1); + IUnknown_AddRef(This->pUnk); - return ref; + return refCount; } /************************************************************************ @@ -485,22 +485,18 @@ static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface) static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface) { EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; - ULONG ref; - TRACE("(%p)->(ref=%ld)\n", This, This->ref); + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(ref before=%ld)\n", This, refCount + 1); IUnknown_Release(This->pUnk); - /* - * Decrease the reference count on this object. - */ - ref = InterlockedDecrement(&This->ref); - /* * If the reference count goes down to 0, perform suicide. */ - if (ref == 0) EnumConnectionsImpl_Destroy(This); + if (!refCount) EnumConnectionsImpl_Destroy(This); - return ref; + return refCount; } /************************************************************************ diff --git a/dlls/oleaut32/dispatch.c b/dlls/oleaut32/dispatch.c index a3ce7440ece..37514b303a1 100644 --- a/dlls/oleaut32/dispatch.c +++ b/dlls/oleaut32/dispatch.c @@ -256,9 +256,11 @@ static HRESULT WINAPI StdDispatch_QueryInterface( static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface) { StdDispatch *This = (StdDispatch *)iface; - TRACE("()\n"); + ULONG refCount = InterlockedIncrement(&This->ref); - return InterlockedIncrement(&This->ref); + TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1); + + return refCount; } /****************************************************************************** @@ -269,18 +271,17 @@ static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface) static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface) { StdDispatch *This = (StdDispatch *)iface; - ULONG ref; - TRACE("(%p)->()\n", This); + ULONG refCount = InterlockedDecrement(&This->ref); - ref = InterlockedDecrement(&This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); - if (ref == 0) + if (!refCount) { ITypeInfo_Release(This->pTypeInfo); CoTaskMemFree(This); } - return ref; + return refCount; } /****************************************************************************** diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index f3dc75cd880..de74c36a742 100644 --- a/dlls/oleaut32/olepicture.c +++ b/dlls/oleaut32/olepicture.c @@ -409,8 +409,11 @@ static ULONG WINAPI OLEPictureImpl_AddRef( IPicture* iface) { OLEPictureImpl *This = (OLEPictureImpl *)iface; - TRACE("(%p)->(ref=%ld)\n", This, This->ref); - return InterlockedIncrement(&This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(ref before=%ld)\n", This, refCount - 1); + + return refCount; } /************************************************************************ @@ -422,20 +425,16 @@ static ULONG WINAPI OLEPictureImpl_Release( IPicture* iface) { OLEPictureImpl *This = (OLEPictureImpl *)iface; - ULONG ret; - TRACE("(%p)->(ref=%ld)\n", This, This->ref); + ULONG refCount = InterlockedDecrement(&This->ref); - /* - * Decrease the reference count on this object. - */ - ret = InterlockedDecrement(&This->ref); + TRACE("(%p)->(ref before=%ld)\n", This, refCount + 1); /* * If the reference count goes down to 0, perform suicide. */ - if (ret==0) OLEPictureImpl_Destroy(This); + if (!refCount) OLEPictureImpl_Destroy(This); - return ret; + return refCount; } diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c index f5de3858d19..9f2990664e1 100644 --- a/dlls/oleaut32/tmarshal.c +++ b/dlls/oleaut32/tmarshal.c @@ -336,29 +336,29 @@ static ULONG WINAPI TMProxyImpl_AddRef(LPRPCPROXYBUFFER iface) { ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface); + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("()\n"); + TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1); - return InterlockedIncrement(&This->ref); + return refCount; } static ULONG WINAPI TMProxyImpl_Release(LPRPCPROXYBUFFER iface) { - ULONG refs; ICOM_THIS_MULTI(TMProxyImpl,lpvtbl2,iface); + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("()\n"); + TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1); - refs = InterlockedDecrement(&This->ref); - if (!refs) + if (!refCount) { DeleteCriticalSection(&This->crit); if (This->chanbuf) IRpcChannelBuffer_Release(This->chanbuf); VirtualFree(This->asmstubs, 0, MEM_RELEASE); CoTaskMemFree(This); } - return refs; + return refCount; } static HRESULT WINAPI @@ -1505,27 +1505,27 @@ static ULONG WINAPI TMStubImpl_AddRef(LPRPCSTUBBUFFER iface) { TMStubImpl *This = (TMStubImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p) before %lu\n", This, This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); - return InterlockedIncrement(&This->ref); + return refCount; } static ULONG WINAPI TMStubImpl_Release(LPRPCSTUBBUFFER iface) { - ULONG refs; TMStubImpl *This = (TMStubImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p) after %lu\n", This, This->ref-1); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); - refs = InterlockedDecrement(&This->ref); - if (!refs) + if (!refCount) { IRpcStubBuffer_Disconnect(iface); CoTaskMemFree(This); } - return refs; + return refCount; } static HRESULT WINAPI diff --git a/dlls/shdocvw/classinfo.c b/dlls/shdocvw/classinfo.c index 13164521720..3207726d122 100644 --- a/dlls/shdocvw/classinfo.c +++ b/dlls/shdocvw/classinfo.c @@ -47,18 +47,22 @@ static HRESULT WINAPI WBPCI_QueryInterface(LPPROVIDECLASSINFO iface, static ULONG WINAPI WBPCI_AddRef(LPPROVIDECLASSINFO iface) { IProvideClassInfoImpl *This = (IProvideClassInfoImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBPCI_Release(LPPROVIDECLASSINFO iface) { IProvideClassInfoImpl *This = (IProvideClassInfoImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } /* Return an ITypeInfo interface to retrieve type library info about @@ -102,18 +106,22 @@ static HRESULT WINAPI WBPCI2_QueryInterface(LPPROVIDECLASSINFO2 iface, static ULONG WINAPI WBPCI2_AddRef(LPPROVIDECLASSINFO2 iface) { IProvideClassInfo2Impl *This = (IProvideClassInfo2Impl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBPCI2_Release(LPPROVIDECLASSINFO2 iface) { IProvideClassInfo2Impl *This = (IProvideClassInfo2Impl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } /* Return an ITypeInfo interface to retrieve type library info about diff --git a/dlls/shdocvw/events.c b/dlls/shdocvw/events.c index 9f6a8f9e3f2..d1b1e25afa6 100644 --- a/dlls/shdocvw/events.c +++ b/dlls/shdocvw/events.c @@ -47,18 +47,22 @@ static HRESULT WINAPI WBCPC_QueryInterface(LPCONNECTIONPOINTCONTAINER iface, static ULONG WINAPI WBCPC_AddRef(LPCONNECTIONPOINTCONTAINER iface) { IConnectionPointContainerImpl *This = (IConnectionPointContainerImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBCPC_Release(LPCONNECTIONPOINTCONTAINER iface) { IConnectionPointContainerImpl *This = (IConnectionPointContainerImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } /* Get a list of connection points inside this container. */ @@ -131,18 +135,22 @@ static HRESULT WINAPI WBCP_QueryInterface(LPCONNECTIONPOINT iface, static ULONG WINAPI WBCP_AddRef(LPCONNECTIONPOINT iface) { IConnectionPointImpl *This = (IConnectionPointImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBCP_Release(LPCONNECTIONPOINT iface) { IConnectionPointImpl *This = (IConnectionPointImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } static HRESULT WINAPI WBCP_GetConnectionInterface(LPCONNECTIONPOINT iface, IID* pIId) diff --git a/dlls/shdocvw/factory.c b/dlls/shdocvw/factory.c index 2187204887a..9697a82d785 100644 --- a/dlls/shdocvw/factory.c +++ b/dlls/shdocvw/factory.c @@ -55,9 +55,11 @@ static HRESULT WINAPI WBCF_QueryInterface(LPCLASSFACTORY iface, static ULONG WINAPI WBCF_AddRef(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } /************************************************************************ @@ -66,10 +68,12 @@ static ULONG WINAPI WBCF_AddRef(LPCLASSFACTORY iface) static ULONG WINAPI WBCF_Release(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } /************************************************************************ diff --git a/dlls/shdocvw/misc.c b/dlls/shdocvw/misc.c index 4142a7ab904..1450834b8cd 100644 --- a/dlls/shdocvw/misc.c +++ b/dlls/shdocvw/misc.c @@ -41,18 +41,22 @@ static HRESULT WINAPI WBQA_QueryInterface(LPQUICKACTIVATE iface, static ULONG WINAPI WBQA_AddRef(LPQUICKACTIVATE iface) { IQuickActivateImpl *This = (IQuickActivateImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBQA_Release(LPQUICKACTIVATE iface) { IQuickActivateImpl *This = (IQuickActivateImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } /* Alternative interface for quicker, easier activation of a control. */ diff --git a/dlls/shdocvw/oleobject.c b/dlls/shdocvw/oleobject.c index 7b71cb3d664..da594c7dd40 100644 --- a/dlls/shdocvw/oleobject.c +++ b/dlls/shdocvw/oleobject.c @@ -144,9 +144,11 @@ static HRESULT WINAPI WBOOBJ_QueryInterface(LPOLEOBJECT iface, static ULONG WINAPI WBOOBJ_AddRef(LPOLEOBJECT iface) { IOleObjectImpl *This = (IOleObjectImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } /************************************************************************ @@ -155,10 +157,12 @@ static ULONG WINAPI WBOOBJ_AddRef(LPOLEOBJECT iface) static ULONG WINAPI WBOOBJ_Release(LPOLEOBJECT iface) { IOleObjectImpl *This = (IOleObjectImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } /************************************************************************ @@ -457,18 +461,22 @@ static HRESULT WINAPI WBOIPO_QueryInterface(LPOLEINPLACEOBJECT iface, static ULONG WINAPI WBOIPO_AddRef(LPOLEINPLACEOBJECT iface) { IOleInPlaceObjectImpl *This = (IOleInPlaceObjectImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBOIPO_Release(LPOLEINPLACEOBJECT iface) { IOleInPlaceObjectImpl *This = (IOleInPlaceObjectImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } static HRESULT WINAPI WBOIPO_GetWindow(LPOLEINPLACEOBJECT iface, HWND* phwnd) @@ -559,18 +567,22 @@ static HRESULT WINAPI WBOC_QueryInterface(LPOLECONTROL iface, static ULONG WINAPI WBOC_AddRef(LPOLECONTROL iface) { IOleControlImpl *This = (IOleControlImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBOC_Release(LPOLECONTROL iface) { IOleControlImpl *This = (IOleControlImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } static HRESULT WINAPI WBOC_GetControlInfo(LPOLECONTROL iface, LPCONTROLINFO pCI) diff --git a/dlls/shdocvw/persist.c b/dlls/shdocvw/persist.c index afed6825bff..a5c2965a547 100644 --- a/dlls/shdocvw/persist.c +++ b/dlls/shdocvw/persist.c @@ -39,18 +39,22 @@ static HRESULT WINAPI WBPS_QueryInterface(LPPERSISTSTORAGE iface, static ULONG WINAPI WBPS_AddRef(LPPERSISTSTORAGE iface) { IPersistStorageImpl *This = (IPersistStorageImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBPS_Release(LPPERSISTSTORAGE iface) { IPersistStorageImpl *This = (IPersistStorageImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } static HRESULT WINAPI WBPS_GetClassID(LPPERSISTSTORAGE iface, CLSID *pClassID) @@ -126,18 +130,22 @@ static HRESULT WINAPI WBPSI_QueryInterface(LPPERSISTSTREAMINIT iface, static ULONG WINAPI WBPSI_AddRef(LPPERSISTSTREAMINIT iface) { IPersistStreamInitImpl *This = (IPersistStreamInitImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WBPSI_Release(LPPERSISTSTREAMINIT iface) { IPersistStreamInitImpl *This = (IPersistStreamInitImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } static HRESULT WINAPI WBPSI_GetClassID(LPPERSISTSTREAMINIT iface, CLSID *pClassID) diff --git a/dlls/shdocvw/webbrowser.c b/dlls/shdocvw/webbrowser.c index 6d5eb199e90..e242781db6c 100644 --- a/dlls/shdocvw/webbrowser.c +++ b/dlls/shdocvw/webbrowser.c @@ -38,18 +38,22 @@ static HRESULT WINAPI WB_QueryInterface(IWebBrowser *iface, REFIID riid, LPVOID static ULONG WINAPI WB_AddRef(IWebBrowser *iface) { IWebBrowserImpl *This = (IWebBrowserImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("\n"); - return ++(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI WB_Release(IWebBrowser *iface) { IWebBrowserImpl *This = (IWebBrowserImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); /* static class, won't be freed */ - TRACE("\n"); - return --(This->ref); + TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); + + return refCount; } /* IDispatch methods */ diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c index 93e2b1f0718..f4f9b42548e 100644 --- a/dlls/shell32/autocomplete.c +++ b/dlls/shell32/autocomplete.c @@ -170,9 +170,11 @@ static ULONG WINAPI IAutoComplete_fnAddRef( IAutoComplete * iface) { IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(%lu)\n",This,This->ref); - return ++(This->ref); + TRACE("(%p)->(%lu)\n", This, refCount - 1); + + return refCount; } /****************************************************************************** @@ -182,10 +184,11 @@ static ULONG WINAPI IAutoComplete_fnRelease( IAutoComplete * iface) { IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->(%lu)\n",This,This->ref); + TRACE("(%p)->(%lu)\n", This, refCount + 1); - if (!--(This->ref)) { + if (!refCount) { TRACE(" destroying IAutoComplete(%p)\n",This); HeapFree(GetProcessHeap(), 0, This->quickComplete); HeapFree(GetProcessHeap(), 0, This->txtbackup); @@ -194,9 +197,8 @@ static ULONG WINAPI IAutoComplete_fnRelease( if (This->enumstr) IEnumString_Release(This->enumstr); HeapFree(GetProcessHeap(), 0, This); - return 0; } - return This->ref; + return refCount; } /****************************************************************************** diff --git a/dlls/shell32/cpanelfolder.c b/dlls/shell32/cpanelfolder.c index 588aae7790b..987e3d91b27 100644 --- a/dlls/shell32/cpanelfolder.c +++ b/dlls/shell32/cpanelfolder.c @@ -181,26 +181,27 @@ static HRESULT WINAPI ISF_ControlPanel_fnQueryInterface(IShellFolder2 * iface, R static ULONG WINAPI ISF_ControlPanel_fnAddRef(IShellFolder2 * iface) { ICPanelImpl *This = (ICPanelImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(count=%lu)\n", This, This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } static ULONG WINAPI ISF_ControlPanel_fnRelease(IShellFolder2 * iface) { ICPanelImpl *This = (ICPanelImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->(count=%lu)\n", This, This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount + 1); - if (!--(This->ref)) { + if (!refCount) { TRACE("-- destroying IShellFolder(%p)\n", This); if (This->pidlRoot) SHFree(This->pidlRoot); LocalFree((HLOCAL) This); - return 0; } - return This->ref; + return refCount; } /************************************************************************** diff --git a/dlls/shell32/dataobject.c b/dlls/shell32/dataobject.c index 96adeb04a40..b311e30424f 100644 --- a/dlls/shell32/dataobject.c +++ b/dlls/shell32/dataobject.c @@ -124,16 +124,21 @@ static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface(LPENUMFORMATETC iface, REF static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPENUMFORMATETC iface) { IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - TRACE("(%p)->(count=%lu)\n",This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface) { IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; - TRACE("(%p)->()\n",This); + ULONG refCount = InterlockedDecrement(&This->ref); - if (!--(This->ref)) + TRACE("(%p)->(%lu)\n", This, refCount + 1); + + if (!refCount) { TRACE(" destroying IEnumFORMATETC(%p)\n",This); if (This->pFmt) @@ -143,7 +148,7 @@ static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface) HeapFree(GetProcessHeap(),0,This); return 0; } - return This->ref; + return refCount; } static HRESULT WINAPI IEnumFORMATETC_fnNext(LPENUMFORMATETC iface, ULONG celt, FORMATETC *rgelt, ULONG *pceltFethed) @@ -291,8 +296,11 @@ static HRESULT WINAPI IDataObject_fnQueryInterface(LPDATAOBJECT iface, REFIID ri static ULONG WINAPI IDataObject_fnAddRef(LPDATAOBJECT iface) { IDataObjectImpl *This = (IDataObjectImpl *)iface; - TRACE("(%p)->(count=%lu)\n",This, This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); + + return refCount; } /************************************************************************** @@ -301,17 +309,18 @@ static ULONG WINAPI IDataObject_fnAddRef(LPDATAOBJECT iface) static ULONG WINAPI IDataObject_fnRelease(LPDATAOBJECT iface) { IDataObjectImpl *This = (IDataObjectImpl *)iface; - TRACE("(%p)->()\n",This); + ULONG refCount = InterlockedDecrement(&This->ref); - if (!--(This->ref)) + TRACE("(%p)->(%lu)\n", This, refCount + 1); + + if (!refCount) { TRACE(" destroying IDataObject(%p)\n",This); _ILFreeaPidl(This->apidl, This->cidl); ILFree(This->pidl), HeapFree(GetProcessHeap(),0,This); - return 0; } - return This->ref; + return refCount; } /************************************************************************** diff --git a/dlls/shell32/dragdrophelper.c b/dlls/shell32/dragdrophelper.c index f8005708433..53a879f186b 100644 --- a/dlls/shell32/dragdrophelper.c +++ b/dlls/shell32/dragdrophelper.c @@ -113,24 +113,26 @@ static HRESULT WINAPI IDropTargetHelper_fnQueryInterface (IDropTargetHelper * if static ULONG WINAPI IDropTargetHelper_fnAddRef (IDropTargetHelper * iface) { IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE ("(%p)->(count=%lu)\n", This, This->ref); + TRACE ("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } static ULONG WINAPI IDropTargetHelper_fnRelease (IDropTargetHelper * iface) { IDropTargetHelperImpl *This = (IDropTargetHelperImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE ("(%p)->(count=%lu)\n", This, This->ref); + TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); - if (!--(This->ref)) { + if (!refCount) { TRACE("-- destroying (%p)\n", This); LocalFree ((HLOCAL) This); return 0; } - return This->ref; + return refCount; } static HRESULT WINAPI IDropTargetHelper_fnDragEnter ( diff --git a/dlls/shell32/enumidlist.c b/dlls/shell32/enumidlist.c index 31abedbcad7..1d78e29cbe3 100644 --- a/dlls/shell32/enumidlist.c +++ b/dlls/shell32/enumidlist.c @@ -240,8 +240,11 @@ static ULONG WINAPI IEnumIDList_fnAddRef( IEnumIDList * iface) { IEnumIDListImpl *This = (IEnumIDListImpl *)iface; - TRACE("(%p)->(%lu)\n",This,This->ref); - return ++(This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(%lu)\n", This, refCount - 1); + + return refCount; } /****************************************************************************** * IEnumIDList_fnRelease @@ -250,16 +253,16 @@ static ULONG WINAPI IEnumIDList_fnRelease( IEnumIDList * iface) { IEnumIDListImpl *This = (IEnumIDListImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->(%lu)\n",This,This->ref); + TRACE("(%p)->(%lu)\n", This, refCount + 1); - if (!--(This->ref)) { + if (!refCount) { TRACE(" destroying IEnumIDList(%p)\n",This); DeleteList((IEnumIDList*)This); HeapFree(GetProcessHeap(),0,This); - return 0; } - return This->ref; + return refCount; } /************************************************************************** diff --git a/dlls/shell32/folders.c b/dlls/shell32/folders.c index 7aa2e7485d5..12b6fe4d52a 100644 --- a/dlls/shell32/folders.c +++ b/dlls/shell32/folders.c @@ -130,10 +130,11 @@ static HRESULT WINAPI IExtractIconW_fnQueryInterface(IExtractIconW *iface, REFII static ULONG WINAPI IExtractIconW_fnAddRef(IExtractIconW * iface) { IExtractIconWImpl *This = (IExtractIconWImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(count=%lu)\n",This, This->ref ); + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } /************************************************************************** * IExtractIconW_Release @@ -141,17 +142,18 @@ static ULONG WINAPI IExtractIconW_fnAddRef(IExtractIconW * iface) static ULONG WINAPI IExtractIconW_fnRelease(IExtractIconW * iface) { IExtractIconWImpl *This = (IExtractIconWImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->()\n",This); + TRACE("(%p)->(count=%lu)\n", This, refCount + 1); - if (!--(This->ref)) + if (!refCount) { TRACE(" destroying IExtractIcon(%p)\n",This); SHFree(This->pidl); HeapFree(GetProcessHeap(),0,This); return 0; } - return This->ref; + return refCount; } static HRESULT getIconLocationForFolder(IExtractIconW *iface, UINT uFlags, diff --git a/dlls/shell32/memorystream.c b/dlls/shell32/memorystream.c index ff7ea0b00c8..e6460a6d6c1 100644 --- a/dlls/shell32/memorystream.c +++ b/dlls/shell32/memorystream.c @@ -127,10 +127,11 @@ static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVO static ULONG WINAPI IStream_fnAddRef(IStream *iface) { ISHFileStream *This = (ISHFileStream *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(count=%lu)\n",This, This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } /************************************************************************** @@ -139,16 +140,17 @@ static ULONG WINAPI IStream_fnAddRef(IStream *iface) static ULONG WINAPI IStream_fnRelease(IStream *iface) { ISHFileStream *This = (ISHFileStream *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->()\n",This); + TRACE("(%p)->(count=%lu)\n", This, refCount + 1); - if (!--(This->ref)) + if (!refCount) { TRACE(" destroying SHFileStream (%p)\n",This); CloseHandle(This->handle); HeapFree(GetProcessHeap(),0,This); } - return This->ref; + return refCount; } static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead) diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c index e0272646ecb..b7b379f81c5 100644 --- a/dlls/shell32/shelllink.c +++ b/dlls/shell32/shelllink.c @@ -974,10 +974,11 @@ static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface) { IShellLinkImpl *This = (IShellLinkImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(count=%lu)\n",This,This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } /****************************************************************************** * IShellLinkA_Release @@ -985,11 +986,12 @@ static ULONG WINAPI IShellLinkA_fnAddRef(IShellLinkA * iface) static ULONG WINAPI IShellLinkA_fnRelease(IShellLinkA * iface) { IShellLinkImpl *This = (IShellLinkImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->(count=%lu)\n",This,This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount + 1); - if (--(This->ref)) - return This->ref; + if (refCount) + return refCount; TRACE("-- destroying IShellLink(%p)\n",This); diff --git a/dlls/shell32/shellole.c b/dlls/shell32/shellole.c index 0167b16dc2f..ea74a9fa088 100644 --- a/dlls/shell32/shellole.c +++ b/dlls/shell32/shellole.c @@ -556,9 +556,11 @@ static HRESULT WINAPI IDefClF_fnQueryInterface( static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface) { IDefClFImpl *This = (IDefClFImpl *)iface; - TRACE("(%p)->(count=%lu)\n",This,This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); - return InterlockedIncrement(&This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); + + return refCount; } /****************************************************************************** * IDefClF_fnRelease @@ -566,9 +568,11 @@ static ULONG WINAPI IDefClF_fnAddRef(LPCLASSFACTORY iface) static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface) { IDefClFImpl *This = (IDefClFImpl *)iface; - TRACE("(%p)->(count=%lu)\n",This,This->ref); + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(count=%lu)\n", This, refCount + 1); - if (!InterlockedDecrement(&This->ref)) + if (!refCount) { if (This->pcRefDll) InterlockedDecrement(This->pcRefDll); @@ -576,7 +580,7 @@ static ULONG WINAPI IDefClF_fnRelease(LPCLASSFACTORY iface) HeapFree(GetProcessHeap(),0,This); return 0; } - return This->ref; + return refCount; } /****************************************************************************** * IDefClF_fnCreateInstance diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c index 66b4e8c5d16..e14dd087735 100644 --- a/dlls/shell32/shfldr_desktop.c +++ b/dlls/shell32/shfldr_desktop.c @@ -157,19 +157,21 @@ static HRESULT WINAPI ISF_Desktop_fnQueryInterface (IShellFolder2 * iface, REFII static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface) { IGenericSFImpl *This = (IGenericSFImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE ("(%p)->(count=%lu)\n", This, This->ref); + TRACE ("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface) { IGenericSFImpl *This = (IGenericSFImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE ("(%p)->(count=%lu)\n", This, This->ref); + TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); - if (!--(This->ref)) { + if (!refCount) { TRACE ("-- destroying IShellFolder(%p)\n", This); if (This->pidlRoot) SHFree (This->pidlRoot); @@ -178,7 +180,7 @@ static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface) LocalFree ((HLOCAL) This); return 0; } - return This->ref; + return refCount; } /************************************************************************** diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c index 858628540a4..e8fdca78b38 100644 --- a/dlls/shell32/shfldr_fs.c +++ b/dlls/shell32/shfldr_fs.c @@ -173,19 +173,21 @@ static HRESULT WINAPI IUnknown_fnQueryInterface (IUnknown * iface, REFIID riid, static ULONG WINAPI IUnknown_fnAddRef (IUnknown * iface) { IGenericSFImpl *This = (IGenericSFImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE ("(%p)->(count=%lu)\n", This, This->ref); + TRACE ("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } static ULONG WINAPI IUnknown_fnRelease (IUnknown * iface) { IGenericSFImpl *This = (IGenericSFImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE ("(%p)->(count=%lu)\n", This, This->ref); + TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); - if (!--(This->ref)) { + if (!refCount) { TRACE ("-- destroying IShellFolder(%p)\n", This); if (This->pidlRoot) @@ -193,9 +195,8 @@ static ULONG WINAPI IUnknown_fnRelease (IUnknown * iface) if (This->sPathTarget) SHFree (This->sPathTarget); LocalFree ((HLOCAL) This); - return 0; } - return This->ref; + return refCount; } static IUnknownVtbl unkvt = diff --git a/dlls/shell32/shfldr_mycomp.c b/dlls/shell32/shfldr_mycomp.c index 5de8574efcd..cacfcfbd68c 100644 --- a/dlls/shell32/shfldr_mycomp.c +++ b/dlls/shell32/shfldr_mycomp.c @@ -160,26 +160,27 @@ static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 * iface, RE static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface) { IGenericSFImpl *This = (IGenericSFImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE ("(%p)->(count=%lu)\n", This, This->ref); + TRACE ("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface) { IGenericSFImpl *This = (IGenericSFImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE ("(%p)->(count=%lu)\n", This, This->ref); + TRACE ("(%p)->(count=%lu)\n", This, refCount + 1); - if (!--(This->ref)) { + if (!refCount) { TRACE ("-- destroying IShellFolder(%p)\n", This); if (This->pidlRoot) SHFree (This->pidlRoot); LocalFree ((HLOCAL) This); - return 0; } - return This->ref; + return refCount; } /************************************************************************** diff --git a/dlls/shell32/shlfsbind.c b/dlls/shell32/shlfsbind.c index 14e1f3a811d..b558aeab3e1 100644 --- a/dlls/shell32/shlfsbind.c +++ b/dlls/shell32/shlfsbind.c @@ -179,22 +179,26 @@ static HRESULT WINAPI IFileSystemBindData_fnQueryInterface(IFileSystemBindData * static ULONG WINAPI IFileSystemBindData_fnAddRef(IFileSystemBindData *iface) { IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - TRACE("(%p)\n", This); - return InterlockedIncrement(&This->ref); + ULONG refCount = InterlockedIncrement(&This->ref); + + TRACE("(%p)->(count=%li)\n", This, refCount - 1); + + return refCount; } static ULONG WINAPI IFileSystemBindData_fnRelease(IFileSystemBindData *iface) { IFileSystemBindDataImpl *This = (IFileSystemBindDataImpl *)iface; - TRACE("(%p)\n", This); + ULONG refCount = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(count=%li)\n", This, refCount + 1); - if (!InterlockedDecrement(&This->ref)) + if (!refCount) { TRACE(" destroying ISFBindPidl(%p)\n",This); HeapFree(GetProcessHeap(), 0, This); - return 0; } - return This->ref; + return refCount; } static HRESULT WINAPI IFileSystemBindData_fnGetFindData(IFileSystemBindData *iface, WIN32_FIND_DATAW *pfd) diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c index f844edbabf6..c9181e7d501 100644 --- a/dlls/shell32/shlview.c +++ b/dlls/shell32/shlview.c @@ -1636,10 +1636,11 @@ static HRESULT WINAPI IShellView_fnQueryInterface(IShellView * iface,REFIID riid static ULONG WINAPI IShellView_fnAddRef(IShellView * iface) { IShellViewImpl *This = (IShellViewImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(count=%lu)\n",This,This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } /********************************************************** * IShellView_Release @@ -1647,10 +1648,11 @@ static ULONG WINAPI IShellView_fnAddRef(IShellView * iface) static ULONG WINAPI IShellView_fnRelease(IShellView * iface) { IShellViewImpl *This = (IShellViewImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->()\n",This); + TRACE("(%p)->(count=%li)\n", This, refCount + 1); - if (!--(This->ref)) + if (!refCount) { TRACE(" destroying IShellView(%p)\n",This); @@ -1666,9 +1668,8 @@ static ULONG WINAPI IShellView_fnRelease(IShellView * iface) SHFree(This->apidl); HeapFree(GetProcessHeap(),0,This); - return 0; } - return This->ref; + return refCount; } /********************************************************** diff --git a/dlls/shell32/shv_bg_cmenu.c b/dlls/shell32/shv_bg_cmenu.c index 9dd5dc6cb90..b879d180fa2 100644 --- a/dlls/shell32/shv_bg_cmenu.c +++ b/dlls/shell32/shv_bg_cmenu.c @@ -106,10 +106,11 @@ static HRESULT WINAPI ISVBgCm_fnQueryInterface(IContextMenu2 *iface, REFIID riid static ULONG WINAPI ISVBgCm_fnAddRef(IContextMenu2 *iface) { BgCmImpl *This = (BgCmImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(count=%lu)\n",This, This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } /************************************************************************** @@ -118,10 +119,11 @@ static ULONG WINAPI ISVBgCm_fnAddRef(IContextMenu2 *iface) static ULONG WINAPI ISVBgCm_fnRelease(IContextMenu2 *iface) { BgCmImpl *This = (BgCmImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->()\n",This); + TRACE("(%p)->(count=%li)\n", This, refCount + 1); - if (!--(This->ref)) + if (!refCount) { TRACE(" destroying IContextMenu(%p)\n",This); @@ -129,10 +131,8 @@ static ULONG WINAPI ISVBgCm_fnRelease(IContextMenu2 *iface) IShellFolder_Release(This->pSFParent); HeapFree(GetProcessHeap(),0,This); - return 0; } - - return This->ref; + return refCount; } /************************************************************************** diff --git a/dlls/shell32/shv_item_cmenu.c b/dlls/shell32/shv_item_cmenu.c index 96584068191..9aedddd735b 100644 --- a/dlls/shell32/shv_item_cmenu.c +++ b/dlls/shell32/shv_item_cmenu.c @@ -142,10 +142,11 @@ static HRESULT WINAPI ISvItemCm_fnQueryInterface(IContextMenu2 *iface, REFIID ri static ULONG WINAPI ISvItemCm_fnAddRef(IContextMenu2 *iface) { ItemCmImpl *This = (ItemCmImpl *)iface; + ULONG refCount = InterlockedIncrement(&This->ref); - TRACE("(%p)->(count=%lu)\n",This, This->ref); + TRACE("(%p)->(count=%lu)\n", This, refCount - 1); - return ++(This->ref); + return refCount; } /************************************************************************** @@ -154,10 +155,11 @@ static ULONG WINAPI ISvItemCm_fnAddRef(IContextMenu2 *iface) static ULONG WINAPI ISvItemCm_fnRelease(IContextMenu2 *iface) { ItemCmImpl *This = (ItemCmImpl *)iface; + ULONG refCount = InterlockedDecrement(&This->ref); - TRACE("(%p)->()\n",This); + TRACE("(%p)->(count=%li)\n", This, refCount + 1); - if (!--(This->ref)) + if (!refCount) { TRACE(" destroying IContextMenu(%p)\n",This); @@ -171,9 +173,8 @@ static ULONG WINAPI ISvItemCm_fnRelease(IContextMenu2 *iface) _ILFreeaPidl(This->apidl, This->cidl); HeapFree(GetProcessHeap(),0,This); - return 0; } - return This->ref; + return refCount; } /**************************************************************************