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

View File

@ -402,9 +402,7 @@ static ULONG WINAPI OLEPictureImpl_AddRef(
{
OLEPictureImpl *This = (OLEPictureImpl *)iface;
TRACE("(%p)->(ref=%ld)\n", This, This->ref);
This->ref++;
return This->ref;
return InterlockedIncrement(&This->ref);
}
/************************************************************************
@ -416,24 +414,20 @@ static ULONG WINAPI OLEPictureImpl_Release(
IPicture* iface)
{
OLEPictureImpl *This = (OLEPictureImpl *)iface;
ULONG ret;
TRACE("(%p)->(ref=%ld)\n", This, This->ref);
/*
* Decrease the reference count on this object.
*/
This->ref--;
ret = InterlockedDecrement(&This->ref);
/*
* If the reference count goes down to 0, perform suicide.
*/
if (This->ref==0)
{
OLEPictureImpl_Destroy(This);
if (ret==0) OLEPictureImpl_Destroy(This);
return 0;
}
return This->ref;
return ret;
}
@ -1691,13 +1685,13 @@ SPCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
static ULONG WINAPI
SPCF_AddRef(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI SPCF_Release(LPCLASSFACTORY iface) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
/* static class, won't be freed */
return --(This->ref);
return InterlockedDecrement(&This->ref);
}
static HRESULT WINAPI SPCF_CreateInstance(