- Use Interlocked* instead of ++/-- in AddRef/Release.

- Use only stored result of Interlocked* in AddRef/Release.
- Expand TRACEs to display the ref count.
oldstable
James Hawkins 2005-01-12 19:55:24 +00:00 committed by Alexandre Julliard
parent 79ecb0d783
commit ed12a3defd
4 changed files with 103 additions and 75 deletions

View File

@ -2374,16 +2374,22 @@ static HRESULT WINAPI IDsDriverBufferImpl_QueryInterface(PIDSDRIVERBUFFER iface,
static ULONG WINAPI IDsDriverBufferImpl_AddRef(PIDSDRIVERBUFFER iface)
{
IDsDriverBufferImpl *This = (IDsDriverBufferImpl *)iface;
TRACE("(%p)\n",iface);
return ++This->ref;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsDriverBufferImpl_Release(PIDSDRIVERBUFFER iface)
{
IDsDriverBufferImpl *This = (IDsDriverBufferImpl *)iface;
TRACE("(%p)\n",iface);
if (--This->ref)
return This->ref;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
if (refCount)
return refCount;
if (This == This->drv->primary)
This->drv->primary = NULL;
DSDB_DestroyMMAP(This);
@ -2560,17 +2566,22 @@ static HRESULT WINAPI IDsDriverImpl_QueryInterface(PIDSDRIVER iface, REFIID riid
static ULONG WINAPI IDsDriverImpl_AddRef(PIDSDRIVER iface)
{
IDsDriverImpl *This = (IDsDriverImpl *)iface;
TRACE("(%p)\n",iface);
This->ref++;
return This->ref;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsDriverImpl_Release(PIDSDRIVER iface)
{
IDsDriverImpl *This = (IDsDriverImpl *)iface;
TRACE("(%p)\n",iface);
if (--This->ref)
return This->ref;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
if (refCount)
return refCount;
HeapFree(GetProcessHeap(),0,This);
return 0;
}

View File

@ -1320,15 +1320,16 @@ static HRESULT WINAPI IDsDriverBufferImpl_QueryInterface(PIDSDRIVERBUFFER iface,
static ULONG WINAPI IDsDriverBufferImpl_AddRef(PIDSDRIVERBUFFER iface)
{
IDsDriverBufferImpl *This = (IDsDriverBufferImpl *)iface;
This->ref++;
return This->ref;
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI IDsDriverBufferImpl_Release(PIDSDRIVERBUFFER iface)
{
IDsDriverBufferImpl *This = (IDsDriverBufferImpl *)iface;
if (--This->ref)
return This->ref;
ULONG refCount = InterlockedDecrement(&This->ref);
if (refCount)
return refCount;
if (This == This->drv->primary)
This->drv->primary = NULL;
DSDB_UnmapPrimary(This);
@ -1479,15 +1480,16 @@ static HRESULT WINAPI IDsDriverImpl_QueryInterface(PIDSDRIVER iface, REFIID riid
static ULONG WINAPI IDsDriverImpl_AddRef(PIDSDRIVER iface)
{
IDsDriverImpl *This = (IDsDriverImpl *)iface;
This->ref++;
return This->ref;
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI IDsDriverImpl_Release(PIDSDRIVER iface)
{
IDsDriverImpl *This = (IDsDriverImpl *)iface;
if (--This->ref)
return This->ref;
ULONG refCount = InterlockedDecrement(&This->ref);
if (refCount)
return refCount;
HeapFree(GetProcessHeap(),0,This);
return 0;
}

View File

@ -172,26 +172,28 @@ static ULONG WINAPI IDsCaptureDriverPropertySetImpl_AddRef(
PIDSDRIVERPROPERTYSET iface)
{
IDsCaptureDriverPropertySetImpl *This = (IDsCaptureDriverPropertySetImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %ld\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsCaptureDriverPropertySetImpl_Release(
PIDSDRIVERPROPERTYSET iface)
{
IDsCaptureDriverPropertySetImpl *This = (IDsCaptureDriverPropertySetImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
TRACE("(%p) ref was %ld\n", This, refCount + 1);
if (!refCount) {
IDsCaptureDriverBuffer_Release((PIDSCDRIVERBUFFER)This->capture_buffer);
This->capture_buffer->property_set = NULL;
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n",This);
}
return ref;
return refCount;
}
static HRESULT WINAPI IDsCaptureDriverPropertySetImpl_Get(
@ -274,26 +276,28 @@ static ULONG WINAPI IDsCaptureDriverNotifyImpl_AddRef(
PIDSDRIVERNOTIFY iface)
{
IDsCaptureDriverNotifyImpl *This = (IDsCaptureDriverNotifyImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %ld\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsCaptureDriverNotifyImpl_Release(
PIDSDRIVERNOTIFY iface)
{
IDsCaptureDriverNotifyImpl *This = (IDsCaptureDriverNotifyImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
TRACE("(%p) ref was %ld\n", This, refCount + 1);
if (!refCount) {
IDsCaptureDriverBuffer_Release((PIDSCDRIVERBUFFER)This->capture_buffer);
This->capture_buffer->notify = NULL;
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n",This);
}
return ref;
return refCount;
}
static HRESULT WINAPI IDsCaptureDriverNotifyImpl_SetNotificationPositions(
@ -421,19 +425,20 @@ static HRESULT WINAPI IDsCaptureDriverBufferImpl_QueryInterface(
static ULONG WINAPI IDsCaptureDriverBufferImpl_AddRef(PIDSCDRIVERBUFFER iface)
{
IDsCaptureDriverBufferImpl *This = (IDsCaptureDriverBufferImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %ld\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsCaptureDriverBufferImpl_Release(PIDSCDRIVERBUFFER iface)
{
IDsCaptureDriverBufferImpl *This = (IDsCaptureDriverBufferImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p) ref was %ld\n", This, refCount + 1);
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
if (!refCount) {
WINE_WAVEIN* wwi;
wwi = &WInDev[This->drv->wDevID];
@ -463,7 +468,7 @@ static ULONG WINAPI IDsCaptureDriverBufferImpl_Release(PIDSCDRIVERBUFFER iface)
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n",This);
}
return ref;
return refCount;
}
static HRESULT WINAPI IDsCaptureDriverBufferImpl_Lock(
@ -727,23 +732,25 @@ static HRESULT WINAPI IDsCaptureDriverImpl_QueryInterface(
static ULONG WINAPI IDsCaptureDriverImpl_AddRef(PIDSCDRIVER iface)
{
IDsCaptureDriverImpl *This = (IDsCaptureDriverImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %ld\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsCaptureDriverImpl_Release(PIDSCDRIVER iface)
{
IDsCaptureDriverImpl *This = (IDsCaptureDriverImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
TRACE("(%p) ref was %ld\n", This, refCount + 1);
if (!refCount) {
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n",This);
}
return ref;
return refCount;
}
static HRESULT WINAPI IDsCaptureDriverImpl_GetDriverDesc(

View File

@ -165,24 +165,26 @@ static HRESULT WINAPI IDsDriverPropertySetImpl_QueryInterface(
static ULONG WINAPI IDsDriverPropertySetImpl_AddRef(PIDSDRIVERPROPERTYSET iface)
{
IDsDriverPropertySetImpl *This = (IDsDriverPropertySetImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %ld\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsDriverPropertySetImpl_Release(PIDSDRIVERPROPERTYSET iface)
{
IDsDriverPropertySetImpl *This = (IDsDriverPropertySetImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
TRACE("(%p) ref was %ld\n", This, refCount + 1);
if (!refCount) {
IDsDriverBuffer_Release((PIDSDRIVERBUFFER)This->buffer);
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n",This);
}
return ref;
return refCount;
}
static HRESULT WINAPI IDsDriverPropertySetImpl_Get(
@ -261,25 +263,27 @@ static HRESULT WINAPI IDsDriverNotifyImpl_QueryInterface(
static ULONG WINAPI IDsDriverNotifyImpl_AddRef(PIDSDRIVERNOTIFY iface)
{
IDsDriverNotifyImpl *This = (IDsDriverNotifyImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %ld\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsDriverNotifyImpl_Release(PIDSDRIVERNOTIFY iface)
{
IDsDriverNotifyImpl *This = (IDsDriverNotifyImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
TRACE("(%p) ref was %ld\n", This, refCount + 1);
if (!refCount) {
IDsDriverBuffer_Release((PIDSDRIVERBUFFER)This->buffer);
HeapFree(GetProcessHeap(), 0, This->notifies);
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n",This);
}
return ref;
return refCount;
}
static HRESULT WINAPI IDsDriverNotifyImpl_SetNotificationPositions(
@ -435,20 +439,22 @@ static HRESULT WINAPI IDsDriverBufferImpl_QueryInterface(PIDSDRIVERBUFFER iface,
static ULONG WINAPI IDsDriverBufferImpl_AddRef(PIDSDRIVERBUFFER iface)
{
IDsDriverBufferImpl *This = (IDsDriverBufferImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %ld\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsDriverBufferImpl_Release(PIDSDRIVERBUFFER iface)
{
IDsDriverBufferImpl *This = (IDsDriverBufferImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&(This->ref));
if (ref)
return ref;
TRACE("(%p) ref was %ld\n", This, refCount + 1);
if (refCount)
return refCount;
if (This == This->drv->primary)
This->drv->primary = NULL;
@ -674,23 +680,25 @@ static HRESULT WINAPI IDsDriverImpl_QueryInterface(PIDSDRIVER iface, REFIID riid
static ULONG WINAPI IDsDriverImpl_AddRef(PIDSDRIVER iface)
{
IDsDriverImpl *This = (IDsDriverImpl *)iface;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedIncrement(&This->ref);
return InterlockedIncrement(&(This->ref));
TRACE("(%p) ref was %ld\n", This, refCount - 1);
return refCount;
}
static ULONG WINAPI IDsDriverImpl_Release(PIDSDRIVER iface)
{
IDsDriverImpl *This = (IDsDriverImpl *)iface;
DWORD ref;
TRACE("(%p) ref was %ld\n", This, This->ref);
ULONG refCount = InterlockedDecrement(&This->ref);
ref = InterlockedDecrement(&(This->ref));
if (ref == 0) {
TRACE("(%p) ref was %ld\n", This, refCount + 1);
if (!refCount) {
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n",This);
}
return ref;
return refCount;
}
static HRESULT WINAPI IDsDriverImpl_GetDriverDesc(PIDSDRIVER iface,