rpcrt4: Use interlocked functions to increment/decrement ref counts.
This commit is contained in:
parent
b75828fc90
commit
6f8749b7bc
|
@ -65,7 +65,7 @@ static HRESULT WINAPI CStdPSFactory_QueryInterface(LPPSFACTORYBUFFER iface,
|
|||
if (IsEqualGUID(&IID_IUnknown,riid) ||
|
||||
IsEqualGUID(&IID_IPSFactoryBuffer,riid)) {
|
||||
*obj = This;
|
||||
This->RefCount++;
|
||||
InterlockedIncrement( &This->RefCount );
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
|
@ -75,14 +75,14 @@ static ULONG WINAPI CStdPSFactory_AddRef(LPPSFACTORYBUFFER iface)
|
|||
{
|
||||
CStdPSFactoryBuffer *This = (CStdPSFactoryBuffer *)iface;
|
||||
TRACE("(%p)->AddRef()\n",iface);
|
||||
return ++(This->RefCount);
|
||||
return InterlockedIncrement( &This->RefCount );
|
||||
}
|
||||
|
||||
static ULONG WINAPI CStdPSFactory_Release(LPPSFACTORYBUFFER iface)
|
||||
{
|
||||
CStdPSFactoryBuffer *This = (CStdPSFactoryBuffer *)iface;
|
||||
TRACE("(%p)->Release()\n",iface);
|
||||
return --(This->RefCount);
|
||||
return InterlockedDecrement( &This->RefCount );
|
||||
}
|
||||
|
||||
static HRESULT WINAPI CStdPSFactory_CreateProxy(LPPSFACTORYBUFFER iface,
|
||||
|
|
|
@ -79,7 +79,7 @@ static HMODULE LoadCOM(void)
|
|||
typedef struct RpcStreamImpl
|
||||
{
|
||||
const IStreamVtbl *lpVtbl;
|
||||
DWORD RefCount;
|
||||
LONG RefCount;
|
||||
PMIDL_STUB_MESSAGE pMsg;
|
||||
LPDWORD size;
|
||||
unsigned char *data;
|
||||
|
@ -95,7 +95,7 @@ static HRESULT WINAPI RpcStream_QueryInterface(LPSTREAM iface,
|
|||
IsEqualGUID(&IID_ISequentialStream, riid) ||
|
||||
IsEqualGUID(&IID_IStream, riid)) {
|
||||
*obj = This;
|
||||
This->RefCount++;
|
||||
InterlockedIncrement( &This->RefCount );
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOINTERFACE;
|
||||
|
@ -104,19 +104,20 @@ static HRESULT WINAPI RpcStream_QueryInterface(LPSTREAM iface,
|
|||
static ULONG WINAPI RpcStream_AddRef(LPSTREAM iface)
|
||||
{
|
||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
||||
return ++(This->RefCount);
|
||||
return InterlockedIncrement( &This->RefCount );
|
||||
}
|
||||
|
||||
static ULONG WINAPI RpcStream_Release(LPSTREAM iface)
|
||||
{
|
||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
||||
if (!--(This->RefCount)) {
|
||||
ULONG ref = InterlockedDecrement( &This->RefCount );
|
||||
if (!ref) {
|
||||
TRACE("size=%d\n", *This->size);
|
||||
This->pMsg->Buffer = This->data + *This->size;
|
||||
HeapFree(GetProcessHeap(),0,This);
|
||||
return 0;
|
||||
}
|
||||
return This->RefCount;
|
||||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI RpcStream_Read(LPSTREAM iface,
|
||||
|
|
Loading…
Reference in New Issue