Alexandre Julliard : gdi32: Don't bother freeing graphics drivers.

Alexandre Julliard julliard at winehq.org
Thu May 6 11:13:21 CDT 2010


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu May  6 13:37:32 2010 +0200

gdi32: Don't bother freeing graphics drivers.

---

 dlls/gdi32/dc.c          |    6 -----
 dlls/gdi32/driver.c      |   56 +--------------------------------------------
 dlls/gdi32/gdi_private.h |    2 -
 3 files changed, 2 insertions(+), 62 deletions(-)

diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index 577c151..27d491a 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -674,7 +674,6 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
 
 error:
     if (dc) free_dc_ptr( dc );
-    DRIVER_release_driver( funcs );
     return 0;
 }
 
@@ -759,7 +758,6 @@ HDC WINAPI CreateCompatibleDC( HDC hdc )
             physDev = origDC->physDev;
         }
         release_dc_ptr( origDC );
-        if (funcs) funcs = DRIVER_get_driver( funcs );
     }
 
     if (!funcs && !(funcs = DRIVER_load_driver( displayW ))) return 0;
@@ -790,7 +788,6 @@ HDC WINAPI CreateCompatibleDC( HDC hdc )
 
 error:
     if (dc) free_dc_ptr( dc );
-    DRIVER_release_driver( funcs );
     return 0;
 }
 
@@ -800,7 +797,6 @@ error:
  */
 BOOL WINAPI DeleteDC( HDC hdc )
 {
-    const DC_FUNCTIONS *funcs = NULL;
     DC * dc;
 
     TRACE("%p\n", hdc );
@@ -838,13 +834,11 @@ BOOL WINAPI DeleteDC( HDC hdc )
 	SelectObject( hdc, GetStockObject(WHITE_BRUSH) );
 	SelectObject( hdc, GetStockObject(SYSTEM_FONT) );
         SelectObject( hdc, GetStockObject(DEFAULT_BITMAP) );
-        funcs = dc->funcs;
         if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc->physDev);
         dc->physDev = NULL;
     }
 
     free_dc_ptr( dc );
-    if (funcs) DRIVER_release_driver( funcs );  /* do that after releasing the GDI lock */
     return TRUE;
 }
 
diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c
index 05c2513..bb7af56 100644
--- a/dlls/gdi32/driver.c
+++ b/dlls/gdi32/driver.c
@@ -42,7 +42,6 @@ struct graphics_driver
 {
     struct list             entry;
     HMODULE                 module;  /* module handle */
-    unsigned int            count;   /* reference count */
     DC_FUNCTIONS            funcs;
 };
 
@@ -69,7 +68,6 @@ static struct graphics_driver *create_driver( HMODULE module )
 
     if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
     driver->module = module;
-    driver->count  = 1;
 
     /* fill the function table */
     if (module)
@@ -227,11 +225,7 @@ static struct graphics_driver *load_display_driver(void)
     HMODULE module = 0;
     HKEY hkey;
 
-    if (display_driver)  /* already loaded */
-    {
-        display_driver->count++;
-        return display_driver;
-    }
+    if (display_driver) return display_driver;  /* already loaded */
 
     strcpy( buffer, "x11" );  /* default value */
     /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
@@ -260,7 +254,6 @@ static struct graphics_driver *load_display_driver(void)
         ExitProcess(1);
     }
 
-    display_driver->count++;  /* we don't want to free it */
     return display_driver;
 }
 
@@ -278,7 +271,7 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
     EnterCriticalSection( &driver_section );
 
     /* display driver is a special case */
-    if (!strcmpiW( name, displayW ) || 
+    if (!strcmpiW( name, displayW ) ||
         !strcmpiW( name, display1W ))
     {
         driver = load_display_driver();
@@ -292,7 +285,6 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
         {
             if (driver->module == module)
             {
-                driver->count++;
                 LeaveCriticalSection( &driver_section );
                 return &driver->funcs;
             }
@@ -318,50 +310,6 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
 }
 
 
-/**********************************************************************
- *	     DRIVER_get_driver
- *
- * Get a new copy of an existing driver.
- */
-const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs )
-{
-    struct graphics_driver *driver;
-
-    EnterCriticalSection( &driver_section );
-    LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
-        if (&driver->funcs == funcs) break;
-    if (&driver->entry == &drivers) ERR( "driver not found, trouble ahead\n" );
-    driver->count++;
-    LeaveCriticalSection( &driver_section );
-    return funcs;
-}
-
-
-/**********************************************************************
- *	     DRIVER_release_driver
- *
- * Release a driver by decrementing ref count and freeing it if needed.
- */
-void DRIVER_release_driver( const DC_FUNCTIONS *funcs )
-{
-    struct graphics_driver *driver;
-
-    EnterCriticalSection( &driver_section );
-
-    LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
-    {
-        if (&driver->funcs != funcs) continue;
-        if (--driver->count) break;
-        list_remove( &driver->entry );
-        if (driver == display_driver) display_driver = NULL;
-        FreeLibrary( driver->module );
-        HeapFree( GetProcessHeap(), 0, driver );
-        break;
-    }
-    LeaveCriticalSection( &driver_section );
-}
-
-
 /*****************************************************************************
  *      DRIVER_GetDriverName
  *
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index de00eb4..a3ec954 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -386,8 +386,6 @@ extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
 
 /* driver.c */
 extern const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name ) DECLSPEC_HIDDEN;
-extern const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs ) DECLSPEC_HIDDEN;
-extern void DRIVER_release_driver( const DC_FUNCTIONS *funcs ) DECLSPEC_HIDDEN;
 extern BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size ) DECLSPEC_HIDDEN;
 
 /* enhmetafile.c */




More information about the wine-cvs mailing list