From 11f361a29ca48b54d03b4e11c74d338f062c6d7f Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Sat, 23 Nov 2002 02:24:53 +0000
Subject: [PATCH] Removed no longer needed PROFILE_LoadWineIni().

---
 files/profile.c | 91 +++++++++++++++++++------------------------------
 include/file.h  |  1 -
 loader/main.c   |  3 --
 3 files changed, 36 insertions(+), 59 deletions(-)

diff --git a/files/profile.c b/files/profile.c
index 525e2359a0f..a66c332a65a 100644
--- a/files/profile.c
+++ b/files/profile.c
@@ -83,14 +83,8 @@ static PROFILE *MRUProfile[N_CACHED_PROFILES]={NULL};
 
 #define CurProfile (MRUProfile[0])
 
-/* wine.ini config file registry root */
-static HKEY wine_profile_key;
-
 #define PROFILE_MAX_LINE_LEN   1024
 
-/* Wine profile: the profile file being used */
-static char PROFILE_WineIniUsed[MAX_PATHNAME_LEN] = "";
-
 /* Check for comments in profile */
 #define IS_ENTRY_COMMENT(str)  ((str)[0] == ';')
 
@@ -896,6 +890,41 @@ static BOOL PROFILE_SetString( LPCWSTR section_name, LPCWSTR key_name,
 }
 
 
+/***********************************************************************
+ *           get_profile_key
+ */
+static HKEY get_profile_key(void)
+{
+    static HKEY profile_key;
+
+    if (!profile_key)
+    {
+        OBJECT_ATTRIBUTES attr;
+        UNICODE_STRING nameW;
+        HKEY hkey;
+
+        attr.Length = sizeof(attr);
+        attr.RootDirectory = 0;
+        attr.ObjectName = &nameW;
+        attr.Attributes = 0;
+        attr.SecurityDescriptor = NULL;
+        attr.SecurityQualityOfService = NULL;
+
+        if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\Software\\Wine\\Wine\\Config" ) ||
+            NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, REG_OPTION_VOLATILE, NULL ))
+        {
+            ERR("Cannot create config registry key\n" );
+            ExitProcess( 1 );
+        }
+        RtlFreeUnicodeString( &nameW );
+
+        if (InterlockedCompareExchangePointer( (void **)&profile_key, hkey, 0 ))
+            NtClose( hkey );  /* somebody beat us to it */
+    }
+    return profile_key;
+}
+
+
 /***********************************************************************
  *           PROFILE_GetWineIniString
  *
@@ -910,7 +939,7 @@ int PROFILE_GetWineIniString( LPCWSTR section, LPCWSTR key_name,
     UNICODE_STRING nameW;
 
     attr.Length = sizeof(attr);
-    attr.RootDirectory = wine_profile_key;
+    attr.RootDirectory = get_profile_key();
     attr.ObjectName = &nameW;
     attr.Attributes = 0;
     attr.SecurityDescriptor = NULL;
@@ -988,54 +1017,6 @@ int  PROFILE_GetWineIniBool( LPCWSTR section, LPCWSTR key_name, int def )
 }
 
 
-/***********************************************************************
- *           PROFILE_LoadWineIni
- *
- * Load the old .winerc file.
- */
-int PROFILE_LoadWineIni(void)
-{
-    OBJECT_ATTRIBUTES attr;
-    UNICODE_STRING nameW;
-    char buffer[MAX_PATHNAME_LEN];
-    const char *p;
-    FILE *f;
-    HKEY hKeySW;
-    DWORD disp;
-
-    attr.Length = sizeof(attr);
-    attr.RootDirectory = 0;
-    attr.ObjectName = &nameW;
-    attr.Attributes = 0;
-    attr.SecurityDescriptor = NULL;
-    attr.SecurityQualityOfService = NULL;
-
-    /* make sure HKLM\\Software\\Wine\\Wine exists as non-volatile key */
-    if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\Software\\Wine\\Wine" ) ||
-        NtCreateKey( &hKeySW, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp ))
-    {
-        ERR("Cannot create config registry key\n" );
-        ExitProcess( 1 );
-    }
-    RtlFreeUnicodeString( &nameW );
-    NtClose( hKeySW );
-
-    if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\Software\\Wine\\Wine\\Config" ) ||
-        NtCreateKey( &wine_profile_key, KEY_ALL_ACCESS, &attr, 0,
-                     NULL, REG_OPTION_VOLATILE, &disp ))
-    {
-        ERR("Cannot create config registry key\n" );
-        ExitProcess( 1 );
-    }
-    RtlFreeUnicodeString( &nameW );
-
-    if (disp == REG_OPENED_EXISTING_KEY) return 1;  /* loaded by the server */
-
-    MESSAGE( "Can't open configuration file %s/config\n", wine_get_config_dir() );
-    return 0;
-}
-
-
 /***********************************************************************
  *           PROFILE_UsageWineIni
  *
diff --git a/include/file.h b/include/file.h
index 60aed614eee..d9f8b923495 100644
--- a/include/file.h
+++ b/include/file.h
@@ -109,7 +109,6 @@ extern int DOSFS_FindNext( const char *path, const char *short_mask,
                            int skip, WIN32_FIND_DATAA *entry );
 
 /* profile.c */
-extern int PROFILE_LoadWineIni(void);
 extern void PROFILE_UsageWineIni(void);
 extern int PROFILE_GetWineIniString( LPCWSTR section, LPCWSTR key_name,
                                      LPCWSTR def, LPWSTR buffer, int len );
diff --git a/loader/main.c b/loader/main.c
index 12dd29f74de..8e238050ec9 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -67,9 +67,6 @@ BOOL MAIN_MainInit(void)
     setbuf(stderr,NULL);
     setlocale(LC_CTYPE,"");
 
-    /* Load the configuration file */
-    if (!PROFILE_LoadWineIni()) return FALSE;
-
     /* Initialise DOS drives */
     if (!DRIVE_Init()) return FALSE;
 
-- 
GitLab