- use only stored result of Interlocked* in AddRef/Release

- expand TRACEs to display the ref count
oldstable
James Hawkins 2005-01-12 19:29:43 +00:00 committed by Alexandre Julliard
parent fea45b1493
commit a1e304a25f
3 changed files with 28 additions and 20 deletions

View File

@ -467,10 +467,11 @@ static HRESULT WINAPI IQueryAssociations_fnQueryInterface(
static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations *iface)
{
IQueryAssociationsImpl *This = (IQueryAssociationsImpl *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
TRACE("(%p)->(ref before=%lu)\n",This, This->ref);
return InterlockedIncrement(&This->ref);
return refCount;
}
/**************************************************************************
@ -481,16 +482,17 @@ static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations *iface)
static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations *iface)
{
IQueryAssociationsImpl *This = (IQueryAssociationsImpl *)iface;
ULONG ulRet;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
if (!(ulRet = InterlockedDecrement(&This->ref)))
if (!refCount)
{
TRACE("Destroying IQueryAssociations (%p)\n", This);
HeapFree(GetProcessHeap(), 0, This);
}
return ulRet;
return refCount;
}
/**************************************************************************

View File

@ -78,9 +78,11 @@ static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVO
static ULONG WINAPI IStream_fnAddRef(IStream *iface)
{
ISHFileStream *This = (ISHFileStream *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
TRACE("(%p)\n", This);
return InterlockedIncrement(&This->ref);
return refCount;
}
/**************************************************************************
@ -89,18 +91,19 @@ static ULONG WINAPI IStream_fnAddRef(IStream *iface)
static ULONG WINAPI IStream_fnRelease(IStream *iface)
{
ISHFileStream *This = (ISHFileStream *)iface;
ULONG ulRet;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)\n", This);
if (!(ulRet = InterlockedDecrement(&This->ref)))
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
if (!refCount)
{
IStream_fnCommit(iface, 0); /* If ever buffered, this will be needed */
LocalFree((HLOCAL)This->lpszPath);
CloseHandle(This->hFile);
HeapFree(GetProcessHeap(), 0, This);
}
return ulRet;
return refCount;
}
/**************************************************************************

View File

@ -75,10 +75,11 @@ static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVO
static ULONG WINAPI IStream_fnAddRef(IStream *iface)
{
ISHRegStream *This = (ISHRegStream *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
TRACE("(%p)->(count=%lu)\n",This, This->ref);
return InterlockedIncrement(&This->ref);
return refCount;
}
/**************************************************************************
@ -87,10 +88,11 @@ static ULONG WINAPI IStream_fnAddRef(IStream *iface)
static ULONG WINAPI IStream_fnRelease(IStream *iface)
{
ISHRegStream *This = (ISHRegStream *)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->()\n",This);
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
if (!InterlockedDecrement(&This->ref))
if (!refCount)
{
TRACE(" destroying SHReg IStream (%p)\n",This);
@ -102,7 +104,8 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface)
HeapFree(GetProcessHeap(),0,This);
return 0;
}
return This->ref;
return refCount;
}
/**************************************************************************