Sync to Wine-20050211
[reactos.git] / reactos / lib / shlwapi / regstream.c
index 14c48d2..172e1bb 100644 (file)
@@ -75,10 +75,11 @@ static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVO
 static ULONG WINAPI IStream_fnAddRef(IStream *iface)\r
 {\r
        ISHRegStream *This = (ISHRegStream *)iface;\r
+       ULONG refCount = InterlockedIncrement(&This->ref);\r
+       \r
+       TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);\r
 \r
-       TRACE("(%p)->(count=%lu)\n",This, This->ref);\r
-\r
-       return InterlockedIncrement(&This->ref);\r
+       return refCount;\r
 }\r
 \r
 /**************************************************************************\r
@@ -87,10 +88,11 @@ static ULONG WINAPI IStream_fnAddRef(IStream *iface)
 static ULONG WINAPI IStream_fnRelease(IStream *iface)\r
 {\r
        ISHRegStream *This = (ISHRegStream *)iface;\r
+       ULONG refCount = InterlockedDecrement(&This->ref);\r
 \r
-       TRACE("(%p)->()\n",This);\r
+       TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);\r
 \r
-       if (!InterlockedDecrement(&This->ref))\r
+       if (!refCount)\r
        {\r
          TRACE(" destroying SHReg IStream (%p)\n",This);\r
 \r
@@ -102,7 +104,8 @@ static ULONG WINAPI IStream_fnRelease(IStream *iface)
          HeapFree(GetProcessHeap(),0,This);\r
          return 0;\r
        }\r
-       return This->ref;\r
+\r
+       return refCount;\r
 }\r
 \r
 /**************************************************************************\r