Author: greatlrd
Date: Sun Apr 9 19:07:43 2006
New Revision: 21532
URL:
http://svn.reactos.ru/svn/reactos?rev=21532&view=rev
Log:
Thanks billycash to explain for me how ref counter works in ddraw. Now we free the COM
when it need it (no more memory leak)
Modified:
trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
trunk/reactos/dll/directx/ddraw/rosdraw.h
Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddra…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Sun Apr 9 19:07:43 2006
@@ -118,11 +118,11 @@
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
ULONG ref=0;
-
+
if (iface!=NULL)
{
- ref = InterlockedIncrement((PLONG)&This->mDDrawGlobal.dwRefCnt);
- }
+ ref = InterlockedIncrement(&This->ref);
+ }
return ref;
}
@@ -143,8 +143,10 @@
if (iface!=NULL)
{
- ref = InterlockedDecrement((PLONG)&This->mDDrawGlobal.dwRefCnt);
-
+ ref = InterlockedDecrement(&This->ref);
+
+ DX_WINDBG_trace_res((INT)This->mDDrawGlobal.dwRefCnt,(INT)ref,(INT)0);
+
if (ref == 0)
{
// set resoltion back to the one in registry
@@ -153,17 +155,11 @@
ChangeDisplaySettings(NULL, 0);
}
-
Hal_DirectDraw_Release(iface);
- //Hel_DirectDraw_Release(iface);
-
- RtlZeroMemory(&This->mDDrawGlobal, sizeof(DDRAWI_DIRECTDRAW_GBL));
- //RtlZeroMemory(This, sizeof(IDirectDrawImpl));
-
+ //Hel_DirectDraw_Release(iface);
if (This!=NULL)
- {
-
- // HeapFree(GetProcessHeap(), 0, This);
+ {
+ HeapFree(GetProcessHeap(), 0, This);
}
}
}
Modified: trunk/reactos/dll/directx/ddraw/rosdraw.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/rosdraw.h…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/rosdraw.h (original)
+++ trunk/reactos/dll/directx/ddraw/rosdraw.h Sun Apr 9 19:07:43 2006
@@ -74,6 +74,9 @@
/* HEL stuff */
DWORD HELMemoryAvilable;
+
+ /* internal counter */
+ ULONG ref;
} IDirectDrawImpl;