Commit 7b6b24d8 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

- Use Interlocked* functions in AddRef and Release.

- Store the result of the Interlocked functions and use only this.
parent eb23257b
......@@ -51,14 +51,19 @@ HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, L
ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface) {
ID3DXBufferImpl *This = (ID3DXBufferImpl *)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 ID3DXBufferImpl_Release(LPD3DXBUFFER iface) {
ID3DXBufferImpl *This = (ID3DXBufferImpl *)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->buffer);
HeapFree(GetProcessHeap(), 0, This);
......
......@@ -56,14 +56,19 @@ HRESULT WINAPI IDirectMusicBandImpl_IUnknown_QueryInterface (LPUNKNOWN iface, RE
ULONG WINAPI IDirectMusicBandImpl_IUnknown_AddRef (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicBandImpl, 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 IDirectMusicBandImpl_IUnknown_Release (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicBandImpl, 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);
}
......
......@@ -51,14 +51,19 @@ HRESULT WINAPI IDirectMusicBandTrack_IUnknown_QueryInterface (LPUNKNOWN iface, R
ULONG WINAPI IDirectMusicBandTrack_IUnknown_AddRef (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicBandTrack, 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 IDirectMusicBandTrack_IUnknown_Release (LPUNKNOWN iface) {
ICOM_THIS_MULTI(IDirectMusicBandTrack, 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);
}
......
......@@ -39,13 +39,13 @@ static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPV
static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */
return --(This->ref);
return InterlockedDecrement(&This->ref);
}
static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
......@@ -84,13 +84,13 @@ static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID rii
static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */
return --(This->ref);
return InterlockedDecrement(&This->ref);
}
static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment