From 227a0894d4a112a5af4139bbec7105945c0216be Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 8 Apr 2000 21:06:06 +0000 Subject: [PATCH] Removed a number of global handle allocations and critical section initializations. --- dlls/shell32/changenotify.c | 13 ++++--------- dlls/shell32/iconcache.c | 5 +---- dlls/user/user_main.c | 7 ------- dlls/x11drv/x11drv_main.c | 4 ---- files/profile.c | 6 +----- graphics/x11drv/xfont.c | 5 +---- include/cursoricon.h | 2 -- include/message.h | 1 - loader/ne/module.c | 3 --- memory/heap.c | 5 +---- scheduler/sysdeps.c | 2 +- scheduler/syslevel.c | 1 - windows/cursoricon.c | 11 +---------- windows/timer.c | 16 +--------------- windows/x11drv/event.c | 4 ++-- 15 files changed, 13 insertions(+), 72 deletions(-) diff --git a/dlls/shell32/changenotify.c b/dlls/shell32/changenotify.c index 38aabd88122..d2377e4cc99 100644 --- a/dlls/shell32/changenotify.c +++ b/dlls/shell32/changenotify.c @@ -13,9 +13,9 @@ #include "winversion.h" #include "wine/undocshell.h" -DEFAULT_DEBUG_CHANNEL(shell) +DEFAULT_DEBUG_CHANNEL(shell); -static CRITICAL_SECTION SHELL32_ChangenotifyCS; +static CRITICAL_SECTION SHELL32_ChangenotifyCS = CRITICAL_SECTION_INIT; /* internal list of notification clients (internal) */ typedef struct _NOTIFICATIONLIST @@ -30,17 +30,12 @@ typedef struct _NOTIFICATIONLIST DWORD dwFlags; /* client flags */ } NOTIFICATIONLIST, *LPNOTIFICATIONLIST; -NOTIFICATIONLIST head; -NOTIFICATIONLIST tail; +static NOTIFICATIONLIST head; +static NOTIFICATIONLIST tail; void InitChangeNotifications() { TRACE("head=%p tail=%p\n", &head, &tail); - - InitializeCriticalSection(&SHELL32_ChangenotifyCS); - MakeCriticalSectionGlobal(&SHELL32_ChangenotifyCS); - ZeroMemory(&head, sizeof(NOTIFICATIONLIST)); - ZeroMemory(&tail, sizeof(NOTIFICATIONLIST)); head.next = &tail; tail.prev = &head; } diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c index d5a81ed01a3..82a7e644fad 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -451,7 +451,7 @@ typedef struct } SIC_ENTRY, * LPSIC_ENTRY; static HDPA sic_hdpa = 0; -static CRITICAL_SECTION SHELL32_SicCS; +static CRITICAL_SECTION SHELL32_SicCS = CRITICAL_SECTION_INIT; /***************************************************************************** * SIC_CompareEntrys [called by comctl32.dll] @@ -612,9 +612,6 @@ BOOL SIC_Initialize(void) if (sic_hdpa) /* already initialized?*/ return TRUE; - InitializeCriticalSection(&SHELL32_SicCS); - MakeCriticalSectionGlobal(&SHELL32_SicCS); - sic_hdpa = pDPA_Create(16); if (!sic_hdpa) diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c index 83b154c04e4..f076a5b3c28 100644 --- a/dlls/user/user_main.c +++ b/dlls/user/user_main.c @@ -7,7 +7,6 @@ #include "winuser.h" #include "wine/winbase16.h" -#include "cursoricon.h" #include "dce.h" #include "dialog.h" #include "display.h" @@ -61,15 +60,9 @@ BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) /* Create the DCEs */ DCE_Init(); - /* Initialize timers */ - if (!TIMER_Init()) return FALSE; - /* Initialize window procedures */ if (!WINPROC_Init()) return FALSE; - /* Initialize cursor/icons */ - CURSORICON_Init(); - /* Initialize built-in window classes */ if (!WIDGETS_Init()) return FALSE; diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c index d546aa86aa5..ed4683c6c9c 100644 --- a/dlls/x11drv/x11drv_main.c +++ b/dlls/x11drv/x11drv_main.c @@ -156,10 +156,6 @@ static void process_attach(void) CLIPBOARD_Driver = &X11DRV_CLIPBOARD_Driver; WND_Driver = &X11DRV_WND_Driver; - /* We need this before calling any Xlib function */ - InitializeCriticalSection( &X11DRV_CritSection ); - MakeCriticalSectionGlobal( &X11DRV_CritSection ); - putenv("XKB_DISABLE="); /* Disable XKB extension if present. */ /* Open display */ diff --git a/files/profile.c b/files/profile.c index f578c90e368..e2920dc45e7 100644 --- a/files/profile.c +++ b/files/profile.c @@ -81,7 +81,7 @@ static char PROFILE_WineIniUsed[MAX_PATHNAME_LEN] = ""; static const WCHAR wininiW[] = { 'w','i','n','.','i','n','i',0 }; -static CRITICAL_SECTION PROFILE_CritSect; +static CRITICAL_SECTION PROFILE_CritSect = CRITICAL_SECTION_INIT; static const char hex[16] = "0123456789ABCDEF"; @@ -944,10 +944,6 @@ int PROFILE_LoadWineIni(void) ERR("Cannot create config registry key\n" ); return 0; } - wine_profile_key = ConvertToGlobalHandle( wine_profile_key ); - - InitializeCriticalSection( &PROFILE_CritSect ); - MakeCriticalSectionGlobal( &PROFILE_CritSect ); if (!CLIENT_IsBootThread()) return 1; /* already loaded */ diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c index b98461d6318..3d60cef5037 100644 --- a/graphics/x11drv/xfont.c +++ b/graphics/x11drv/xfont.c @@ -208,7 +208,7 @@ static fontEncodingTemplate* fETTable = __fETTable; static int DefResolution = 0; -static CRITICAL_SECTION crtsc_fonts_X11; +static CRITICAL_SECTION crtsc_fonts_X11 = CRITICAL_SECTION_INIT; static fontResource* fontList = NULL; static fontObject* fontCache = NULL; /* array */ @@ -2628,9 +2628,6 @@ BOOL X11DRV_FONT_Init( DeviceCaps* pDevCaps ) XFONT_LoadDefaults(); XFONT_LoadIgnores(); - InitializeCriticalSection( &crtsc_fonts_X11 ); - MakeCriticalSectionGlobal( &crtsc_fonts_X11 ); - /* fontList initialization is over, allocate X font cache */ fontCache = (fontObject*) HeapAlloc(GetProcessHeap(), 0, fontCacheSize * sizeof(fontObject)); diff --git a/include/cursoricon.h b/include/cursoricon.h index cf513d7b2b6..682a63207bf 100644 --- a/include/cursoricon.h +++ b/include/cursoricon.h @@ -70,8 +70,6 @@ typedef struct #define CID_WIN32 0x0004 #define CID_NONSHARED 0x0008 -extern void CURSORICON_Init( void ); - extern HCURSOR16 CURSORICON_IconToCursor( HICON16 hIcon, BOOL bSemiTransparent ); diff --git a/include/message.h b/include/message.h index 9ac0a2de5b3..64859ab0361 100644 --- a/include/message.h +++ b/include/message.h @@ -19,7 +19,6 @@ extern BOOL MSG_InternalGetMessage( int type, struct tagMSG *msg, HWND hwnd, WORD flags, BOOL sendIdle, BOOL* idleSent ); /* timer.c */ -extern BOOL TIMER_Init( void ); extern void TIMER_RemoveWindowTimers( HWND hwnd ); extern void TIMER_RemoveQueueTimers( HQUEUE16 hqueue ); extern BOOL TIMER_GetTimerMsg( struct tagMSG *msg, HWND hwnd, diff --git a/loader/ne/module.c b/loader/ne/module.c index 9c4ad77c07b..696f94d645a 100644 --- a/loader/ne/module.c +++ b/loader/ne/module.c @@ -384,9 +384,6 @@ HANDLE NE_OpenFile( NE_MODULE *pModule ) if ((cachedfd = CreateFileA( name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, -1 )) == -1) MESSAGE( "Can't open file '%s' for module %04x\n", name, pModule->self ); - else - /* FIXME: should not be necessary */ - cachedfd = ConvertToGlobalHandle(cachedfd); TRACE("opened '%s' -> %d\n", name, cachedfd ); return cachedfd; diff --git a/memory/heap.c b/memory/heap.c index 5ee1e2a8383..e8cf809fcfd 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -535,10 +535,7 @@ static BOOL HEAP_InitSubHeap( HEAP *heap, LPVOID address, DWORD flags, /* Initialize critical section */ InitializeCriticalSection( &heap->critSection ); - /* FIXME: once separate address spaces are implemented, only */ - /* the SystemHeap critical section should be global */ - /* if (!SystemHeap) */ - MakeCriticalSectionGlobal( &heap->critSection ); + if (!SystemHeap) MakeCriticalSectionGlobal( &heap->critSection ); } /* Create the first free block */ diff --git a/scheduler/sysdeps.c b/scheduler/sysdeps.c index 09f8c96ce11..9e74f822fed 100644 --- a/scheduler/sysdeps.c +++ b/scheduler/sysdeps.c @@ -36,7 +36,7 @@ static int *ph_errno = &h_errno; DEFAULT_DEBUG_CHANNEL(thread) /* Xlib critical section (FIXME: does not belong here) */ -CRITICAL_SECTION X11DRV_CritSection = { 0, }; +CRITICAL_SECTION X11DRV_CritSection = CRITICAL_SECTION_INIT; #ifdef linux # ifdef HAVE_SCHED_H diff --git a/scheduler/syslevel.c b/scheduler/syslevel.c index 0a94bdfd11b..5a7523e406e 100644 --- a/scheduler/syslevel.c +++ b/scheduler/syslevel.c @@ -59,7 +59,6 @@ SEGPTR WINAPI GetpWin16Lock16(void) VOID WINAPI _CreateSysLevel(SYSLEVEL *lock, INT level) { InitializeCriticalSection( &lock->crst ); - MakeCriticalSectionGlobal( &lock->crst ); lock->level = level; TRACE("(%p, %d): handle is %d\n", diff --git a/windows/cursoricon.c b/windows/cursoricon.c index d69771502e5..e0917810be7 100644 --- a/windows/cursoricon.c +++ b/windows/cursoricon.c @@ -82,18 +82,9 @@ typedef struct tagICONCACHE } ICONCACHE; static ICONCACHE *IconAnchor = NULL; -static CRITICAL_SECTION IconCrst; +static CRITICAL_SECTION IconCrst = CRITICAL_SECTION_INIT; static DWORD ICON_HOTSPOT = 0x42424242; -/********************************************************************** - * CURSORICON_Init - */ -void CURSORICON_Init( void ) -{ - InitializeCriticalSection( &IconCrst ); - MakeCriticalSectionGlobal( &IconCrst ); -} - /********************************************************************** * CURSORICON_FindSharedIcon */ diff --git a/windows/timer.c b/windows/timer.c index a8aeece6519..dd99e40fad1 100644 --- a/windows/timer.c +++ b/windows/timer.c @@ -37,21 +37,7 @@ typedef struct tagTIMER static TIMER TimersArray[NB_TIMERS]; -static CRITICAL_SECTION csTimer; - - -/*********************************************************************** - * TIMER_Init - * - * Initialize critical section for the timer. - */ -BOOL TIMER_Init( void ) -{ - InitializeCriticalSection( &csTimer ); - MakeCriticalSectionGlobal( &csTimer ); - - return TRUE; -} +static CRITICAL_SECTION csTimer = CRITICAL_SECTION_INIT; /*********************************************************************** diff --git a/windows/x11drv/event.c b/windows/x11drv/event.c index ed71c7f26e9..3b3ef6d4a8e 100644 --- a/windows/x11drv/event.c +++ b/windows/x11drv/event.c @@ -2041,7 +2041,7 @@ int X11DRV_EVENT_PrepareShmCompletion( Drawable dw ) int n; if (!shm_read) - shm_read = ConvertToGlobalHandle( FILE_DupUnixHandle( ConnectionNumber(display), GENERIC_READ | SYNCHRONIZE ) ); + shm_read = FILE_DupUnixHandle( ConnectionNumber(display), GENERIC_READ | SYNCHRONIZE ); for (n=0; n