From 45000c2da2dd3b82bfeaa62a80bc1f19b34f1c06 Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Thu, 14 Dec 2006 09:20:00 +0000 Subject: [PATCH] start implement release for dd interface, we do not release everthing yet, we still have some memory leak. svn path=/trunk/; revision=25155 --- reactos/dll/directx/ddraw/cleanup.c | 38 ++++++++++++++++++++++++++--- reactos/dll/directx/ddraw/rosdraw.h | 4 ++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/reactos/dll/directx/ddraw/cleanup.c b/reactos/dll/directx/ddraw/cleanup.c index 0b85cb6e9ec..bdf60c74c41 100644 --- a/reactos/dll/directx/ddraw/cleanup.c +++ b/reactos/dll/directx/ddraw/cleanup.c @@ -15,9 +15,41 @@ VOID Cleanup(LPDIRECTDRAW7 iface) { - /* FIXME - free all memory and delete all dx stuff - */ + LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; + + if (ddgbl.lpDDCBtmp != NULL) + { + DxHeapMemFree(ddgbl.lpDDCBtmp); + } + + if (ddgbl.lpModeInfo != NULL) + { + DxHeapMemFree(ddgbl.lpModeInfo); + } + + /* FIXME + delete the DC we create + delete the dx handler we got from hal + any more I forget ? + */ + + /* release the linked interface */ + while (This->lpVtbl != NULL) + { + LPDDRAWI_DIRECTDRAW_INT newThis = This->lpVtbl; + if (This->lpLcl != NULL) + { + DxHeapMemFree(This->lpLcl); + } + + This = newThis; + } + + /* release unlinked interface */ + if (This->lpLcl != NULL) + { + DxHeapMemFree(This->lpLcl); + } } diff --git a/reactos/dll/directx/ddraw/rosdraw.h b/reactos/dll/directx/ddraw/rosdraw.h index a04db4ae979..3fb5e1f0e26 100644 --- a/reactos/dll/directx/ddraw/rosdraw.h +++ b/reactos/dll/directx/ddraw/rosdraw.h @@ -33,7 +33,9 @@ VOID Cleanup(LPDIRECTDRAW7 iface); /* own macro to alloc memmory */ #define DxHeapMemAlloc(m) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m) -#define DxHeapMemFree(p) HeapFree(GetProcessHeap(), 0, p); +#define DxHeapMemFree(p) HeapFree(GetProcessHeap(), 0, p); \ + p = NULL; + /******** Main Object ********/ /* Public interface */