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

This commit is contained in:
James Hawkins 2004-09-21 00:25:03 +00:00 committed by Alexandre Julliard
parent a1ccb921bd
commit 364822739f
2 changed files with 14 additions and 26 deletions

View File

@ -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(
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 ret;
}
return this->ref;
} }
/************************************************************************ /************************************************************************
@ -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(

View File

@ -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(
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 ret;
}
return This->ref;
} }
@ -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(