- use Interlocked* functions in AddRef and Release.

- store the result of the Interlocked functions and use only this.
This commit is contained in:
Paul Vriens 2005-01-12 19:26:42 +00:00 committed by Alexandre Julliard
parent 1bc887bcbe
commit b2bb57a484
4 changed files with 28 additions and 16 deletions

View File

@ -54,17 +54,20 @@ HRESULT WINAPI IDirectMusicChordMapImpl_IUnknown_QueryInterface (LPUNKNOWN iface
ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_AddRef (LPUNKNOWN iface) { ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_AddRef (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, 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(); DMCOMPOS_LockModule();
return ++(This->ref); return ref;
} }
ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_Release (LPUNKNOWN iface) { ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_Release (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface); ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface);
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
TRACE("(%p): ReleaseRef to %ld\n", This, ref);
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);

View File

@ -51,17 +51,20 @@ HRESULT WINAPI IDirectMusicChordMapTrack_IUnknown_QueryInterface (LPUNKNOWN ifac
ULONG WINAPI IDirectMusicChordMapTrack_IUnknown_AddRef (LPUNKNOWN iface) { ULONG WINAPI IDirectMusicChordMapTrack_IUnknown_AddRef (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicChordMapTrack, UnknownVtbl, 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(); DMCOMPOS_LockModule();
return ++(This->ref); return ref;
} }
ULONG WINAPI IDirectMusicChordMapTrack_IUnknown_Release (LPUNKNOWN iface) { ULONG WINAPI IDirectMusicChordMapTrack_IUnknown_Release (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicChordMapTrack, UnknownVtbl, iface); ICOM_THIS_MULTI(IDirectMusicChordMapTrack, UnknownVtbl, iface);
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
TRACE("(%p): ReleaseRef to %ld\n", This, ref);
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);

View File

@ -38,17 +38,20 @@ HRESULT WINAPI IDirectMusicComposerImpl_QueryInterface (LPDIRECTMUSICCOMPOSER if
ULONG WINAPI IDirectMusicComposerImpl_AddRef (LPDIRECTMUSICCOMPOSER iface) { ULONG WINAPI IDirectMusicComposerImpl_AddRef (LPDIRECTMUSICCOMPOSER iface) {
IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)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(); DMCOMPOS_LockModule();
return ++(This->ref); return ref;
} }
ULONG WINAPI IDirectMusicComposerImpl_Release (LPDIRECTMUSICCOMPOSER iface) { ULONG WINAPI IDirectMusicComposerImpl_Release (LPDIRECTMUSICCOMPOSER iface) {
IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface; IDirectMusicComposerImpl *This = (IDirectMusicComposerImpl *)iface;
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
TRACE("(%p): ReleaseRef to %ld\n", This, ref);
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);

View File

@ -51,17 +51,20 @@ HRESULT WINAPI IDirectMusicSignPostTrack_IUnknown_QueryInterface (LPUNKNOWN ifac
ULONG WINAPI IDirectMusicSignPostTrack_IUnknown_AddRef (LPUNKNOWN iface) { ULONG WINAPI IDirectMusicSignPostTrack_IUnknown_AddRef (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicSignPostTrack, UnknownVtbl, 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(); DMCOMPOS_LockModule();
return ++(This->ref); return ref;
} }
ULONG WINAPI IDirectMusicSignPostTrack_IUnknown_Release (LPUNKNOWN iface) { ULONG WINAPI IDirectMusicSignPostTrack_IUnknown_Release (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicSignPostTrack, UnknownVtbl, iface); ICOM_THIS_MULTI(IDirectMusicSignPostTrack, UnknownVtbl, iface);
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
TRACE("(%p): ReleaseRef to %ld\n", This, ref);
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);