Commit 36482273 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

Use InterlockedDecrement and InterlockedIncrement instead of ++/--.

parent a1ccb921
...@@ -529,9 +529,7 @@ ULONG WINAPI OLEFontImpl_AddRef( ...@@ -529,9 +529,7 @@ ULONG WINAPI OLEFontImpl_AddRef(
{ {
OLEFontImpl *this = (OLEFontImpl *)iface; OLEFontImpl *this = (OLEFontImpl *)iface;
TRACE("(%p)->(ref=%ld)\n", this, this->ref); TRACE("(%p)->(ref=%ld)\n", this, this->ref);
this->ref++; return InterlockedIncrement(&this->ref);
return this->ref;
} }
/************************************************************************ /************************************************************************
...@@ -543,24 +541,20 @@ ULONG WINAPI OLEFontImpl_Release( ...@@ -543,24 +541,20 @@ ULONG WINAPI OLEFontImpl_Release(
IFont* iface) IFont* iface)
{ {
OLEFontImpl *this = (OLEFontImpl *)iface; OLEFontImpl *this = (OLEFontImpl *)iface;
ULONG ret;
TRACE("(%p)->(ref=%ld)\n", this, this->ref); TRACE("(%p)->(ref=%ld)\n", this, this->ref);
/* /*
* Decrease the reference count on this object. * Decrease the reference count on this object.
*/ */
this->ref--; ret = InterlockedDecrement(&this->ref);
/* /*
* If the reference count goes down to 0, perform suicide. * If the reference count goes down to 0, perform suicide.
*/ */
if (this->ref==0) if (ret==0) OLEFontImpl_Destroy(this);
{
OLEFontImpl_Destroy(this);
return 0;
}
return this->ref; return ret;
} }
/************************************************************************ /************************************************************************
...@@ -2087,13 +2081,13 @@ SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { ...@@ -2087,13 +2081,13 @@ SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
static ULONG WINAPI static ULONG WINAPI
SFCF_AddRef(LPCLASSFACTORY iface) { SFCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */ /* static class, won't be freed */
return --(This->ref); return InterlockedDecrement(&This->ref);
} }
static HRESULT WINAPI SFCF_CreateInstance( static HRESULT WINAPI SFCF_CreateInstance(
......
...@@ -402,9 +402,7 @@ static ULONG WINAPI OLEPictureImpl_AddRef( ...@@ -402,9 +402,7 @@ static ULONG WINAPI OLEPictureImpl_AddRef(
{ {
OLEPictureImpl *This = (OLEPictureImpl *)iface; OLEPictureImpl *This = (OLEPictureImpl *)iface;
TRACE("(%p)->(ref=%ld)\n", This, This->ref); TRACE("(%p)->(ref=%ld)\n", This, This->ref);
This->ref++; return InterlockedIncrement(&This->ref);
return This->ref;
} }
/************************************************************************ /************************************************************************
...@@ -416,24 +414,20 @@ static ULONG WINAPI OLEPictureImpl_Release( ...@@ -416,24 +414,20 @@ static ULONG WINAPI OLEPictureImpl_Release(
IPicture* iface) IPicture* iface)
{ {
OLEPictureImpl *This = (OLEPictureImpl *)iface; OLEPictureImpl *This = (OLEPictureImpl *)iface;
ULONG ret;
TRACE("(%p)->(ref=%ld)\n", This, This->ref); TRACE("(%p)->(ref=%ld)\n", This, This->ref);
/* /*
* Decrease the reference count on this object. * Decrease the reference count on this object.
*/ */
This->ref--; ret = InterlockedDecrement(&This->ref);
/* /*
* If the reference count goes down to 0, perform suicide. * If the reference count goes down to 0, perform suicide.
*/ */
if (This->ref==0) if (ret==0) OLEPictureImpl_Destroy(This);
{
OLEPictureImpl_Destroy(This);
return 0;
}
return This->ref; return ret;
} }
...@@ -1691,13 +1685,13 @@ SPCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { ...@@ -1691,13 +1685,13 @@ SPCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
static ULONG WINAPI static ULONG WINAPI
SPCF_AddRef(LPCLASSFACTORY iface) { SPCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface) { static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface; IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */ /* static class, won't be freed */
return --(This->ref); return InterlockedDecrement(&This->ref);
} }
static HRESULT WINAPI SPCF_CreateInstance( static HRESULT WINAPI SPCF_CreateInstance(
......
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