Commit 11db0ea6 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

Use only stored result of Interlocked* in AddRef/Release.

parent 452491bd
......@@ -2998,21 +2998,24 @@ HRESULT WINAPI IWineD3DDeviceImpl_QueryInterface(IWineD3DDevice *iface,REFIID ri
ULONG WINAPI IWineD3DDeviceImpl_AddRef(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : AddRef increasing from %ld\n", This, This->ref);
return InterlockedIncrement(&This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef increasing from %ld\n", This, refCount - 1);
return refCount;
}
ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %ld\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : Releasing from %ld\n", This, refCount + 1);
if (!refCount) {
IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
IWineD3D_Release(This->wineD3D);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
return refCount;
}
/**********************************************************
......
......@@ -1613,17 +1613,20 @@ HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface,REFIID riid,LPVOID *p
ULONG WINAPI IWineD3DImpl_AddRef(IWineD3D *iface) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE("(%p) : AddRef increasing from %ld\n", This, This->ref);
return InterlockedIncrement(&This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef increasing from %ld\n", This, refCount - 1);
return refCount;
}
ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %ld\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) HeapFree(GetProcessHeap(), 0, This);
return ref;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : Releasing from %ld\n", This, refCount + 1);
if (!refCount) HeapFree(GetProcessHeap(), 0, This);
return refCount;
}
/**********************************************************
......
......@@ -262,20 +262,23 @@ HRESULT WINAPI IWineD3DStateBlockImpl_QueryInterface(IWineD3DStateBlock *iface,R
ULONG WINAPI IWineD3DStateBlockImpl_AddRef(IWineD3DStateBlock *iface) {
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
TRACE("(%p) : AddRef increasing from %ld\n", This, This->ref);
return InterlockedIncrement(&This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p) : AddRef increasing from %ld\n", This, refCount - 1);
return refCount;
}
ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %ld\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) : Releasing from %ld\n", This, refCount + 1);
if (!refCount) {
IWineD3DDevice_Release((IWineD3DDevice *)This->wineD3DDevice);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
return refCount;
}
/**********************************************************
......
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