- Use only stored result of Interlocked* in AddRef/Release.

- Expand TRACEs to display the ref count.
This commit is contained in:
James Hawkins 2005-01-12 19:52:38 +00:00 committed by Alexandre Julliard
parent 11db0ea655
commit 79ecb0d783
2 changed files with 21 additions and 23 deletions

View File

@ -78,25 +78,25 @@ static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* if
static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
{
SecManagerImpl *This = (SecManagerImpl *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)\n",This);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
return InterlockedIncrement(&This->ref);
return refCount;
}
static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
{
SecManagerImpl *This = (SecManagerImpl *)iface;
ULONG ref;
TRACE("(%p)\n",This);
ULONG refCount = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
/* destroy the object if there's no more reference on it */
if (ref==0){
if (!refCount){
HeapFree(GetProcessHeap(),0,This);
}
return ref;
return refCount;
}
static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
@ -238,10 +238,11 @@ static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManager* iface, RE
static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
{
ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p) was %lu\n", This, This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
return InterlockedIncrement(&This->ref);
return refCount;
}
/********************************************************************
@ -250,15 +251,13 @@ static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
{
ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
ULONG ref;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) was %lu\n", This, This->ref);
ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
if(!ref)
if(!refCount)
HeapFree(GetProcessHeap(), 0, This);
return ref;
return refCount;
}
/********************************************************************

View File

@ -103,10 +103,11 @@ static HRESULT WINAPI URLMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,
static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)\n",This);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
return InterlockedIncrement(&This->ref);
return refCount;
}
/******************************************************************************
@ -115,19 +116,17 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
ULONG ref;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)\n",This);
ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
/* destroy the object if there's no more reference on it */
if (ref == 0) {
if (!refCount) {
HeapFree(GetProcessHeap(),0,This->URLName);
HeapFree(GetProcessHeap(),0,This);
}
return ref;
return refCount;
}
/******************************************************************************