[D3DX8] Use Interlocked* functions in AddRef and Release
Paul Vriens
Paul.Vriens at xs4all.nl
Fri Jan 21 01:52:28 CST 2005
Hi,
my install works again :-), so here's the next one.
Wherever possible, I changed the TRACE's not to contain This->*ref*
(without changing the text-part).
Changelog:
- use Interlocked* functions in AddRef and Release.
- store the result of the Interlocked functions and use only this.
Cheers,
Paul Vriens
Index: dlls/d3dx8/d3dxbuffer.c
===================================================================
RCS file: /home/wine/wine/dlls/d3dx8/d3dxbuffer.c,v
retrieving revision 1.6
diff -u -p -r1.6 d3dxbuffer.c
--- dlls/d3dx8/d3dxbuffer.c 23 Dec 2004 18:33:45 -0000 1.6
+++ dlls/d3dx8/d3dxbuffer.c 21 Jan 2005 07:35:40 -0000
@@ -51,14 +51,19 @@ HRESULT WINAPI ID3DXBufferImpl_QueryInte
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);
More information about the wine-patches
mailing list