Commit 7f07b006 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 e1ff586d
...@@ -80,23 +80,24 @@ static HRESULT WINAPI IDirectXFileImpl_QueryInterface(IDirectXFile* iface, REFII ...@@ -80,23 +80,24 @@ static HRESULT WINAPI IDirectXFileImpl_QueryInterface(IDirectXFile* iface, REFII
static ULONG WINAPI IDirectXFileImpl_AddRef(IDirectXFile* iface) static ULONG WINAPI IDirectXFileImpl_AddRef(IDirectXFile* iface)
{ {
IDirectXFileImpl *This = (IDirectXFileImpl *)iface; IDirectXFileImpl *This = (IDirectXFileImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): AddRef from %ld\n", iface, This, ref - 1);
This->ref++; return ref;
return S_OK;
} }
static ULONG WINAPI IDirectXFileImpl_Release(IDirectXFile* iface) static ULONG WINAPI IDirectXFileImpl_Release(IDirectXFile* iface)
{ {
IDirectXFileImpl *This = (IDirectXFileImpl *)iface; IDirectXFileImpl *This = (IDirectXFileImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): ReleaseRef to %ld\n", iface, This, ref);
if (!--This->ref) if (!ref)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return S_OK; return ref;
} }
/*** IDirectXFile methods ***/ /*** IDirectXFile methods ***/
...@@ -190,23 +191,24 @@ static HRESULT WINAPI IDirectXFileBinaryImpl_QueryInterface(IDirectXFileBinary* ...@@ -190,23 +191,24 @@ static HRESULT WINAPI IDirectXFileBinaryImpl_QueryInterface(IDirectXFileBinary*
static ULONG WINAPI IDirectXFileBinaryImpl_AddRef(IDirectXFileBinary* iface) static ULONG WINAPI IDirectXFileBinaryImpl_AddRef(IDirectXFileBinary* iface)
{ {
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface; IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): AddRef from %ld\n", iface, This, ref - 1);
This->ref++; return ref;
return S_OK;
} }
static ULONG WINAPI IDirectXFileBinaryImpl_Release(IDirectXFileBinary* iface) static ULONG WINAPI IDirectXFileBinaryImpl_Release(IDirectXFileBinary* iface)
{ {
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface; IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): ReleaseRef to %ld\n", iface, This, ref);
if (!--This->ref) if (!ref)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return S_OK; return ref;
} }
/*** IDirectXFileObject methods ***/ /*** IDirectXFileObject methods ***/
...@@ -308,23 +310,24 @@ static HRESULT WINAPI IDirectXFileDataImpl_QueryInterface(IDirectXFileData* ifac ...@@ -308,23 +310,24 @@ static HRESULT WINAPI IDirectXFileDataImpl_QueryInterface(IDirectXFileData* ifac
static ULONG WINAPI IDirectXFileDataImpl_AddRef(IDirectXFileData* iface) static ULONG WINAPI IDirectXFileDataImpl_AddRef(IDirectXFileData* iface)
{ {
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface; IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): AddRef from %ld\n", iface, This, ref - 1);
This->ref++; return ref;
return S_OK;
} }
static ULONG WINAPI IDirectXFileDataImpl_Release(IDirectXFileData* iface) static ULONG WINAPI IDirectXFileDataImpl_Release(IDirectXFileData* iface)
{ {
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface; IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): ReleaseRef to %ld\n", iface, This, ref);
if (!--This->ref) if (!ref)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return S_OK; return ref;
} }
/*** IDirectXFileObject methods ***/ /*** IDirectXFileObject methods ***/
...@@ -456,23 +459,24 @@ static HRESULT WINAPI IDirectXFileDataReferenceImpl_QueryInterface(IDirectXFileD ...@@ -456,23 +459,24 @@ static HRESULT WINAPI IDirectXFileDataReferenceImpl_QueryInterface(IDirectXFileD
static ULONG WINAPI IDirectXFileDataReferenceImpl_AddRef(IDirectXFileDataReference* iface) static ULONG WINAPI IDirectXFileDataReferenceImpl_AddRef(IDirectXFileDataReference* iface)
{ {
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface; IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): AddRef from %ld\n", iface, This, ref - 1);
This->ref++; return ref;
return S_OK;
} }
static ULONG WINAPI IDirectXFileDataReferenceImpl_Release(IDirectXFileDataReference* iface) static ULONG WINAPI IDirectXFileDataReferenceImpl_Release(IDirectXFileDataReference* iface)
{ {
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface; IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): ReleaseRef to %ld\n", iface, This, ref);
if (!--This->ref) if (!ref)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return S_OK; return ref;
} }
/*** IDirectXFileObject methods ***/ /*** IDirectXFileObject methods ***/
...@@ -552,23 +556,24 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_QueryInterface(IDirectXFileEnum ...@@ -552,23 +556,24 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_QueryInterface(IDirectXFileEnum
static ULONG WINAPI IDirectXFileEnumObjectImpl_AddRef(IDirectXFileEnumObject* iface) static ULONG WINAPI IDirectXFileEnumObjectImpl_AddRef(IDirectXFileEnumObject* iface)
{ {
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface; IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): AddRef from %ld\n", iface, This, ref - 1);
This->ref++; return ref;
return S_OK;
} }
static ULONG WINAPI IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject* iface) static ULONG WINAPI IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject* iface)
{ {
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface; IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): ReleaseRef to %ld\n", iface, This, ref);
if (!--This->ref) if (!ref)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return S_OK; return ref;
} }
/*** IDirectXFileEnumObject methods ***/ /*** IDirectXFileEnumObject methods ***/
...@@ -655,23 +660,24 @@ static HRESULT WINAPI IDirectXFileObjectImpl_QueryInterface(IDirectXFileObject* ...@@ -655,23 +660,24 @@ static HRESULT WINAPI IDirectXFileObjectImpl_QueryInterface(IDirectXFileObject*
static ULONG WINAPI IDirectXFileObjectImpl_AddRef(IDirectXFileObject* iface) static ULONG WINAPI IDirectXFileObjectImpl_AddRef(IDirectXFileObject* iface)
{ {
IDirectXFileObjectImpl *This = (IDirectXFileObjectImpl *)iface; IDirectXFileObjectImpl *This = (IDirectXFileObjectImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): AddRef from %ld\n", iface, This, ref - 1);
This->ref++; return ref;
return S_OK;
} }
static ULONG WINAPI IDirectXFileObjectImpl_Release(IDirectXFileObject* iface) static ULONG WINAPI IDirectXFileObjectImpl_Release(IDirectXFileObject* iface)
{ {
IDirectXFileObjectImpl *This = (IDirectXFileObjectImpl *)iface; IDirectXFileObjectImpl *This = (IDirectXFileObjectImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): ReleaseRef to %ld\n", iface, This, ref);
if (!--This->ref) if (!ref)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return S_OK; return ref;
} }
/*** IDirectXFileObject methods ***/ /*** IDirectXFileObject methods ***/
...@@ -740,23 +746,24 @@ static HRESULT WINAPI IDirectXFileSaveObjectImpl_QueryInterface(IDirectXFileSave ...@@ -740,23 +746,24 @@ static HRESULT WINAPI IDirectXFileSaveObjectImpl_QueryInterface(IDirectXFileSave
static ULONG WINAPI IDirectXFileSaveObjectImpl_AddRef(IDirectXFileSaveObject* iface) static ULONG WINAPI IDirectXFileSaveObjectImpl_AddRef(IDirectXFileSaveObject* iface)
{ {
IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface; IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): AddRef from %ld\n", iface, This, ref - 1);
This->ref++; return ref;
return S_OK;
} }
static ULONG WINAPI IDirectXFileSaveObjectImpl_Release(IDirectXFileSaveObject* iface) static ULONG WINAPI IDirectXFileSaveObjectImpl_Release(IDirectXFileSaveObject* iface)
{ {
IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface; IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)\n", iface, This); TRACE("(%p/%p): ReleaseRef to %ld\n", iface, This, ref);
if (!--This->ref) if (!ref)
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return S_OK; return ref;
} }
static HRESULT WINAPI IDirectXFileSaveObjectImpl_SaveTemplates(IDirectXFileSaveObject* iface, DWORD cTemplates, const GUID** ppguidTemplates) static HRESULT WINAPI IDirectXFileSaveObjectImpl_SaveTemplates(IDirectXFileSaveObject* iface, DWORD cTemplates, const GUID** ppguidTemplates)
......
...@@ -35,37 +35,37 @@ ...@@ -35,37 +35,37 @@
typedef struct { typedef struct {
IDirectXFile lpVtbl; IDirectXFile lpVtbl;
int ref; ULONG ref;
} IDirectXFileImpl; } IDirectXFileImpl;
typedef struct { typedef struct {
IDirectXFileBinary lpVtbl; IDirectXFileBinary lpVtbl;
int ref; ULONG ref;
} IDirectXFileBinaryImpl; } IDirectXFileBinaryImpl;
typedef struct { typedef struct {
IDirectXFileData lpVtbl; IDirectXFileData lpVtbl;
int ref; ULONG ref;
} IDirectXFileDataImpl; } IDirectXFileDataImpl;
typedef struct { typedef struct {
IDirectXFileDataReference lpVtbl; IDirectXFileDataReference lpVtbl;
int ref; ULONG ref;
} IDirectXFileDataReferenceImpl; } IDirectXFileDataReferenceImpl;
typedef struct { typedef struct {
IDirectXFileObject lpVtbl; IDirectXFileObject lpVtbl;
int ref; ULONG ref;
} IDirectXFileObjectImpl; } IDirectXFileObjectImpl;
typedef struct { typedef struct {
IDirectXFileEnumObject lpVtbl; IDirectXFileEnumObject lpVtbl;
int ref; ULONG ref;
} IDirectXFileEnumObjectImpl; } IDirectXFileEnumObjectImpl;
typedef struct { typedef struct {
IDirectXFileSaveObject lpVtbl; IDirectXFileSaveObject lpVtbl;
int ref; ULONG ref;
} IDirectXFileSaveObjectImpl; } IDirectXFileSaveObjectImpl;
HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, LPVOID *ppObj); HRESULT IDirectXFileImpl_Create(IUnknown *pUnkOuter, 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