Commit 34cffce6 authored by Joris Huizer's avatar Joris Huizer Committed by Alexandre Julliard

Ref count increment/decrement cleanup.

parent 0c3f2868
...@@ -186,7 +186,7 @@ ULONG WINAPI AntiMonikerImpl_AddRef(IMoniker* iface) ...@@ -186,7 +186,7 @@ ULONG WINAPI AntiMonikerImpl_AddRef(IMoniker* iface)
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -195,19 +195,16 @@ ULONG WINAPI AntiMonikerImpl_AddRef(IMoniker* iface) ...@@ -195,19 +195,16 @@ ULONG WINAPI AntiMonikerImpl_AddRef(IMoniker* iface)
ULONG WINAPI AntiMonikerImpl_Release(IMoniker* iface) ULONG WINAPI AntiMonikerImpl_Release(IMoniker* iface)
{ {
AntiMonikerImpl *This = (AntiMonikerImpl *)iface; AntiMonikerImpl *This = (AntiMonikerImpl *)iface;
ULONG ref;
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref--; ref = InterlockedDecrement(&This->ref);
/* destroy the object if there's no more reference on it */ /* destroy the object if there's no more reference on it */
if (This->ref==0){ if (ref == 0) AntiMonikerImpl_Destroy(This);
AntiMonikerImpl_Destroy(This); return ref;
return 0;
}
return This->ref;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -142,7 +142,7 @@ ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface) ...@@ -142,7 +142,7 @@ ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface)
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -151,21 +151,19 @@ ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface) ...@@ -151,21 +151,19 @@ ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface)
ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface) ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
{ {
BindCtxImpl *This = (BindCtxImpl *)iface; BindCtxImpl *This = (BindCtxImpl *)iface;
ULONG ref;
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref--; ref = InterlockedDecrement(&This->ref);
if (This->ref==0){
if (ref == 0){
/* release all registered objects */ /* release all registered objects */
BindCtxImpl_ReleaseBoundObjects((IBindCtx*)This); BindCtxImpl_ReleaseBoundObjects((IBindCtx*)This);
BindCtxImpl_Destroy(This); BindCtxImpl_Destroy(This);
return 0;
} }
return This->ref; return ref;
} }
......
...@@ -1162,9 +1162,8 @@ static ULONG WINAPI OLEClipbrd_IDataObject_AddRef( ...@@ -1162,9 +1162,8 @@ static ULONG WINAPI OLEClipbrd_IDataObject_AddRef(
TRACE("(%p)->(count=%lu)\n",This, This->ref); TRACE("(%p)->(count=%lu)\n",This, This->ref);
This->ref++; return InterlockedIncrement(&This->ref);
return This->ref;
} }
/************************************************************************ /************************************************************************
...@@ -1179,23 +1178,24 @@ static ULONG WINAPI OLEClipbrd_IDataObject_Release( ...@@ -1179,23 +1178,24 @@ static ULONG WINAPI OLEClipbrd_IDataObject_Release(
* Declare "This" pointer * Declare "This" pointer
*/ */
OLEClipbrd *This = (OLEClipbrd *)iface; OLEClipbrd *This = (OLEClipbrd *)iface;
ULONG ref;
TRACE("(%p)->(count=%lu)\n",This, This->ref); TRACE("(%p)->(count=%lu)\n",This, This->ref);
/* /*
* Decrease the reference count on this object. * Decrease the reference count on this object.
*/ */
This->ref--; ref = 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 (ref == 0)
{ {
OLEClipbrd_Destroy(This); OLEClipbrd_Destroy(This);
} }
return This->ref; return ref;
} }
...@@ -1651,7 +1651,7 @@ static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_AddRef(LPENUMFORMATETC iface) ...@@ -1651,7 +1651,7 @@ static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_AddRef(LPENUMFORMATETC iface)
if (This->pUnkDataObj) if (This->pUnkDataObj)
IUnknown_AddRef(This->pUnkDataObj); IUnknown_AddRef(This->pUnkDataObj);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/************************************************************************ /************************************************************************
...@@ -1663,13 +1663,15 @@ static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_Release(LPENUMFORMATETC iface) ...@@ -1663,13 +1663,15 @@ static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_Release(LPENUMFORMATETC iface)
{ {
IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface; IEnumFORMATETCImpl *This = (IEnumFORMATETCImpl *)iface;
LPMALLOC pIMalloc; LPMALLOC pIMalloc;
ULONG ref;
TRACE("(%p)->(count=%lu)\n",This, This->ref); TRACE("(%p)->(count=%lu)\n",This, This->ref);
if (This->pUnkDataObj) if (This->pUnkDataObj)
IUnknown_Release(This->pUnkDataObj); /* Release parent data object */ IUnknown_Release(This->pUnkDataObj); /* Release parent data object */
if (!--(This->ref)) ref = InterlockedDecrement(&This->ref);
if (!ref)
{ {
TRACE("() - destroying IEnumFORMATETC(%p)\n",This); TRACE("() - destroying IEnumFORMATETC(%p)\n",This);
if (SUCCEEDED(CoGetMalloc(MEMCTX_TASK, &pIMalloc))) if (SUCCEEDED(CoGetMalloc(MEMCTX_TASK, &pIMalloc)))
...@@ -1679,10 +1681,8 @@ static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_Release(LPENUMFORMATETC iface) ...@@ -1679,10 +1681,8 @@ static ULONG WINAPI OLEClipbrd_IEnumFORMATETC_Release(LPENUMFORMATETC iface)
} }
HeapFree(GetProcessHeap(),0,This); HeapFree(GetProcessHeap(),0,This);
return 0;
} }
return ref;
return This->ref;
} }
/************************************************************************ /************************************************************************
......
...@@ -243,7 +243,7 @@ ULONG WINAPI CompositeMonikerImpl_AddRef(IMoniker* iface) ...@@ -243,7 +243,7 @@ ULONG WINAPI CompositeMonikerImpl_AddRef(IMoniker* iface)
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -253,23 +253,22 @@ ULONG WINAPI CompositeMonikerImpl_Release(IMoniker* iface) ...@@ -253,23 +253,22 @@ ULONG WINAPI CompositeMonikerImpl_Release(IMoniker* iface)
{ {
CompositeMonikerImpl *This = (CompositeMonikerImpl *)iface; CompositeMonikerImpl *This = (CompositeMonikerImpl *)iface;
ULONG i; ULONG i;
ULONG ref;
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref--; ref = InterlockedDecrement(&This->ref);
/* destroy the object if there's no more reference on it */ /* destroy the object if there's no more reference on it */
if (This->ref==0){ if (ref == 0){
/* release all the components before destroying this object */ /* release all the components before destroying this object */
for (i=0;i<This->tabLastIndex;i++) for (i=0;i<This->tabLastIndex;i++)
IMoniker_Release(This->tabMoniker[i]); IMoniker_Release(This->tabMoniker[i]);
CompositeMonikerImpl_Destroy(This); CompositeMonikerImpl_Destroy(This);
return 0;
} }
return This->ref; return ref;
} }
/****************************************************************************** /******************************************************************************
...@@ -1527,7 +1526,7 @@ ULONG WINAPI EnumMonikerImpl_AddRef(IEnumMoniker* iface) ...@@ -1527,7 +1526,7 @@ ULONG WINAPI EnumMonikerImpl_AddRef(IEnumMoniker* iface)
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
...@@ -1537,24 +1536,22 @@ ULONG WINAPI EnumMonikerImpl_AddRef(IEnumMoniker* iface) ...@@ -1537,24 +1536,22 @@ ULONG WINAPI EnumMonikerImpl_AddRef(IEnumMoniker* iface)
ULONG WINAPI EnumMonikerImpl_Release(IEnumMoniker* iface) ULONG WINAPI EnumMonikerImpl_Release(IEnumMoniker* iface)
{ {
EnumMonikerImpl *This = (EnumMonikerImpl *)iface; EnumMonikerImpl *This = (EnumMonikerImpl *)iface;
ULONG i ULONG i;
; ULONG ref;
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref--; ref = InterlockedDecrement(&This->ref);
/* destroy the object if there's no more reference on it */ /* destroy the object if there's no more reference on it */
if (This->ref==0){ if (ref == 0) {
for(i=0;i<This->tabSize;i++) for(i=0;i<This->tabSize;i++)
IMoniker_Release(This->tabMoniker[i]); IMoniker_Release(This->tabMoniker[i]);
HeapFree(GetProcessHeap(),0,This->tabMoniker); HeapFree(GetProcessHeap(),0,This->tabMoniker);
HeapFree(GetProcessHeap(),0,This); HeapFree(GetProcessHeap(),0,This);
return 0;
} }
return This->ref; return ref;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -134,12 +134,12 @@ typedef struct DataCache DataCache; ...@@ -134,12 +134,12 @@ typedef struct DataCache DataCache;
* There is a version to accomodate all of the VTables implemented * There is a version to accomodate all of the VTables implemented
* by this object. * by this object.
*/ */
#define _ICOM_THIS_From_IDataObject(class,name) class* this = (class*)name; #define _ICOM_THIS_From_IDataObject(class,name) class* this = (class*)name
#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
#define _ICOM_THIS_From_IPersistStorage(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); #define _ICOM_THIS_From_IPersistStorage(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
#define _ICOM_THIS_From_IViewObject2(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); #define _ICOM_THIS_From_IViewObject2(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
#define _ICOM_THIS_From_IOleCache2(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*)); #define _ICOM_THIS_From_IOleCache2(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*))
#define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*)); #define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*))
/* /*
* Prototypes for the methods of the DataCache class. * Prototypes for the methods of the DataCache class.
...@@ -968,10 +968,7 @@ static ULONG WINAPI DataCache_NDIUnknown_AddRef( ...@@ -968,10 +968,7 @@ static ULONG WINAPI DataCache_NDIUnknown_AddRef(
IUnknown* iface) IUnknown* iface)
{ {
_ICOM_THIS_From_NDIUnknown(DataCache, iface); _ICOM_THIS_From_NDIUnknown(DataCache, iface);
return InterlockedIncrement(&this->ref);
this->ref++;
return this->ref;
} }
/************************************************************************ /************************************************************************
...@@ -986,23 +983,19 @@ static ULONG WINAPI DataCache_NDIUnknown_Release( ...@@ -986,23 +983,19 @@ static ULONG WINAPI DataCache_NDIUnknown_Release(
IUnknown* iface) IUnknown* iface)
{ {
_ICOM_THIS_From_NDIUnknown(DataCache, iface); _ICOM_THIS_From_NDIUnknown(DataCache, iface);
ULONG ref;
/* /*
* Decrease the reference count on this object. * Decrease the reference count on this object.
*/ */
this->ref--; ref = 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 (ref == 0) DataCache_Destroy(this);
{
DataCache_Destroy(this);
return 0;
}
return this->ref; return ref;
} }
/********************************************************* /*********************************************************
......
...@@ -126,10 +126,10 @@ typedef struct DefaultHandler DefaultHandler; ...@@ -126,10 +126,10 @@ typedef struct DefaultHandler DefaultHandler;
* There is a version to accomodate all of the VTables implemented * There is a version to accomodate all of the VTables implemented
* by this object. * by this object.
*/ */
#define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name; #define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name
#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); #define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
#define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); #define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
#define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); #define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
/* /*
* Prototypes for the methods of the DefaultHandler class. * Prototypes for the methods of the DefaultHandler class.
...@@ -656,10 +656,7 @@ static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef( ...@@ -656,10 +656,7 @@ static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
IUnknown* iface) IUnknown* iface)
{ {
_ICOM_THIS_From_NDIUnknown(DefaultHandler, iface); _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
return InterlockedIncrement(&this->ref);
this->ref++;
return this->ref;
} }
/************************************************************************ /************************************************************************
...@@ -674,23 +671,19 @@ static ULONG WINAPI DefaultHandler_NDIUnknown_Release( ...@@ -674,23 +671,19 @@ static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
IUnknown* iface) IUnknown* iface)
{ {
_ICOM_THIS_From_NDIUnknown(DefaultHandler, iface); _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
ULONG ref;
/* /*
* Decrease the reference count on this object. * Decrease the reference count on this object.
*/ */
this->ref--; ref = 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 (ref == 0) DefaultHandler_Destroy(this);
{
DefaultHandler_Destroy(this);
return 0;
}
return this->ref; return ref;
} }
/********************************************************* /*********************************************************
......
...@@ -194,7 +194,7 @@ ULONG WINAPI FileMonikerImpl_AddRef(IMoniker* iface) ...@@ -194,7 +194,7 @@ ULONG WINAPI FileMonikerImpl_AddRef(IMoniker* iface)
TRACE("(%p)\n",iface); TRACE("(%p)\n",iface);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -203,19 +203,16 @@ ULONG WINAPI FileMonikerImpl_AddRef(IMoniker* iface) ...@@ -203,19 +203,16 @@ ULONG WINAPI FileMonikerImpl_AddRef(IMoniker* iface)
ULONG WINAPI FileMonikerImpl_Release(IMoniker* iface) ULONG WINAPI FileMonikerImpl_Release(IMoniker* iface)
{ {
FileMonikerImpl *This = (FileMonikerImpl *)iface; FileMonikerImpl *This = (FileMonikerImpl *)iface;
ULONG ref;
TRACE("(%p)\n",iface); TRACE("(%p)\n",iface);
This->ref--; ref = InterlockedDecrement(&This->ref);
/* destroy the object if there's no more reference on it */ /* destroy the object if there's no more reference on it */
if (This->ref==0){ if (ref == 0) FileMonikerImpl_Destroy(This);
FileMonikerImpl_Destroy(This); return ref;
return 0;
}
return This->ref;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -378,10 +378,7 @@ ULONG WINAPI HGLOBALStreamImpl_AddRef( ...@@ -378,10 +378,7 @@ ULONG WINAPI HGLOBALStreamImpl_AddRef(
IStream* iface) IStream* iface)
{ {
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
return InterlockedIncrement(&This->ref);
This->ref++;
return This->ref;
} }
/*** /***
...@@ -392,12 +389,9 @@ ULONG WINAPI HGLOBALStreamImpl_Release( ...@@ -392,12 +389,9 @@ ULONG WINAPI HGLOBALStreamImpl_Release(
IStream* iface) IStream* iface)
{ {
HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
ULONG newRef; ULONG newRef;
This->ref--; newRef = InterlockedDecrement(&This->ref);
newRef = This->ref;
/* /*
* If the reference count goes down to 0, perform suicide. * If the reference count goes down to 0, perform suicide.
......
...@@ -193,7 +193,7 @@ ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface) ...@@ -193,7 +193,7 @@ ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -202,19 +202,16 @@ ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface) ...@@ -202,19 +202,16 @@ ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface) ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface)
{ {
ItemMonikerImpl *This = (ItemMonikerImpl *)iface; ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
ULONG ref;
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref--; ref = InterlockedDecrement(&This->ref);
/* destroy the object if there's no more reference on it */ /* destroy the object if there's no more reference on it */
if (This->ref==0){ if (ref == 0) ItemMonikerImpl_Destroy(This);
ItemMonikerImpl_Destroy(This); return ref;
return 0;
}
return This->ref;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -217,19 +217,16 @@ StdMarshalImpl_QueryInterface(LPMARSHAL iface,REFIID riid,LPVOID *ppv) { ...@@ -217,19 +217,16 @@ StdMarshalImpl_QueryInterface(LPMARSHAL iface,REFIID riid,LPVOID *ppv) {
static ULONG WINAPI static ULONG WINAPI
StdMarshalImpl_AddRef(LPMARSHAL iface) { StdMarshalImpl_AddRef(LPMARSHAL iface) {
StdMarshalImpl *This = (StdMarshalImpl *)iface; StdMarshalImpl *This = (StdMarshalImpl *)iface;
This->ref++; return InterlockedIncrement(&This->ref);
return This->ref;
} }
static ULONG WINAPI static ULONG WINAPI
StdMarshalImpl_Release(LPMARSHAL iface) { StdMarshalImpl_Release(LPMARSHAL iface) {
StdMarshalImpl *This = (StdMarshalImpl *)iface; StdMarshalImpl *This = (StdMarshalImpl *)iface;
This->ref--; ULONG ref = InterlockedDecrement(&This->ref);
if (This->ref) if (!ref) HeapFree(GetProcessHeap(),0,This);
return This->ref; return ref;
HeapFree(GetProcessHeap(),0,This);
return 0;
} }
static HRESULT WINAPI static HRESULT WINAPI
......
...@@ -351,10 +351,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl_QueryInterface( ...@@ -351,10 +351,7 @@ HRESULT WINAPI HGLOBALLockBytesImpl_QueryInterface(
ULONG WINAPI HGLOBALLockBytesImpl_AddRef(ILockBytes* iface) ULONG WINAPI HGLOBALLockBytesImpl_AddRef(ILockBytes* iface)
{ {
HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface; HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface;
return InterlockedIncrement(&This->ref);
This->ref++;
return This->ref;
} }
/****************************************************************************** /******************************************************************************
...@@ -364,22 +361,19 @@ ULONG WINAPI HGLOBALLockBytesImpl_AddRef(ILockBytes* iface) ...@@ -364,22 +361,19 @@ ULONG WINAPI HGLOBALLockBytesImpl_AddRef(ILockBytes* iface)
ULONG WINAPI HGLOBALLockBytesImpl_Release(ILockBytes* iface) ULONG WINAPI HGLOBALLockBytesImpl_Release(ILockBytes* iface)
{ {
HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface; HGLOBALLockBytesImpl* const This=(HGLOBALLockBytesImpl*)iface;
ULONG ref;
ULONG newRef; ref = InterlockedDecrement(&This->ref);
This->ref--;
newRef = This->ref;
/* /*
* If the reference count goes down to 0, perform suicide. * If the reference count goes down to 0, perform suicide.
*/ */
if (newRef==0) if (ref==0)
{ {
HGLOBALLockBytesImpl_Destroy(This); HGLOBALLockBytesImpl_Destroy(This);
} }
return newRef; return ref;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -280,9 +280,7 @@ ULONG WINAPI HGLOBALLockBytesImpl16_AddRef(ILockBytes16* iface) ...@@ -280,9 +280,7 @@ ULONG WINAPI HGLOBALLockBytesImpl16_AddRef(ILockBytes16* iface)
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref++; return InterlockedIncrement(&This->ref);
return This->ref;
} }
/****************************************************************************** /******************************************************************************
...@@ -292,20 +290,18 @@ ULONG WINAPI HGLOBALLockBytesImpl16_AddRef(ILockBytes16* iface) ...@@ -292,20 +290,18 @@ ULONG WINAPI HGLOBALLockBytesImpl16_AddRef(ILockBytes16* iface)
ULONG WINAPI HGLOBALLockBytesImpl16_Release(ILockBytes16* iface) ULONG WINAPI HGLOBALLockBytesImpl16_Release(ILockBytes16* iface)
{ {
HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface; HGLOBALLockBytesImpl16* const This=(HGLOBALLockBytesImpl16*)iface;
ULONG ref;
ULONG newRef;
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref--; ref = InterlockedDecrement(&This->ref);
newRef = This->ref;
/* /*
* If the reference count goes down to 0, perform suicide. * If the reference count goes down to 0, perform suicide.
*/ */
if (newRef==0) if (ref==0)
HGLOBALLockBytesImpl16_Destroy(This); HGLOBALLockBytesImpl16_Destroy(This);
return newRef; return ref;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -145,7 +145,7 @@ ULONG WINAPI RunningObjectTableImpl_AddRef(IRunningObjectTable* iface) ...@@ -145,7 +145,7 @@ ULONG WINAPI RunningObjectTableImpl_AddRef(IRunningObjectTable* iface)
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/*********************************************************************** /***********************************************************************
...@@ -174,13 +174,14 @@ ULONG WINAPI RunningObjectTableImpl_Release(IRunningObjectTable* iface) ...@@ -174,13 +174,14 @@ ULONG WINAPI RunningObjectTableImpl_Release(IRunningObjectTable* iface)
{ {
DWORD i; DWORD i;
RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface; RunningObjectTableImpl *This = (RunningObjectTableImpl *)iface;
ULONG ref;
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref--; ref = InterlockedDecrement(&This->ref);
/* unitialize ROT structure if there's no more reference to it*/ /* unitialize ROT structure if there's no more reference to it*/
if (This->ref==0){ if (ref == 0) {
/* release all registered objects */ /* release all registered objects */
for(i=0;i<This->runObjTabLastIndx;i++) for(i=0;i<This->runObjTabLastIndx;i++)
...@@ -197,11 +198,9 @@ ULONG WINAPI RunningObjectTableImpl_Release(IRunningObjectTable* iface) ...@@ -197,11 +198,9 @@ ULONG WINAPI RunningObjectTableImpl_Release(IRunningObjectTable* iface)
/* there's no more elements in the table */ /* there's no more elements in the table */
This->runObjTabRegister=0; This->runObjTabRegister=0;
This->runObjTabLastIndx=0; This->runObjTabLastIndx=0;
return 0;
} }
return This->ref; return ref;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -189,17 +189,13 @@ static ULONG WINAPI OleAdviseHolderImpl_Release( ...@@ -189,17 +189,13 @@ static ULONG WINAPI OleAdviseHolderImpl_Release(
LPOLEADVISEHOLDER iface) LPOLEADVISEHOLDER iface)
{ {
OleAdviseHolderImpl *This = (OleAdviseHolderImpl *)iface; OleAdviseHolderImpl *This = (OleAdviseHolderImpl *)iface;
ULONG ref;
TRACE("(%p)->(ref=%ld)\n", This, This->ref); TRACE("(%p)->(ref=%ld)\n", This, This->ref);
This->ref--; ref = InterlockedDecrement(&This->ref);
if (This->ref == 0) if (ref == 0) OleAdviseHolderImpl_Destructor(This);
{
OleAdviseHolderImpl_Destructor(This);
return 0;
}
return This->ref; return ref;
} }
/****************************************************************************** /******************************************************************************
...@@ -524,9 +520,7 @@ static ULONG WINAPI DataAdviseHolder_AddRef( ...@@ -524,9 +520,7 @@ static ULONG WINAPI DataAdviseHolder_AddRef(
{ {
DataAdviseHolder *This = (DataAdviseHolder *)iface; DataAdviseHolder *This = (DataAdviseHolder *)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;
} }
/************************************************************************ /************************************************************************
...@@ -538,24 +532,20 @@ static ULONG WINAPI DataAdviseHolder_Release( ...@@ -538,24 +532,20 @@ static ULONG WINAPI DataAdviseHolder_Release(
IDataAdviseHolder* iface) IDataAdviseHolder* iface)
{ {
DataAdviseHolder *This = (DataAdviseHolder *)iface; DataAdviseHolder *This = (DataAdviseHolder *)iface;
ULONG ref;
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--; ref = 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 (ref==0) DataAdviseHolder_Destructor(This);
{
DataAdviseHolder_Destructor(This);
return 0;
}
return This->ref; return ref;
} }
/************************************************************************ /************************************************************************
......
...@@ -103,20 +103,17 @@ CFStub_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv) { ...@@ -103,20 +103,17 @@ CFStub_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *ppv) {
static ULONG WINAPI static ULONG WINAPI
CFStub_AddRef(LPRPCSTUBBUFFER iface) { CFStub_AddRef(LPRPCSTUBBUFFER iface) {
CFStub *This = (CFStub *)iface; CFStub *This = (CFStub *)iface;
return InterlockedIncrement(&This->ref);
This->ref++;
return This->ref;
} }
static ULONG WINAPI static ULONG WINAPI
CFStub_Release(LPRPCSTUBBUFFER iface) { CFStub_Release(LPRPCSTUBBUFFER iface) {
CFStub *This = (CFStub *)iface; CFStub *This = (CFStub *)iface;
ULONG ref;
This->ref--; ref = InterlockedDecrement(&This->ref);
if (This->ref) if (!ref) HeapFree(GetProcessHeap(),0,This);
return This->ref; return ref;
HeapFree(GetProcessHeap(),0,This);
return 0;
} }
static HRESULT WINAPI static HRESULT WINAPI
...@@ -286,18 +283,18 @@ static HRESULT WINAPI IRpcProxyBufferImpl_QueryInterface(LPRPCPROXYBUFFER iface, ...@@ -286,18 +283,18 @@ static HRESULT WINAPI IRpcProxyBufferImpl_QueryInterface(LPRPCPROXYBUFFER iface,
static ULONG WINAPI IRpcProxyBufferImpl_AddRef(LPRPCPROXYBUFFER iface) { static ULONG WINAPI IRpcProxyBufferImpl_AddRef(LPRPCPROXYBUFFER iface) {
ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface); ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI IRpcProxyBufferImpl_Release(LPRPCPROXYBUFFER iface) { static ULONG WINAPI IRpcProxyBufferImpl_Release(LPRPCPROXYBUFFER iface) {
ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface); ICOM_THIS_MULTI(CFProxy,lpvtbl_proxy,iface);
ULONG ref = InterlockedDecrement(&This->ref);
if (!--(This->ref)) { if (!ref) {
IRpcChannelBuffer_Release(This->chanbuf);This->chanbuf = NULL; IRpcChannelBuffer_Release(This->chanbuf);This->chanbuf = NULL;
HeapFree(GetProcessHeap(),0,This); HeapFree(GetProcessHeap(),0,This);
return 0;
} }
return This->ref; return ref;
} }
static HRESULT WINAPI IRpcProxyBufferImpl_Connect(LPRPCPROXYBUFFER iface,IRpcChannelBuffer* pRpcChannelBuffer) { static HRESULT WINAPI IRpcProxyBufferImpl_Connect(LPRPCPROXYBUFFER iface,IRpcChannelBuffer* pRpcChannelBuffer) {
...@@ -331,17 +328,16 @@ CFProxy_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppv) { ...@@ -331,17 +328,16 @@ CFProxy_QueryInterface(LPCLASSFACTORY iface,REFIID riid, LPVOID *ppv) {
static ULONG WINAPI CFProxy_AddRef(LPCLASSFACTORY iface) { static ULONG WINAPI CFProxy_AddRef(LPCLASSFACTORY iface) {
ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface); ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface);
This->ref++; return InterlockedIncrement(&This->ref);
return This->ref;
} }
static ULONG WINAPI CFProxy_Release(LPCLASSFACTORY iface) { static ULONG WINAPI CFProxy_Release(LPCLASSFACTORY iface) {
ULONG ref;
ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface); ICOM_THIS_MULTI(CFProxy,lpvtbl_cf,iface);
This->ref--;
if (This->ref) ref = InterlockedDecrement(&This->ref);
return This->ref; if (!ref) HeapFree(GetProcessHeap(),0,This);
HeapFree(GetProcessHeap(),0,This); return ref;
return 0;
} }
static HRESULT WINAPI CFProxy_CreateInstance( static HRESULT WINAPI CFProxy_CreateInstance(
......
...@@ -286,20 +286,20 @@ PipeBuf_QueryInterface( ...@@ -286,20 +286,20 @@ PipeBuf_QueryInterface(
static ULONG WINAPI static ULONG WINAPI
PipeBuf_AddRef(LPRPCCHANNELBUFFER iface) { PipeBuf_AddRef(LPRPCCHANNELBUFFER iface) {
PipeBuf *This = (PipeBuf *)iface; PipeBuf *This = (PipeBuf *)iface;
This->ref++; return InterlockedIncrement(&This->ref);
return This->ref;
} }
static ULONG WINAPI static ULONG WINAPI
PipeBuf_Release(LPRPCCHANNELBUFFER iface) { PipeBuf_Release(LPRPCCHANNELBUFFER iface) {
PipeBuf *This = (PipeBuf *)iface; PipeBuf *This = (PipeBuf *)iface;
ULONG ref;
wine_rpc_disconnect_header header; wine_rpc_disconnect_header header;
HANDLE pipe; HANDLE pipe;
DWORD reqtype = REQTYPE_DISCONNECT; DWORD reqtype = REQTYPE_DISCONNECT;
This->ref--; ref = InterlockedDecrement(&This->ref);
if (This->ref) if (ref)
return This->ref; return ref;
FIXME("Free all stuff\n"); FIXME("Free all stuff\n");
......
...@@ -221,10 +221,7 @@ ULONG WINAPI StgStreamImpl_AddRef( ...@@ -221,10 +221,7 @@ ULONG WINAPI StgStreamImpl_AddRef(
IStream* iface) IStream* iface)
{ {
StgStreamImpl* const This=(StgStreamImpl*)iface; StgStreamImpl* const This=(StgStreamImpl*)iface;
return InterlockedIncrement(&This->ref);
This->ref++;
return This->ref;
} }
/*** /***
...@@ -236,21 +233,19 @@ ULONG WINAPI StgStreamImpl_Release( ...@@ -236,21 +233,19 @@ ULONG WINAPI StgStreamImpl_Release(
{ {
StgStreamImpl* const This=(StgStreamImpl*)iface; StgStreamImpl* const This=(StgStreamImpl*)iface;
ULONG newRef; ULONG ref;
This->ref--;
newRef = This->ref; ref = InterlockedDecrement(&This->ref);
/* /*
* If the reference count goes down to 0, perform suicide. * If the reference count goes down to 0, perform suicide.
*/ */
if (newRef==0) if (ref==0)
{ {
StgStreamImpl_Destroy(This); StgStreamImpl_Destroy(This);
} }
return newRef; return ref;
} }
/*** /***
......
...@@ -986,7 +986,7 @@ HRESULT WINAPI IStream16_fnQueryInterface( ...@@ -986,7 +986,7 @@ HRESULT WINAPI IStream16_fnQueryInterface(
*/ */
ULONG WINAPI IStream16_fnAddRef(IStream16* iface) { ULONG WINAPI IStream16_fnAddRef(IStream16* iface) {
IStream16Impl *This = (IStream16Impl *)iface; IStream16Impl *This = (IStream16Impl *)iface;
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -994,15 +994,15 @@ ULONG WINAPI IStream16_fnAddRef(IStream16* iface) { ...@@ -994,15 +994,15 @@ ULONG WINAPI IStream16_fnAddRef(IStream16* iface) {
*/ */
ULONG WINAPI IStream16_fnRelease(IStream16* iface) { ULONG WINAPI IStream16_fnRelease(IStream16* iface) {
IStream16Impl *This = (IStream16Impl *)iface; IStream16Impl *This = (IStream16Impl *)iface;
ULONG ref;
FlushFileBuffers(This->hf); FlushFileBuffers(This->hf);
This->ref--; ref = InterlockedDecrement(&This->ref);
if (!This->ref) { if (!ref) {
CloseHandle(This->hf); CloseHandle(This->hf);
UnMapLS( This->thisptr ); UnMapLS( This->thisptr );
HeapFree( GetProcessHeap(), 0, This ); HeapFree( GetProcessHeap(), 0, This );
return 0;
} }
return This->ref; return ref;
} }
/****************************************************************************** /******************************************************************************
...@@ -1480,7 +1480,7 @@ HRESULT WINAPI IStream_fnQueryInterface( ...@@ -1480,7 +1480,7 @@ HRESULT WINAPI IStream_fnQueryInterface(
*/ */
ULONG WINAPI IStream_fnAddRef(IStream* iface) { ULONG WINAPI IStream_fnAddRef(IStream* iface) {
IStream32Impl *This = (IStream32Impl *)iface; IStream32Impl *This = (IStream32Impl *)iface;
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -1488,14 +1488,14 @@ ULONG WINAPI IStream_fnAddRef(IStream* iface) { ...@@ -1488,14 +1488,14 @@ ULONG WINAPI IStream_fnAddRef(IStream* iface) {
*/ */
ULONG WINAPI IStream_fnRelease(IStream* iface) { ULONG WINAPI IStream_fnRelease(IStream* iface) {
IStream32Impl *This = (IStream32Impl *)iface; IStream32Impl *This = (IStream32Impl *)iface;
ULONG ref;
FlushFileBuffers(This->hf); FlushFileBuffers(This->hf);
This->ref--; ref = InterlockedDecrement(&This->ref);
if (!This->ref) { if (!ref) {
CloseHandle(This->hf); CloseHandle(This->hf);
HeapFree( GetProcessHeap(), 0, This ); HeapFree( GetProcessHeap(), 0, This );
return 0;
} }
return This->ref; return ref;
} }
/* --- IStorage16 implementation */ /* --- IStorage16 implementation */
...@@ -1534,7 +1534,7 @@ HRESULT WINAPI IStorage16_fnQueryInterface( ...@@ -1534,7 +1534,7 @@ HRESULT WINAPI IStorage16_fnQueryInterface(
*/ */
ULONG WINAPI IStorage16_fnAddRef(IStorage16* iface) { ULONG WINAPI IStorage16_fnAddRef(IStorage16* iface) {
IStorage16Impl *This = (IStorage16Impl *)iface; IStorage16Impl *This = (IStorage16Impl *)iface;
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -1542,12 +1542,14 @@ ULONG WINAPI IStorage16_fnAddRef(IStorage16* iface) { ...@@ -1542,12 +1542,14 @@ ULONG WINAPI IStorage16_fnAddRef(IStorage16* iface) {
*/ */
ULONG WINAPI IStorage16_fnRelease(IStorage16* iface) { ULONG WINAPI IStorage16_fnRelease(IStorage16* iface) {
IStorage16Impl *This = (IStorage16Impl *)iface; IStorage16Impl *This = (IStorage16Impl *)iface;
This->ref--; ULONG ref;
if (This->ref) ref = InterlockedDecrement(&This->ref);
return This->ref; if (!ref)
UnMapLS( This->thisptr ); {
HeapFree( GetProcessHeap(), 0, This ); UnMapLS( This->thisptr );
return 0; HeapFree( GetProcessHeap(), 0, This );
}
return ref;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -291,9 +291,7 @@ ULONG WINAPI StorageBaseImpl_AddRef( ...@@ -291,9 +291,7 @@ ULONG WINAPI StorageBaseImpl_AddRef(
IStorage* iface) IStorage* iface)
{ {
StorageBaseImpl *This = (StorageBaseImpl *)iface; StorageBaseImpl *This = (StorageBaseImpl *)iface;
This->ref++; return InterlockedIncrement(&This->ref);
return This->ref;
} }
/************************************************************************ /************************************************************************
...@@ -311,12 +309,12 @@ ULONG WINAPI StorageBaseImpl_Release( ...@@ -311,12 +309,12 @@ ULONG WINAPI StorageBaseImpl_Release(
/* /*
* Decrease the reference count on this object. * Decrease the reference count on this object.
*/ */
This->ref--; ULONG ref = 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 (ref == 0)
{ {
/* /*
* Since we are using a system of base-classes, we want to call the * Since we are using a system of base-classes, we want to call the
...@@ -324,11 +322,9 @@ ULONG WINAPI StorageBaseImpl_Release( ...@@ -324,11 +322,9 @@ ULONG WINAPI StorageBaseImpl_Release(
* using virtual functions to implement the destructor. * using virtual functions to implement the destructor.
*/ */
This->v_destructor(This); This->v_destructor(This);
return 0;
} }
return This->ref; return ref;
} }
/************************************************************************ /************************************************************************
...@@ -3637,9 +3633,7 @@ ULONG WINAPI IEnumSTATSTGImpl_AddRef( ...@@ -3637,9 +3633,7 @@ ULONG WINAPI IEnumSTATSTGImpl_AddRef(
IEnumSTATSTG* iface) IEnumSTATSTG* iface)
{ {
IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface; IEnumSTATSTGImpl* const This=(IEnumSTATSTGImpl*)iface;
return InterlockedIncrement(&This->ref);
This->ref++;
return This->ref;
} }
ULONG WINAPI IEnumSTATSTGImpl_Release( ULONG WINAPI IEnumSTATSTGImpl_Release(
...@@ -3649,8 +3643,7 @@ ULONG WINAPI IEnumSTATSTGImpl_Release( ...@@ -3649,8 +3643,7 @@ ULONG WINAPI IEnumSTATSTGImpl_Release(
ULONG newRef; ULONG newRef;
This->ref--; newRef = InterlockedDecrement(&This->ref);
newRef = This->ref;
/* /*
* If the reference count goes down to 0, perform suicide. * If the reference count goes down to 0, perform suicide.
......
...@@ -194,9 +194,7 @@ static ULONG WINAPI ConnectionPointImpl_AddRef(IConnectionPoint* iface) ...@@ -194,9 +194,7 @@ static ULONG WINAPI ConnectionPointImpl_AddRef(IConnectionPoint* iface)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = (ConnectionPointImpl *)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;
} }
/************************************************************************ /************************************************************************
...@@ -208,24 +206,20 @@ static ULONG WINAPI ConnectionPointImpl_Release( ...@@ -208,24 +206,20 @@ static ULONG WINAPI ConnectionPointImpl_Release(
IConnectionPoint* iface) IConnectionPoint* iface)
{ {
ConnectionPointImpl *This = (ConnectionPointImpl *)iface; ConnectionPointImpl *This = (ConnectionPointImpl *)iface;
ULONG ref;
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--; ref = 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 (ref == 0) ConnectionPointImpl_Destroy(This);
{
ConnectionPointImpl_Destroy(This);
return 0;
}
return This->ref; return ref;
} }
/************************************************************************ /************************************************************************
...@@ -473,10 +467,11 @@ static HRESULT WINAPI EnumConnectionsImpl_QueryInterface( ...@@ -473,10 +467,11 @@ static HRESULT WINAPI EnumConnectionsImpl_QueryInterface(
static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface) static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface)
{ {
EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface;
ULONG ref;
TRACE("(%p)->(ref=%ld)\n", This, This->ref); TRACE("(%p)->(ref=%ld)\n", This, This->ref);
This->ref++; ref = InterlockedIncrement(&This->ref);
IUnknown_AddRef(This->pUnk); IUnknown_AddRef(This->pUnk);
return This->ref; return ref;
} }
/************************************************************************ /************************************************************************
...@@ -487,6 +482,7 @@ static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface) ...@@ -487,6 +482,7 @@ static ULONG WINAPI EnumConnectionsImpl_AddRef(IEnumConnections* iface)
static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface) static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface)
{ {
EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface; EnumConnectionsImpl *This = (EnumConnectionsImpl *)iface;
ULONG ref;
TRACE("(%p)->(ref=%ld)\n", This, This->ref); TRACE("(%p)->(ref=%ld)\n", This, This->ref);
IUnknown_Release(This->pUnk); IUnknown_Release(This->pUnk);
...@@ -494,19 +490,14 @@ static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface) ...@@ -494,19 +490,14 @@ static ULONG WINAPI EnumConnectionsImpl_Release(IEnumConnections* iface)
/* /*
* Decrease the reference count on this object. * Decrease the reference count on this object.
*/ */
This->ref--; ref = 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 (ref == 0) EnumConnectionsImpl_Destroy(This);
{
EnumConnectionsImpl_Destroy(This);
return 0;
}
return This->ref; return ref;
} }
/************************************************************************ /************************************************************************
......
...@@ -278,7 +278,7 @@ static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface) ...@@ -278,7 +278,7 @@ static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface)
StdDispatch *This = (StdDispatch *)iface; StdDispatch *This = (StdDispatch *)iface;
TRACE("()\n"); TRACE("()\n");
return ++This->ref; return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -289,18 +289,18 @@ static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface) ...@@ -289,18 +289,18 @@ static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface)
static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface) static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface)
{ {
StdDispatch *This = (StdDispatch *)iface; StdDispatch *This = (StdDispatch *)iface;
ULONG ret; ULONG ref;
TRACE("(%p)->()\n", This); TRACE("(%p)->()\n", This);
ret = This->ref--; ref = InterlockedDecrement(&This->ref);
if (This->ref == 0) if (ref == 0)
{ {
ITypeInfo_Release(This->pTypeInfo); ITypeInfo_Release(This->pTypeInfo);
CoTaskMemFree(This); CoTaskMemFree(This);
} }
return ret; return ref;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -197,7 +197,7 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface) ...@@ -197,7 +197,7 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
/****************************************************************************** /******************************************************************************
...@@ -206,19 +206,16 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface) ...@@ -206,19 +206,16 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface) static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
{ {
URLMonikerImpl *This = (URLMonikerImpl *)iface; URLMonikerImpl *This = (URLMonikerImpl *)iface;
ULONG ref;
TRACE("(%p)\n",This); TRACE("(%p)\n",This);
This->ref--; ref = InterlockedDecrement(&This->ref);
/* destroy the object if there's no more reference on it */ /* destroy the object if there's no more reference on it */
if (This->ref==0){ if (ref == 0) URLMonikerImpl_Destroy(This);
URLMonikerImpl_Destroy(This); return ref;
return 0;
}
return This->ref;
} }
/****************************************************************************** /******************************************************************************
......
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