Alexandre Julliard : gdi32: Improve tracing of GDI objects to make leaks easier to spot.

Alexandre Julliard julliard at winehq.org
Wed Oct 13 11:43:05 CDT 2010


Module: wine
Branch: master
Commit: f75b7e878833946f53c25310c260d6960a4d05a3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f75b7e878833946f53c25310c260d6960a4d05a3

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Oct 12 21:53:38 2010 +0200

gdi32: Improve tracing of GDI objects to make leaks easier to spot.

---

 dlls/gdi32/gdiobj.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c
index a941e2b..196ebc9 100644
--- a/dlls/gdi32/gdiobj.c
+++ b/dlls/gdi32/gdiobj.c
@@ -635,6 +635,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
 #define MAX_LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE_HANDLE)
 static GDIOBJHDR *large_handles[MAX_LARGE_HANDLES];
 static int next_large_handle;
+static LONG debug_count;
 
 static const char *gdi_obj_type( unsigned type )
 {
@@ -712,6 +713,9 @@ HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs
     large_handles[i] = obj;
     next_large_handle = i;
     LeaveCriticalSection( &gdi_section );
+    TRACE( "allocated %s %p %u/%u\n",
+           gdi_obj_type(type), (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2),
+           InterlockedIncrement( &debug_count ), MAX_LARGE_HANDLES );
     return (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2);
 }
 
@@ -736,6 +740,8 @@ void *free_gdi_handle( HGDIOBJ handle )
     }
     if (object)
     {
+        TRACE( "freed %s %p %u/%u\n", gdi_obj_type( object->type ), handle,
+               InterlockedDecrement( &debug_count ) + 1, MAX_LARGE_HANDLES );
         object->type  = 0;  /* mark it as invalid */
         object->funcs = NULL;
     }
@@ -769,7 +775,6 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
         LeaveCriticalSection( &gdi_section );
         WARN( "Invalid handle %p\n", handle );
     }
-    else TRACE("(%p): enter %d\n", handle, gdi_section.RecursionCount);
 
     return ptr;
 }
@@ -781,7 +786,6 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
  */
 void GDI_ReleaseObj( HGDIOBJ handle )
 {
-    TRACE("(%p): leave %d\n", handle, gdi_section.RecursionCount);
     LeaveCriticalSection( &gdi_section );
 }
 




More information about the wine-cvs mailing list